Subject: RE: using <xsl:variable> From: Ben Robb <Ben@xxxxxxxxxx> Date: Tue, 26 Sep 2000 16:22:35 +0100 |
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: using <xsl:variable>, Kay Michael | Thread | Q XSLT: How to copy elements with X, v . rudowitsch |
Q XSLT: How to copy elements with X, v . rudowitsch | Date | Re: (2 xpath questions), Taras Tielkes |
Month |