问题
Hi Experts/Michael Kay
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;
}
Thanks in advance
SARAN
回答1:
As a general rule, Saxon-HE does not provide any extension functions; you have to upgrade to Saxon-PE.
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>
回答2:
According to http://www.saxonica.com/feature-matrix.html, EXSLT functions are not supported by the HE version. You need to either upgrade to a higher edition, or (preferably) rewrite your stylesheet to take advantage of XSLT 2.0, which does not require the EXSLT extension functions.
Or perhaps you can downgrade to a XSLT 1.0 processor such as Saxon 6.5 or Xalan.
来源:https://stackoverflow.com/questions/26622567/saxon-api-dynamicerror-cannot-find-a-matching-1-argument-function-named-exslt