[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: handling tags and PIs within a macro
Nancy Brandt wrote:
<formalpara id="{fid}"> --> This part That's a way to tell the XSLT processor that inside the attribute there's a value that should be interpreted as an XPath expression. It is called an Attribute Value Template (or AVT for short). You can write: <formalpara> <xsl:attribute name="id"><xsl:value-of select="fid" /></xsl:attribute> </ Or you can write: <formalpara id="{fid}"> </ which is quite shorter and closer to what it will eventually look like: an element with the "id" attribute set to whatever is in inside the 'fid" node (without curlies, this would be the literal "fid" string, instead of the content of <fid>). If you, for whatever reason, need an explicit { or } inside an attribute, you need to double it: <formalpara id="{{doublecurlies}}"> </ You can use any valid XPath expression. It's result will be the string-value of that expression (equal to when you would use the xsl:value-of approach instead). Now you may wonder why there's still the verbose construct with xsl:attribute, if this is so much clearer with an AVT. Well, the short answer is: there are situations where an AVT does not suffice. I.e., when you want the name of the attribute to be dynamically generated, then, inside the xsl:attribute, the @name attribute itself is also an AVT: <formalpara> <xsl:attribute name="{attrName}"><xsl:value-of select="fid" /></xsl:attribute> </ will create a formalpara element with an attribute with the name of whatever is inside the attrName element. If the source looked like <attrName>my-jolly-attribute</attrName><fid>Fidelity Content</fid> then the output would be <formalpara my-jolly-attribute="Fidelity Content"> </
|
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
|