[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

Subject: Re: Using <eval> to get a value for a flow object attribute
From: Chris Maden <crism@xxxxxxx>
Date: Thu, 7 May 1998 17:52:46 -0400 (EDT)
object attribute value
[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(&quot;label&quot;)">
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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2007 All Rights Reserved.