Reputation: 265
I'm using xpath 2.0.
I want to add 30 minutes to the variable $orario
.
<tempi id="ID_1">
<orario_part>09:20:00</orario_part>
...
</tempi>
This is my code, but it doesn't work.
<xsl:template match="tempi">
<xsl:variable name="orario" select="./orario_part"/>
<xsl:variable name="totale" select="xs:time($orario)+xs:time('00:30:00')"/>
<time>
<xsl:value-of select="$totale"/>
</time>
</xsl:template>
The following is the desired result:
<time>09:50:00</time>
How can I do this?
Upvotes: 4
Views: 5453
Reputation: 1825
Try this:
<?xml version="1.0" encoding="UTF-8"?>
<tempi id="ID_1">
<orario_part>09:20:00</orario_part>
</tempi>
and
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
version="2.0" exclude-result-prefixes="#all">
<xsl:template match="tempi">
<xsl:variable name="orario" select="./orario_part" />
<xsl:variable name="totale" select="xs:time($orario)"/>
<time>
<xsl:value-of select="$totale + xs:dayTimeDuration('P0DT0H30M')"/>
</time>
</xsl:template>
</xsl:stylesheet>
gives
<time>09:50:00</time>
Upvotes: 4