Project

Profile

Help

Want default JDK DOM implemenation

Added by Anonymous almost 18 years ago

Legacy ID: #3820596 Legacy Poster: tom_vogel (tvogel74)

Hi, we are using Saxon 8.7.3 for an XPath application with JDK 1.5 (like in XPathExample.java) which works fine. Nice and fast! But: After adding saxon8.jar and saxon8-xpath.jar to the classpath the lines: mo_XPath = XPathFactory.newInstance().newXPath(); ... mo_XPath.evaluate(...); will break with the following exception: javax.xml.xpath.XPathExpressionException: Cannot locate an object model implementation for nodes of class org.apache.xerces.dom.DeferredElementImpl at net.sf.saxon.xpath.XPathExpressionImpl.evaluate(XPathExpressionImpl.java:226) at net.sf.saxon.xpath.XPathEvaluator.evaluate(XPathEvaluator.java:336) at com.silverstroke.tyrux.util.XmlParser.A(XmlParser.java:154) at com.silverstroke.tyrux.util.XmlParser.A(XmlParser.java:178) at com.silverstroke.tyrux.flow.designerback.C.C(ConfigFile.java:19) at com.silverstroke.tyrux.flow.designerback.DesignerBack.mgetBuildingBlocks(DesignerBack.java:307) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at sun.rmi.server.UnicastServerRef.dispatch(Unknown Source) at sun.rmi.transport.Transport$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at sun.rmi.transport.Transport.serviceCall(Unknown Source) at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source) at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown Source) at java.lang.Thread.run(Unknown Source) It only works if we add saxon8-dom.jar as well. Shouldn't I get something completely Saxon-independent from the first line "mo_XPath = XPathFactory.newInstance().newXPath();"??? I would expect to retrieve the default implemetation from the JDK here and I can't see why saxon8-dom.jar should be necessary at all -- I am fine with the default DOM-parser anyway. Can somebody help? Thanks.


Replies (3)

Please register to reply

RE: Want default JDK DOM implemenation - Added by Anonymous almost 18 years ago

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

The saxon8-dom.jar is needed on your classpath if you want to use Saxon to access a DOM input. It doesn't include a DOM implementation, just the classes that map the DOM to Saxon's NodeInfo interface.

RE: Want default JDK DOM implemenation - Added by Anonymous almost 18 years ago

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

To add to this response: XPathFactory.newInstance().newXPath(); is asking for an implementation of XPath that works with the DOM (because that's the default tree model). I'm assuming you want the Saxon implementation of XPath, and this will load the Saxon implementation if saxon8-xpath.jar is on the classpath. This should work with any implementation of the DOM. If you want a different XPath engine, I'm not sure why you're asking here.

RE: Want default JDK DOM implemenation - Added by Anonymous almost 18 years ago

Legacy ID: #3821607 Legacy Poster: tom_vogel (tvogel74)

Thanks for your answer. I'll try to clarify my problem further: We are using Saxon XPath in one place of the application and the implementation from the JDK 1.5 in another. Saxon came as an addon and we discovered that it broke some of the old code as described. I assumed to get a Saxon Xpath only if I specify "NamespaceConstant.OBJECT_MODEL_SAXON". I'd like a default Xpath as well that works with the default DOM implementation from the JDK. But as can be seen from the stacktrace once Saxon is in the classpath it needs the saxon implementation of DOM as well. I do not want to be dependent on saxon8-dom.jar. Is that possible? Cheers

    (1-3/3)

    Please register to reply