Project

Profile

Help

Sum a duration in a for-each-group

Added by Anonymous over 14 years ago

Legacy ID: #7644836 Legacy Poster: James Crann (hyperjc)

I am not sure if the following is a bug or my misunderstanding.. I am trying to use the sum method to sum durations within a for-each-group but i get the following error "Cannot convert string "PT2M30S" to a double" I would have thought Sum would recognise the datatye Is this a bug? Can anybody suggest a work around? <xsl:for-each-group select="CallTrans" group-by="../DetailHeader/@ServiceHeader"> <xsl:value-of select="NumberDialed"/>: <xsl:value-of select="sum(current-group()/MinSec)"/> </xsl:for-each-group> I also tried the following <xsl:value-of select="sum(seconds-from-duration(current-group()/MinSec))"/> but seconds-from-duration() only works in a single node not a nodeset


Replies (1)

RE: Sum a duration in a for-each-group - Added by Anonymous over 14 years ago

Legacy ID: #7645578 Legacy Poster: Michael Kay (mhkay)

This would work as written if you were running in schema-aware mode with MinSec typed as a duration. But if MinSec is untyped, you need to convert it explicitly to a duration: sum(current-group()/MinSec/xs:dayTimeDuration(.)) Note that XSLT coding questions which are not specifically related to Saxon are best asked on the xsl-list at mulberrytech.com

    (1-1/1)

    Please register to reply