how to do it in xslt?

David Way

Usenet Archive
Joined
Oct 31, 2003
Messages
1
Reaction score
0
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.
 

Dimitre Novatchev

Usenet Archive
Joined
Nov 7, 2000
Messages
737
Reaction score
0
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?

No need for global variables here. Also, the knoledge required (as is often the case) is pure XPath.

Use:

../preceding-sibling::L1[1]

=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
548,042
Messages
3,104,224
Members
248,132
Latest member
henrywalsh

Latest Threads

Top