Re: Global Variables (use of)

Subject: Re: Global Variables (use of)
From: David Carlisle <davidc@xxxxxxxxx>
Date: Fri, 21 Jul 2000 17:57:42 GMT
<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


Current Thread