4

xpath2.0を使用しています。

変数に30分を追加したいと思います$orario

  <tempi id="ID_1">
    <orario_part>09:20:00</orario_part>
    ...
  </tempi>

これは私のコードですが、機能しません。

<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>

望ましい結果は次のとおりです。

<time>09:50:00</time>

これどうやってするの?

4

1 に答える 1

4

これを試して:

<?xml version="1.0" encoding="UTF-8"?>
<tempi id="ID_1">
    <orario_part>09:20:00</orario_part>
</tempi>

<?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>

与える

<time>09:50:00</time>
于 2013-02-15T01:34:14.363 に答える