Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   XML (http://www.velocityreviews.com/forums/f32-xml.html)
-   -   how to do it in xslt? (http://www.velocityreviews.com/forums/t165971-how-to-do-it-in-xslt.html)

David Way 11-01-2003 12:38 AM

how to do it in xslt?
 
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 11-01-2003 06:27 AM

Re: how to do it in xslt?
 
> 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" <swingall2003@yahoo.com> wrote in message
news:17d9fab7.0310311638.45a5466d@posting.google.c 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.





All times are GMT. The time now is 07:28 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.