Thanks Michael. I'll try accessing the NodeInfo to pass to the XPathExpression. I'm using that API (The net.sf.saxon.xpath.XPathEvaluator) because I'm trying implement custom bindings for java extension functions. I can see how to do that in the non-s9API, but can't see how to do this in the s9API. Am I missing something (I'm sure I am).

From: Michael Kay []
Sent: Friday, January 29, 2010 2:28 PM
To: 'Mailing list for the SAXON XSLT and XQuery processor'
Subject: Re: [saxon] (no subject)

I'm not sure if your XPathEvaluator is a net.sf.saxon.xpath.XPathEvaluator or a net.sf.saxon.sxpath.XPathEvaluator; but either way, you can't mix s9api and non-s9api interfaces in this way. Since you've built an XdmNode using s9api, please use the s9api XPath API to access it.
Alternatively, you can get the NodeInfo underlying the s9api XdmNode, and pass this to the XPathExpression.evaluate() method.


Michael Kay

From: Steve Carton []
Sent: 29 January 2010 15:17
Subject: [saxon] (no subject)

Hi guys,
I'm trying to write a java program that will parse a file with an XML document and then run an XPath against that XML document. I'm using Dom4J as my parser. I think I'm parsing the document okay, but when I run the XPath, I get this exception:
javax.xml.xpath.XPathExpressionException: Cannot locate an object model implementation for nodes of class net.sf.saxon.s9api.XdmNode
Here is an excerpt from the code:
    SAXReader parser = new SAXReader();
    parser.setEntityResolver(new NoOpEntityResolver());
    Document doc =;
    Configuration configuration = processor.getUnderlyingConfiguration();
    configuration.registerExternalObjectModel(new DOM4JObjectModel());
    net.sf.saxon.functions.FunctionLibrary lib = MyFunctionLibrary.getInstance(configuration);
    configuration.setExtensionBinder("java", lib);
    XPathEvaluator xpathEvaluator = new XPathEvaluator(configuration);
    xpathEvaluator.getStaticContext().setNamespaceContext(new MyNamespaceContext());
    XPathExpression xpathExpression = xpathEvaluator.compile(script);
    String result = xpathExpression.evaluate(processor.newDocumentBuilder().wrap(xml));
Part of the requirement here is to automagically recognize certain prefix bindings and map them to java extension functions. Not sure if that stuff is getting in the way or not.
Any advice or thoughts?
Steve Carton