cmarchand(_at_)oxiane(_dot_)com wrote:
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.490S,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 Système:
/home/ext-cmarchand/devel/avo-optim/inneo/src/main/makeTempsTableFromLogs/xslt/makeTable.xsl
Scénario: makeTable
fichier XSL:
/home/ext-cmarchand/devel/avo-optim/inneo/src/main/makeTempsTableFromLogs/xslt/makeTable.xsl
Nom du moteur: Saxon-PE 9.5.1.3
Gravité: fatal
Description: XPTY0004: Only subtypes of xs:duration can be added
Try to use
xs:dayTimeDuration($seq[1])
instead of xs:duration.
And consider to use `xsl:sequence` instead of `xsl:value-of`.
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--