www.webdeveloper.com
Results 1 to 3 of 3

Thread: how to do it in xslt?

  1. #1
    Join Date
    Oct 2003
    Posts
    1

    Unhappy 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.

  2. #2
    Join Date
    Dec 2002
    Location
    Calgary, Canada
    Posts
    6,123
    You can forward a variable to a template.
    using the following syntax

    <xsl:call-template name = "templateName"> <xsl:with-param name = "varName" select = "elementName"/>
    </xsl:call-template>
    Cheers

    Khalid

    Message Posting Guidelines In These Forums, Please read these before posting any question.
    Web site: webapplikations.com
    Web Resources Page:Web Resources

  3. #3
    Join Date
    Sep 2003
    Location
    Australia
    Posts
    37
    heres an example of using variables in XSL...

    <body>
    <xsl:variable name="bookCount" select="count(//book)"/>
    <xsl:variable name="bookTotal" select="sum(//book/price)"/>
    <xsl:variable name="bookAverage" select="$bookTotal div $bookCount"/>
    <table border="1">
    .
    .
    .
    .
    .
    .
    <td align="right">
    <xsl:value-of select="format-number($bookAverage, '#.00')"/>
    </td>

    HTH...

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles