Nancy Brandt wrote:
<formalpara id="{fid}"> --> This part
Why is it important to enclose the "id" part in curly
brackets?
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">
</
HTH,
Cheers,
-- Abel Braaksma
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--