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

sum of duration as string

Subject: sum of duration as string
From: "cmarchand@xxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 9 Mar 2016 14:40:59 -0000
 sum of duration as string
Hello,

I have a comma separated string of durations :

<base
name='BASECOCOS'>PT2.206S,PT2.206S,PT0.435S,PT0.435S,PT1.022S,PT1.022S,PT1.49
0S,PT1.490S,PT12M15.963S,PT12M15.963S</base>


I want to calculate the sum of the durations who are in odd positions.

I've tried this :

<xsl:function name="local:sumDuration" as="xs:duration">
   <xsl:param name="seq" as="xs:string+"/>
   <xsl:choose>
      <xsl:when test="count($seq) ge 3">
         <xsl:variable name="dur1" as="xs:duration"
select="xs:duration($seq[1])"/>
         <xsl:value-of select="$dur1 +
local:sumDuration(subsequence($seq,3))"/>
      </xsl:when>
      <xsl:otherwise>
         <xsl:value-of select="xs:duration($seq[1])"/>
      </xsl:otherwise>
   </xsl:choose>
</xsl:function>

...

   <xsl:value-of select="local:sumDuration(tokenize(./text(),','))"/>

I get this error :

ID SystC(me:
/home/ext-cmarchand/devel/avo-optim/inneo/src/main/makeTempsTableFromLogs/xsl
t/makeTable.xsl
ScC)nario: makeTable
fichier XSL:
/home/ext-cmarchand/devel/avo-optim/inneo/src/main/makeTempsTableFromLogs/xsl
t/makeTable.xsl
Nom du moteur: Saxon-PE 9.5.1.3
GravitC): fatal
Description: XPTY0004: Only subtypes of xs:duration can be added
Emplacement de dC)but: 245:0
URL: http://www.w3.org/TR/xpath20/#ERRXPTY0004

I use /xsl:stylesheet/@version="2.0" with Saxon-PE 9.5.1.3

Any help will be much appreciated.

Christophe

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