[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

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
making xsl variable global
<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

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-2013 All Rights Reserved.