views:

77

answers:

2

hi friends I am getting a particular value by using

<xsl:value-of select="@date" />

and i want to store this value as a variable say 'd' How can i do this and also tell me how can i use that caribale back in my template. Thanks in advance

+3  A: 
<xsl:variable name="d" select="@date" />
<xsl:value-of select="$d" />

Looking through the basics might be worthwhile. ;-)

Tomalak
+2  A: 

That would be

<xsl:variable name="date" select="@date" />

to declare a symbol referencing the node @date.

To use it later on you can reference that symbol by prefixing the name with $:

<xsl:value-of select="$date" />

Note that once the symbol is declared you cannot change its value in XSLT.

0xA3
@divo: Casual nitpicking: You're not declaring a symbol with the *value of* @date, but rather one with a *reference to* the node.
Tomalak
Thanks Tomalak, my mistake. That's actually quite a difference.
0xA3