无法在 Saxon 9.7 中使用 <xsl:evaluate>
Can't use <xsl:evaluate> in Saxon 9.7
我是 运行 具有此 POM 片段的 XML Maven 插件:
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>xml-maven-plugin</artifactId>
<version>1.0.1</version>
<executions>
<execution>
<goals>
<goal>transform</goal>
</goals>
</execution>
</executions>
<configuration>
<transformationSets>
<transformationSet>
<dir>${basedir}/target/xml</dir>
<stylesheet>${basedir}/target/typesetting/fop/xslt/PhotoBook-fo.xslt</stylesheet>
</transformationSet>
</transformationSets>
</configuration>
<dependencies>
<dependency>
<groupId>net.sf.saxon</groupId>
<artifactId>Saxon-HE</artifactId>
<version>9.7.0-15</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
样式表包含一个特性,<xsl:evaluate>
,它是 XSLT 3.0 的一部分,据我所知,它在 Saxon-HE 9.7.0 中受支持。样式表正确声明了 XSLT 版本:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="3.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:xhtml="http://www.w3.org/1999/xhtml">
但是正在处理这个片段:
<xsl:for-each select="xhtml:tr[1]/xhtml:td">
<xsl:element name="table-column" namespace="http://www.w3.org/1999/XSL/Format">
<xsl:attribute name="column-width">
<xsl:evaluate select="@width"/>
</xsl:attribute>
</xsl:element>
</xsl:for-each>
我明白了
[INFO] --- xml-maven-plugin:1.0.1:transform (default) @ birds-portfolio-1 ---
Static error at xsl:evaluate on line 132 column 56 of xhtml5-fo.xslt:
XTSE0010: Unknown XSLT element: evaluate
我错过了什么?谢谢。
Saxon 9.7 HE 不支持任何 XSLT 3.0 语言功能,为此您需要 PE 或 EE (http://saxonica.com/html/documentation/xsl-elements/evaluate.html)。使用 version="3.0"
样式表在 9.7 HE 中获得的唯一增强是访问 XPath 3.0 表达式(如 let
)和函数(如 serialize
或 parse-xml
)。
至于你的代码,你确定你需要xsl:evaluate
?好像
<xsl:attribute name="column-width" select="@width"/>
可能就足够了,除非您的 width
属性包含您需要评估的 XPath 表达式。
我什至会替换
<xsl:for-each select="xhtml:tr[1]/xhtml:td">
<xsl:element name="table-column" namespace="http://www.w3.org/1999/XSL/Format">
<xsl:attribute name="column-width">
<xsl:evaluate select="@width"/>
</xsl:attribute>
</xsl:element>
</xsl:for-each>
和
<xsl:for-each select="xhtml:tr[1]/xhtml:td">
<table-column xmlns="http://www.w3.org/1999/XSL/Format" column-width="{@width}"/>
</xsl:for-each>
Martin Honnen 已经很有帮助地指出 (+1) Saxon 9.7 HE 不支持 XSLT 3.0,但我想为可能在这方面有问题的未来读者添加另一种可能性:如果 Saxon 9.7 EE 或 PE找不到合适的 许可证密钥 ,它似乎可以继续使用减少的功能,也许就像在 HE 下一样。
一方面,这种优雅的降级可能会有所帮助,但另一方面,它也会让获得许可的 EE 或 PE 用户感到困惑,他们在未能正确放置许可证时不希望出现这种行为新机器设置上的密钥文件。
我是 运行 具有此 POM 片段的 XML Maven 插件:
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>xml-maven-plugin</artifactId>
<version>1.0.1</version>
<executions>
<execution>
<goals>
<goal>transform</goal>
</goals>
</execution>
</executions>
<configuration>
<transformationSets>
<transformationSet>
<dir>${basedir}/target/xml</dir>
<stylesheet>${basedir}/target/typesetting/fop/xslt/PhotoBook-fo.xslt</stylesheet>
</transformationSet>
</transformationSets>
</configuration>
<dependencies>
<dependency>
<groupId>net.sf.saxon</groupId>
<artifactId>Saxon-HE</artifactId>
<version>9.7.0-15</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
样式表包含一个特性,<xsl:evaluate>
,它是 XSLT 3.0 的一部分,据我所知,它在 Saxon-HE 9.7.0 中受支持。样式表正确声明了 XSLT 版本:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="3.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:xhtml="http://www.w3.org/1999/xhtml">
但是正在处理这个片段:
<xsl:for-each select="xhtml:tr[1]/xhtml:td">
<xsl:element name="table-column" namespace="http://www.w3.org/1999/XSL/Format">
<xsl:attribute name="column-width">
<xsl:evaluate select="@width"/>
</xsl:attribute>
</xsl:element>
</xsl:for-each>
我明白了
[INFO] --- xml-maven-plugin:1.0.1:transform (default) @ birds-portfolio-1 ---
Static error at xsl:evaluate on line 132 column 56 of xhtml5-fo.xslt:
XTSE0010: Unknown XSLT element: evaluate
我错过了什么?谢谢。
Saxon 9.7 HE 不支持任何 XSLT 3.0 语言功能,为此您需要 PE 或 EE (http://saxonica.com/html/documentation/xsl-elements/evaluate.html)。使用 version="3.0"
样式表在 9.7 HE 中获得的唯一增强是访问 XPath 3.0 表达式(如 let
)和函数(如 serialize
或 parse-xml
)。
至于你的代码,你确定你需要xsl:evaluate
?好像
<xsl:attribute name="column-width" select="@width"/>
可能就足够了,除非您的 width
属性包含您需要评估的 XPath 表达式。
我什至会替换
<xsl:for-each select="xhtml:tr[1]/xhtml:td">
<xsl:element name="table-column" namespace="http://www.w3.org/1999/XSL/Format">
<xsl:attribute name="column-width">
<xsl:evaluate select="@width"/>
</xsl:attribute>
</xsl:element>
</xsl:for-each>
和
<xsl:for-each select="xhtml:tr[1]/xhtml:td">
<table-column xmlns="http://www.w3.org/1999/XSL/Format" column-width="{@width}"/>
</xsl:for-each>
Martin Honnen 已经很有帮助地指出 (+1) Saxon 9.7 HE 不支持 XSLT 3.0,但我想为可能在这方面有问题的未来读者添加另一种可能性:如果 Saxon 9.7 EE 或 PE找不到合适的 许可证密钥 ,它似乎可以继续使用减少的功能,也许就像在 HE 下一样。
一方面,这种优雅的降级可能会有所帮助,但另一方面,它也会让获得许可的 EE 或 PE 用户感到困惑,他们在未能正确放置许可证时不希望出现这种行为新机器设置上的密钥文件。