Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > how to do it in xslt?

Reply
Thread Tools

how to do it in xslt?

 
 
David Way
Guest
Posts: n/a
 
      11-01-2003
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.
 
Reply With Quote
 
 
 
 
Dimitre Novatchev
Guest
Posts: n/a
 
      11-01-2003
> 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



"David Way" <> wrote in message
news: om...
> 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.



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off




Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57