Click to See Complete Forum and Search --> : how to do it in xslt?


newtoxml
October 31st, 2003, 07:49 PM
I have an xml file looks like this:

<root>
<L1>a</L1>
<L2>b
<L3>c</L3>
</L2>
</root>

In my xslt file, I do a template match to get to <L3>

<xsl:template match="L2/L3">
need to use the value of L1.
</xsl:template>

Assuming that I get to the node of L3. Now, my question is, how do I get the value of L1 inside of the that match template? Is there a global variable or something in xslt so I can store the L1's value in that global variable and use it in the match template?

Can anyone tell me how I can do this in xslt? Please give me some details because I am still learning this stuff :-)

Thanks in advance.

khp
October 31st, 2003, 08:49 PM
Originally posted by newtoxml

Assuming that I get to the node of L3. Now, my question is, how do I get the value of L1 inside of the that match template?

Something like this should do the trick..

<xsl:value-of select="parent::L2/preceding-sibling::L1"/>



Originally posted by newtoxml
Is there a global variable or something in xslt so I can store the L1's value in that global variable and use it in the match template?

There is something called variables, and they can be declared globally. But they are more like global constants, you can't change them durring the execution of the style-sheet. So they can't really help you in this.

newtoxml
October 31st, 2003, 10:12 PM
Thanks a lot. That's exactly what I need.