Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 25th, 2003, 06:26 PM
Authorized User
 
Join Date: Jun 2003
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default Adding numbers

I am struggling to figure out XML and XSL as I go, so please treat me like a complete novice.

I have the following XML output from an SQL database:

- <Target>
- <Target_T Test_Run_ID="47" Target_ID="76" Target_Name_VC="auto-target12">
  <Test_T PF="1" Duration="324" />
  <Test_T PF="1" Duration="371" />
  <Test_T PF="1" Duration="166" />
  <Test_T PF="1" Duration="169" />
  <Test_T PF="2" Duration="0" />
  <Test_T PF="1" Duration="1658" />
  </Target_T>
  </Target>

I'm trying to get a sum of the Duration values, and displaying it in a table. I've created the template at the end of this message, and am calling it via the following:

<xsl:for-each select="Target/Target_T">
<TR>
<TD>
    <xsl:apply-template name="totDuration"/>
</TD>
</TR>
</xsl:for-each>

IE6 reports "Keyword xsl:apply-template may not be used here." I can't figure out why. Can anyone help me? Any hints would be most appreciated.

Here's the template:

<xsl:template name="totDuration">
  <xsl:param name="Tests" select="Test_T" />
  <xsl:param name="subtotal" select="0" />
  <xsl:choose>
    <xsl:when test="$Tests">
      <xsl:call-template name="totDuration">
        <xsl:with-param name="Tests"
                        select="$Tests[position() > 1]" />
        <xsl:with-param name="subtotal"
          select="$subtotal + substring-before($Tests[1], ':')" />
      </xsl:call-template>
    </xsl:when>
    <xsl:otherwise>
      <xsl:value-of select="$subtotal" />
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>
 
Old June 26th, 2003, 10:14 AM
Authorized User
 
Join Date: Jun 2003
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Sorry for the double-post.





Similar Threads
Thread Thread Starter Forum Replies Last Post
adding up 2 numbers in xsl umair.aziz XSLT 3 July 14th, 2006 09:24 AM
regarding adding numbers in xsl umair.aziz XSLT 1 June 24th, 2006 12:12 PM
Adding numbers Hudson40 Excel VBA 3 November 23rd, 2005 03:02 AM
adding numbers gmoney060 Access 1 August 15th, 2004 08:14 PM
Adding numbers kend XSLT 4 June 27th, 2003 12:33 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.