how to do it in xslt?

Discussion in 'XML' started by David Way, Nov 1, 2003.

  1. David Way

    David Way Guest

    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.
     
    David Way, Nov 1, 2003
    #1
    1. Advertising

  2. > 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:...
    > 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, Nov 1, 2003
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Stylus Studio
    Replies:
    0
    Views:
    693
    Stylus Studio
    Aug 3, 2004
  2. Benjamin Hillsley
    Replies:
    3
    Views:
    1,693
    Dimitre Novatchev
    Sep 25, 2003
  3. ted
    Replies:
    1
    Views:
    626
    Laurens
    Jan 26, 2004
  4. Replies:
    2
    Views:
    726
    Henry S. Thompson
    Oct 19, 2005
  5. Replies:
    4
    Views:
    684
Loading...

Share This Page