Dev*_*esk 2 java xslt saxon spring-boot
我是 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>
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
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
Run Code Online (Sandbox Code Playgroud)
我在 pom.xml 中使用了以下依赖项
<dependency>
<groupId>net.sf.saxon</groupId>
<artifactId>Saxon-HE</artifactId>
<version>9.9.0-2</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
嗯,消息的意思就是它所说的。您正在尝试使用称为“自反扩展函数”的功能。此功能尝试将 XPath 函数调用与类路径上可用的 Java 类和方法(在本例中java.text.SimpleDateFormat
)相匹配。Saxon-HE 产品不提供此功能。您可以通过多种方式解决该问题:
升级到 Saxon-PE(需要花费少量金钱)
format-date()
使用标准 XPath函数替换对此 Java 方法的使用
使用 Saxon-HE 中可用的 Java 调用机制,即“集成扩展函数”(请参阅 Saxon 文档中的“扩展性”)。
归档时间: |
|
查看次数: |
3161 次 |
最近记录: |