Subject: AW: [xsl] sum of duration as string From: "Dr. Patrik Stellmann patrik.stellmann@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Wed, 9 Mar 2016 15:26:02 -0000 |
Something like this should work: <xsl:value-of select="sum(for $i in tokenize(., ',')[(position() mod 2) = 1] return xs:dayTimeDuration($i))"/> Regards, Patrik ------------------------------------------------------------------ Systemarchitektur & IT-Projekte Tel: +49 40 33449-1142 Fax: +49 40 33449-1400 E-Mail: Patrik.Stellmann@xxxxxxxxx<mailto:Patrik.Stellmann@xxxxxxxxx> Von: cmarchand@xxxxxxxxxx [mailto:xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx] Gesendet: Mittwoch, 9. MC$rz 2016 15:42 An: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Betreff: [xsl] 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 XSL-List info and archive<http://www.mulberrytech.com/xsl/xsl-list> EasyUnsubscribe<-list/2718916> (by email<>) GDV Dienstleistungs-GmbH & Co. KG GlockengieCerwall 1 D-20095 Hamburg www.gdv-dl.de Sitz und Registergericht: Hamburg HRA 93 894 USt.-IdNr : DE 205183123 KomplementC$rin: GDV Beteiligungsgesellschaft mbH Sitz und Registergericht: Hamburg HRB 71 153 GeschC$ftsfC<hrer: Dr. Jens Bartenwerfer Michael Bathke Volker Sonnenburg ------------------------------------------------------------------ Diese E-Mail und alle AnhC$nge enthalten vertrauliche und/oder rechtlich geschC<tzte Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtC<mlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese E-Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe der E-Mail ist nicht gestattet. This e-mail and any attached files may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorised copying, disclosure or distribution of the material in this e-mail is strictly forbidden.
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] sum of duration as string, Martin Honnen martin | Thread | Re: [xsl] sum of duration as string, Michael Kay mike@xxx |
Re: [xsl] sum of duration as string, Martin Honnen martin | Date | Re: [xsl] sum of duration as string, Michael Kay mike@xxx |
Month |