[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: for-each issue

Subject: Re: for-each issue
From: "Mukul Gandhi" <gandhi.mukul@xxxxxxxxx>
Date: Thu, 27 Mar 2008 16:02:03 +0530
Re:  for-each issue
On 3/27/08, Z W <mpc8250@xxxxxxxxx> wrote:
> <td>
> <xsl:variable name="cib_time_duration">
> <xsl:for-each select="document($currentJTL)/testResults/*[not(@label =
> preceding::*/@label)]">
> <xsl:variable name="minTimeStamp_prev_2">
>        <xsl:call-template name="find_minTimeStamp_prev_2">                     <xsl:with-param
> name="nodes" select="/testResults/sampleResult" />
>        </xsl:call-template>
> </xsl:variable>
>
> <xsl:variable name="maxTimeStamp_prev_2">
>        <xsl:call-template name="find_maxTimeStamp_prev_2">
>        <xsl:with-param name="nodes" select="/testResults/sampleResult" />
>                </xsl:call-template>
> </xsl:variable>
>
> <xsl:variable name="timeSpan" select="$maxTimeStamp_prev_2
> -$minTimeStamp_prev_2" />
> <xsl:value-of select="$timeSpan"/>
> </xsl:for-each>
> </xsl:variable>
>
> <xsl:value-of select="$cib_time_duration"/>
>
> </td>
>
> But I get the $cib_time_duration printed 3 times. How do I get it to
> print once ?

This might solve the problem

<xsl:variable name="cib_time_duration">
   <xsl:for-each select="document($currentJTL)/testResults/*[not(@label =
             preceding::*/@label)]">
      <!-- keep the code here
            as it is
      -->
      <xsl:if test="position() = last()">
         <xsl:value-of select="$timeSpan"/>
      </xsl:if>
   </xsl:for-each>
</xsl:variable>

<xsl:value-of select="$cib_time_duration" />

Though I have a feeling, you can structure the code even better.

-- 
Regards,
Mukul Gandhi

Current Thread
  • for-each issue
    • Z W - 27 Mar 2008 07:52:43 -0000
      • Mukul Gandhi - 27 Mar 2008 08:29:07 -0000
        • Z W - 27 Mar 2008 09:55:04 -0000
          • Mukul Gandhi - 27 Mar 2008 10:32:23 -0000 <=
          • Z W - 27 Mar 2008 10:40:23 -0000
          • Z W - 27 Mar 2008 10:53:10 -0000
          • Mukul Gandhi - 27 Mar 2008 11:55:51 -0000
          • Z W - 27 Mar 2008 15:10:59 -0000

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2007 All Rights Reserved.