Reputation: 337
In a mule flow, I want to convert the time duration in format "hh:mm" in a xml file to seconds using XSLT.
For conversion I used the following,
<xsl:template match="EventDuration">
<duration>
<xsl:value-of select="60*substring-after(text(), ':') + 3600*substring-before(text(), ':')" />
</duration>
</xsl:template>
But It gives the following error....
XPTY0004: Arithmetic operator is not defined for arguments of types (xs:integer, xs:string)
What is the problem of this approach?
Upvotes: 2
Views: 3017
Reputation: 163262
You seem to be using XSLT 2.0, and in 2.0 you need to convert strings to numbers explicitly before doing arithmetic.
Your other option is to use date/time/duration arithmetic:
(xs:time(concat(text(), ":00") - xs:time("00:00:00")) div xs:dayTimeDuration("PT1S")
Upvotes: 1