Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Variables in XSL? 1

Status
Not open for further replies.

Henk1

Programmer
Oct 26, 2001
46
ZA
Can you use variables in XSL. I know about the <xsl:variable command, but I cannot seem to change the value. Is there a way of changing its value or is there another command?

Thank you,
Henk
 
you can't change the value of variables in xsl. this is intentional and is the main idea behind the language is that there are no variables (it's a &quot;functional language&quot;).

the <xsl:variable> tag is maybe a confusing name. they should be thought of as references only - so their aim in life is to save you having to type so much when you want to reference the same thing over and over, ie. they really don't change.

you don't need to use traditional variables to do anything in xsl tho. it's hard to explain the thinking behind this approach :) but if there was anything in particular you need to do then post it. once you see one example it becomes clearer.
 
Thanks for the info. I sort of figured that you can't change it.

I want to loop through a list of objects, and give each object a unique numeric value for use in HTML. I wanted to do this through variables. Is there another way?

Henk

 
you might be able to use position().

<xsl:for-each select=&quot;object&quot;>
<xsl:value-of select=&quot;position()&quot;/><br/>
</xsl:value-of>

position() will return where you are in your list of nodes.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top