2017-03-04 30 views
1

我运行XML Maven插件这个POM片段的 无法使用:在萨克森9.7

<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 

我缺少什么?谢谢。

回答

2

Saxon 9.7 HE不支持任何XSLT 3.0语言功能,您需要PE或EE(http://saxonica.com/html/documentation/xsl-elements/evaluate.html)。在9.7 HE和version="3.0"样式表中唯一的增强功能是访问XPath 3.0表达式(如let)和函数(如serializeparse-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> 
+0

谢谢,我迷失在各种版本。是的,我确实需要评估,因为我可能会使用一些涉及页面测量的变量来传递表达式(这些内容与排版图书的FOP相关)。我还需要对XSLT代码进行大量的重构,但目前我仍然需要评估,在改进代码的其余部分之前,我必须先处理它。 –

1

马丁Honnen已经有益指出的(+1),其撒克逊9.7他不支持XSLT 3.0,但我想添加其他未来读者可能会遇到这方面的问题:如果Saxon 9.7 EE或PE无法找到合适的许可证密钥,它似乎会继续与减少的功能一起工作,可能会像在HE中一样。

一方面,这种优雅的退化可能会有所帮助,但另一方面,当未能正确放置许可证密钥时,不希望出现此行为的许可EE或PE用户也会感到困惑文件在新的机器设置上。