的ISO 8601的格式和更新值我有一个XML象下面这样:转换日期为节点XSLT
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<properties>
<entry key="date">11-15-2017 22:45:59</entry>
</properties>
我要更改日期格式为ISO 8601,并使用XSLT更新日期变量的值。 输出XML应该是这样的
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<properties>
<entry key="date">11-15-2017T22:45:59Z</entry>
</properties>
我已经定义与转换日期值的变量。我正在使用这个xslt,但没有得到所需的输出。
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:variable name="dateparam" select="properties/entry[@key='date']/@value"></xsl:variable>
<xsl:template match="entry[@key='date']">
<xsl:copy>
<xsl:apply-templates select="@*"/>
<xsl:value-of select="concat(translate(normalize-space($dateparam), ' ', 'T'), 'Z')"/>
</xsl:copy>
</xsl:template>
有人可以帮助我,因为我是XSLT的新手。
'“属性/进入[@名称= '日期']/@ value =“'=>'”properties/entry [@key ='date']/@ value“',和''=>'',应该解析y我们的问题。 –
AntonH
我看不到' xsl:variable>'做了想要的转换,它merlely选择一个输入属性节点。由于符号' {$ dateparam} '只会在XSLT 3.0处理器中使用XSLT 2.0处理器在XSLT'version =“3.0”'和expand-text =“yes”'中输出变量,您可以使用' '。 –
我在这里使用变量来转换格式 我没有得到dataparam的价值。 –