Project

Profile

Help

.NET Extension Function in XPathSelector

Added by Anonymous almost 18 years ago

Legacy ID: #4165721 Legacy Poster: mjp (mperestrello)

Is it possible to call .NET extension functions from an XPathSelector. I have followed the examples, inlcuding the issue of the clitype: prefix, but the message I received is always: Cannot find a matching 2-argument function named {com.mm.XChain.transform.XsltExtensions}GetContextProperty() The relevant xml is: <xsl:value-of select="xchain:GetContextProperty('http://xchain.test','ContextTest')&quot;/> I add the namespace to the compiler: DeclareNamespace("xchain", "clitype:com.mm.XChain.transform.XSLTExtensions"); giving it the name of my class. I get an error on the compile line (as above). XPathExecutable xpe = cachedSaxonXPathCompiler.Compile(expression); XPathSelector xps = xpe.Load(); xps.ContextItem = cacheGetXmlDocumentAsXDMNode(xdoc); XdmAtomicValue val = (XdmAtomicValue) xps.EvaluateSingle(); result = (bool)val.Value; I also tried to do this with an XSL and the same thing occurs. In my software, the saxon processor is called from within an assembly. I noticed that the documentation states that Saxon looks inside the running assembly or externally. What am I doing wrong ?


Replies (3)

Please register to reply

RE: .NET Extension Function in XPathSelector - Added by Anonymous almost 18 years ago

Legacy ID: #4165727 Legacy Poster: mjp (mperestrello)

Forgot to say that I am calling a static function in the same .NET assembly which runs the Saxon Processor.

RE: .NET Extension Function in XPathSelector - Added by Anonymous almost 18 years ago

Legacy ID: #4165776 Legacy Poster: Michael Kay (mhkay)

Please try adding "?asm=<assembly-name>" to the namespace URI of the function name. This seems to be more reliable. Also please try using the -TJ option on the command line to trace the attempt to bind an extension function

RE: .NET Extension Function in XPathSelector - Added by Anonymous almost 18 years ago

Legacy ID: #4166205 Legacy Poster: mjp (mperestrello)

That did the trick. For the sake of completeness the code is: NewXPathCompiler --> DeclareNamespace("xchain","clitype:com.mm.XChain.transform.XSLTExtensions?asm=com.mm.XChain.beta1"); XPathExecutable xpe = cachedSaxonXPathCompiler.Compile(expression); XPathSelector xps = xpe.Load(); xps.ContextItem = cachedXdmNode(xdoc); XdmAtomicValue val = (XdmAtomicValue)xps.EvaluateSingle(); result = (bool)val.Value; Thanks for the fast reply.

    (1-3/3)

    Please register to reply