|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Global Variables (use of)
<xsl:variable name="sectnum"><xsl:value-of
select="child::title/attribute::id"/></xsl:variable>
which could be more simply written
<xsl:variable name="sectnum"><xsl:value-of select="title/@id"/></xsl:variable>
will define $sectnum to be the result tree fragment consisting of
a root node and a single text node consisting of the value of the
id attribute of the title child of the root node (if there is one)
or the empty string (if not)
But from your description it seems that title is not the top level
element of your source, so this will always return a result tree
fragment containing a text node with the empty string.
I'm not sure what you were trying to do
but guessing from
> IfI need to build a TOC where all the titles are reproduced as anchors
> with the id value as the href,
I doubt you want a variable at all, but rather something like
this in whichever template is making your top level document body, at
the point you want the toc.
<xsl:for-each select="//title">
<a href="#{@id}"><xsl:value-of select="."/></a><br/>
</xsl:for-each>
(a real example would be fancier, distinguishing sections from
subsections etc)
David
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
|

Cart








