Saxon.Api.DynamicError,“找不到名为 {exslt.org/common}node-set() 的匹配 1 参数函数"; [英] Saxon.Api.DynamicError, "Cannot find a matching 1-argument function named {exslt.org/common}node-set()"
问题描述
嗨专家/迈克尔凯
我得到了Saxon.Api.DynamicError - 找不到名为 {exslt.org/common}node-set() 的匹配 1-argument 函数.没有本地名称为 node-set 的 Saxon 扩展函数",使用saxon9he - v9.4.0.2.我的 XSLT 文件正在调用EXSLT".请帮我解决这个问题.
I got "Saxon.Api.DynamicError - Cannot find a matching 1-argument function named {exslt.org/common}node-set(). There is no Saxon extension function with the local name node-set" by using saxon9he - v9.4.0.2. My XSLT file is calling "EXSLT". please help me to resolve the issue.
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;
}
提前致谢
萨兰
推荐答案
作为一般规则,Saxon-HE 不提供任何扩展功能;您必须升级到 Saxon-PE.
As a general rule, Saxon-HE does not provide any extension functions; you have to upgrade to Saxon-PE.
然而,exslt:node-set() 扩展在 XSLT 1.0 代码中使用如此广泛,以至于我们对这个代码有所缓和,它在 Saxon-HE 9.6 中可用,并且(我认为,需要检查)也在 9.5 中可用.
However, the exslt:node-set() extension is so widely used in XSLT 1.0 code that we relented on this one, it's available in Saxon-HE 9.6 and (I think, need to check) also in 9.5.
如果您需要,还有另一种解决方法:自己实施.只需将自定义模块添加到包含代码的样式表(一个导入以前的主模块的主模块)
There's another workaround if you need it: implement it yourself. Just add a customization module to your stylesheet (a main module that imports what was previously the main module) which contains the code
<xsl:function name="exslt:node-set" as="node()">
<xsl:param name="n" as="node()"/>
<xsl:sequence select="$n"/>
</xsl:function>
这篇关于Saxon.Api.DynamicError,“找不到名为 {exslt.org/common}node-set() 的匹配 1 参数函数";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!