元素xsl:mode不能直接出现在xsl:stylesheet中

时间:2018-09-07 19:51:54

标签: java saxon

在我的xslt 3.0中使用<axsl:mode on-no-match="shallow-copy"/>时出现此错误。 lib-> saxon-ee:9.7.0.4

Error at /xsl:stylesheet/xsl:mode[1] 
  XTSE0010: Element xsl:mode must not appear directly within xsl:stylesheet
Error at /xsl:stylesheet/xsl:mode[1] 
  XTSE0010: Element xsl:mode must not appear directly within xsl:stylesheet
Error at /xsl:stylesheet/xsl:mode[1] 
  XTSE0010: Unknown XSLT element: mode

当我使用最新的SaxonEE9-8-0-14时,不确定如何使用Serializer. net.sf.saxon.s9api.Serializer

// destination
            Serializer serializer = new Serializer(); // This worked with 9.7 but errors with 9.8
            serializer.setOutputWriter(writer);
            serializer.setOutputProperty(Serializer.Property.METHOD, "xml");
            serializer.setOutputProperty(Serializer.Property.OMIT_XML_DECLARATION, "yes");
            serializer.setOutputProperty(Serializer.Property.ENCODING, "UTF-8");
            transformer.setDestination(serializer);

请帮助

1 个答案:

答案 0 :(得分:0)

最新版本是Saxon 9.8。以前的9.7是在XSLT 3.0建议最终确定之前发布的,因此XSLT 3.0功能仅在明确要求时才可用(例如,通过在样式表上设置version =“ 3.0”)。

Serializer的独立构造函数在9.6和9.7中被弃用,转而使用工厂方法Processor.newSerializer(),而公共构造函数最终在9.8中被删除。这是因为除非Serializer有权访问支撑Configuration的{​​{1}},否则它将无法做任何需要考虑配置设置的事情。

相关问题