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

RE: using <xsl:variable>

Subject: RE: using <xsl:variable>
From: Ben Robb <Ben@xxxxxxxxxx>
Date: Tue, 26 Sep 2000 16:22:35 +0100
using xslt variables
Dhruv,

You are falling into the common mistake that most people go through. You may
not change a value in the XSL once it has been set once, and this includes
variables. This is to make the language side-effect free, and so make its
processing time shorter.

So you may ask "why call it a variable?". The answer to this is that it *is*
a variable in the sense that at the time of writing the XSL, the value of
that particular node is not known.

However, in your case it should be possible to get around your problem with
something like this (though without the source XML I can't be sure...):

<xsl:template match="figure">
<xsl:variable name="fig" select="position()"/>
<xsl:value-of select="$fig"/>
------
</xsl:template>

The value of the "fig" variable cannot change once it has been set in the
template, but is "reset" every time the template is called (think of it like
a local variable in function based programming). Hence, you will see the fig
variable incrementing every time the template is called, which is (I think)
what you wanted.

If is not (for example, you just want a count), then email the list with a
more specific breakdown of your problem...

Hope this helps,

Ben


 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.