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

Recursion Help with Summing Durations

Subject: Recursion Help with Summing Durations
From: Seth Ladd <seth@xxxxxxxxx>
Date: 29 Apr 2002 14:28:08 -0400
recursion help
Hello,

I am trying to use the EXSLT template add-duration.  I have a node-set
of durations that I'd like to sum together.  My named template is not
working, and I was hoping someone could give me some hints or tips on
where to go to make this recursion work properly.

My environment:

Java 1.3.1
Xalan2
Cocoon 2.0.2

I've tested that I'm getting the correct node-set by using count(). 
I've also hard-coded some values into add-duration to make sure it
works.

I've been scanning documentation all day, and coming up empty.  I might
be getting tripped up with the difference between node-sets and RTFs,
but that's where my XSLT gets fuzzy.  Any tips or suggestions would be
greatly appreciated!

Thanks so much,
Seth

My template:

    <xsl:template name="total-durations">
        <xsl:param name="durations"/>

        <xsl:choose>
            <xsl:when test="$durations">
                <xsl:variable name="first" select="$durations[1]"/>
                <xsl:variable name="rest">
                    <xsl:call-template name="total-durations">
                        <xsl:with-param name="durations"
                                select="$durations[position()!=1]"/>
                    </xsl:call-template>
                </xsl:variable>

                <xsl:call-template name="date:add-duration">
                    <xsl:with-param name="duration1" select="$first"/>
                    <xsl:with-param name="duration2" select="$rest"/>
                </xsl:call-template>

            </xsl:when>
            <xsl:otherwise>P0M</xsl:otherwise>
        </xsl:choose>

    </xsl:template>

I call it with this (while I am in the timecard element):

<xsl:call-template name="total-durations">
    <xsl:with-param name="durations" select="shift/duration"/>
</xsl:call-template>

And my original document looks like:

<timecard>
    <shift>
       <duration>P13M</duration>
    </shift>
    <shift>
       <duration>P43M</duration>
    </shift>
</timecard>



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

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-2011 All Rights Reserved.