我是xslt和springboot的新手。我已经使用Spring Boot开发了微服务。我有如下的xslt文件。
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:java="http://xml.apache.org/xslt/java">
<xsl:template match="//ProcessInput">
<xsl:variable name="dateTimeFmt" select="java:format(java:java.text.SimpleDateFormat.new ('yyyy-MM-ddHH:mm:ss'), java:java.util.Date.new())"/>
<xsl:variable name="date" select="concat(substring($dateTimeFmt,1,10),'T',substring($dateTimeFmt,11))"/>
<RMessage>
<header>
<RMessageId>
<xsl:value-of select="IMD/@id"/>
</RMessageId>
<RMessageSchemaVersion/>
<RSource>ABC</RSource>
<RDestination>XYZ</RDestination>
<RDateTimeSent>
<xsl:value-of select="$date"/>
</RDateTimeSent>
</header>
<body>
<xsl:copy-of select="IMD/node()"/>
</body>
</RMessage>
</xsl:template>
</xsl:stylesheet>
我遇到了以下错误:
Error at char 98 in xsl:variable/@select on line 4 column 145
XTDE1425: Cannot find a 2-argument function named
Q{http://xml.apache.org/xslt/java}format(). Reflexive calls to Java methods are not
available under Saxon-HE
in built-in template rule for /ProcessInput in the unnamed mode
我在pom.xml中使用了以下依赖项
<dependency>
<groupId>net.sf.saxon</groupId>
<artifactId>Saxon-HE</artifactId>
<version>9.9.0-2</version>
</dependency>
答案 0 :(得分:0)
好吧,该消息表示它的意思。您正在尝试使用一种称为“自反扩展功能”的功能。此功能试图将XPath函数调用与类路径(在本例中为java.text.SimpleDateFormat
)上可用的Java类和方法进行匹配。该功能在Saxon-HE产品中不可用。您可以通过多种方式解决该问题:
升级到Saxon-PE(花费少量资金)
使用标准XPath format-date()
函数替换此Java方法的使用
使用Saxon-HE中可用的调出Java的机制,即“集成扩展功能”(请参见Saxon文档中的“ Extensibility”下)。