替换XML值我有以下XML文档:XSLT:以当前日期和时间
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/>
<soapenv:Body>
<Elaborations>
<Elaboration>
<DateBegin>2014-01-01T02:00:00.000+01:00</DateBegin>
<DateEnd>2014-01-01T02:00:00.000+01:00</DateEnd>
<Result>12594</Result>
</Elaboration>
<Elaboration>
<DateBegin>2014-01-01T02:00:00.000+01:00</DateBegin>
<DateEnd>2014-01-01T02:00:00.000+01:00</DateEnd>
<Result>12593</Result>
</Elaboration>
<Elaboration>
<DateBegin>2014-01-01T02:00:00.000+01:00</DateBegin>
<DateEnd>2014-01-01T02:00:00.000+01:00</DateEnd>
<Result>12595</Result>
</Elaboration>
<Elaboration>
<DateBegin>2014-01-01T02:00:00.000+01:00</DateBegin>
<DateEnd>2014-01-01T02:00:00.000+01:00</DateEnd>
<Result>29598</Result>
</Elaboration>
<Elaboration>
<DateBegin>2014-01-01T02:00:00.000+01:00</DateBegin>
<DateEnd>2014-01-01T02:00:00.000+01:00</DateEnd>
<Result>37583</Result>
</Elaboration>
</Elaborations>
</soapenv:Body>
</soapenv:Envelope>
我要替换的元素DateBegin和DateEnd与当前日期和时间的值,用XSLT。 我写了下面的转换:
<?xml version="1.0"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:variable name="dateNow" select="current-dateTime()"/>
<xsl:template match="DateBegin/text()">
<xsl:value-of select="$dateNow"/>
</xsl:template>
<xsl:template match="DateEnd/text()">
<xsl:value-of select="$dateNow"/>
</xsl:template>
</xsl:stylesheet>
但我的XSLT文件得到一个解析错误。 问题在哪里?
请发布您正在获取的**确切**错误。 – 2014-10-02 16:00:30
你的代码似乎没有问题,它运行良好[这里](http://xsltransform.net/gWmuiJ1)。正如Michael建议的那样,告诉我们错误信息是什么。另外,您使用哪种XSLT处理器? – 2014-10-02 21:52:50
我在骆驼路线中使用转换。我得到以下错误:'javax.xml.transform.TransformerConfigurationException:无法编译样式表''在检查表达式类型'funcall(current-dateTime,[])'时引起错误:' – Andrea 2014-10-03 07:23:17