|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Using <eval> to get a value for a flow object attribute
[Ed Burns] > How can I use the eval tag to get an attribute from the current > element and have that be rendered as the value of an attribute in > the result output? > > This example uses HTML flow objects. Note that <SELECT> is a flow > object, not an XSL tag. (MSXSL and DOCPROC they handle this by > replacing <select> with <select-elements>.) > > <rule> > <target-element type="system"/> > <SELECT NAME="<eval>getAttribute("label")</eval>"> > <children/> > </rule> > > Is there any way to escape the enclosing quotes? More confusion brought about by "HTML flow objects". <SELECT> is an *element*, not text that looks like one. In XSL '97, it means "make a select element". NAME is an attribute of the <SELECT> element. The string '<eval>' inside an attribute value is just that, a string, not an element. Elements can not occur inside attribute values. And finally, <SELECT> is unclosed; the above sample is not a well-formed XML document (as all XSL stylesheets must be). Now, as to how to fix this: Any attribute value can start with an equals sign, and the rest of the attribute value will be evaluated as an ECMAscript expression. The quotes are a problem, and the '97 submission is unclear on the order in which things are processed. An XML parser should resolve any entity references, so you could do <SELECT NAME="=getAttribute("label")"> but I wouldn't trust MSXSL to have implemented that yet. It's worth testing, but for robustness, I'd do this: <rule> <target-element type="system"/> <SELECT NAME='=getAttribute("label")'> <children/> </SELECT> </rule> -Chris -- <!NOTATION SGML.Geek PUBLIC "-//Anonymous//NOTATION SGML Geek//EN"> <!ENTITY crism PUBLIC "-//O'Reilly//NONSGML Christopher R. Maden//EN" "<URL>http://www.oreilly.com/people/staff/crism/ <TEL>+1.617.499.7487 <USMAIL>90 Sherman Street, Cambridge, MA 02140 USA" NDATA SGML.Geek> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|






