Saxon.Api.DynamicError, "Cannot find a matching 1-argument function named {exslt.org/common}node-set



嗨,专家/Michael Kay

我使用saxon9he-v9.4.0.2得到了"Saxon.Api.DynamicError-找不到名为{exslt.org/common}node-set()的匹配单参数函数。没有本地名称节点集的Saxon扩展函数"。我的XSLT文件正在调用"EXSLT"。请帮我解决这个问题。

public static StringWriter XSLT2(string sourceFile, string XSLT)
{
    Processor processor = new Processor();
    var setting = new XmlReaderSettings { DtdProcessing = DtdProcessing.Parse };
    XmlReader reader2 = XmlReader.Create(sourceFile, setting);
    XdmNode input = processor.NewDocumentBuilder().Build(reader2);
    //XPathCompiler compiler = processor.NewXPathCompiler();
    //compiler.DeclareNamespace("exsl", "http://exslt.org/common");
    // Create a transformer for the stylesheet.
    //Stream XsltTransformer transformer = processor.NewXsltCompiler().Compile(XSLT).Load();
    XsltTransformer transformer = processor.NewXsltCompiler().Compile(new Uri(XSLT + @"mekontopic.xsl")).Load();
    transformer.InputXmlResolver = new XmlUrlResolver();
    // Set the root node of the source document to be the initial context node
    transformer.InitialContextNode = input;
    // Create a serializer
    StringWriter s = new StringWriter();
    Serializer serializer = new Serializer();//serializer.SetOutputWriter(Console.Out);
    serializer.SetOutputWriter(s);
    // Transform the source XML to System.out.
    transformer.Run(serializer);
    return s;
}

提前感谢

SARAN

一般来说,Saxon HE不提供任何扩展功能;你必须升级到Saxon PE。

然而,exslt:node-set()扩展在XSLT1.0代码中使用得如此广泛,以至于我们对这一扩展有所让步,它在Saxon HE 9.6中可用,(我认为,需要检查)也在9.5中可用。

如果您需要,还有另一种变通方法:自己实现。只需在样式表中添加一个自定义模块(一个导入以前主模块的主模块),其中包含代码

<xsl:function name="exslt:node-set" as="node()">
  <xsl:param name="n" as="node()"/>
  <xsl:sequence select="$n"/>
</xsl:function>

根据http://www.saxonica.com/feature-matrix.html,HE版本不支持EXSLT功能。您需要升级到更高版本,或者(最好)重写样式表以利用XSLT2.0,它不需要EXSLT扩展函数。

或者,您可以降级到XSLT1.0处理器,如Saxon6.5或Xalan。

相关内容

最新更新