You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by Asiri Liyana Arachchi <as...@gmail.com> on 2013/09/23 14:56:13 UTC

(Unknown)

Hi all,

What is the difference between the DOM document instances created using

1) Xerces

InputStream is = new FileInputStream("resources/test.xml");DOMLoader
loader = new XercesLoader();
Document doc1 = loader.load(is);

2) Axiom

OMElement documentElement = new
StAXOMBuilder("resources/test.xml").getDocumentElement();OMFactory
doomFactory = DOOMAbstractFactory.getOMFactory();  StAXOMBuilder
doomBuilder = new
StAXOMBuilder(doomFactory,documentElement.getXMLStreamReader());
Document doc2 = (org.w3c.dom.Document) doomBuilder.getDocument();

3) Javax

DocumentBuilderFactory factory =
DocumentBuilderFactory.newInstance();DocumentBuilder builder =
factory.newDocumentBuilder();
Document doc3 = builder.parse(new File("resources/test.xml"));

I wanted to pass these DOM instances to an XPath processor (Psychopath).
But it worked only when the DOM instance created using xerces are passed. I
want doc2 instance to be passed successfully.

I would appreciate a lot if somebody can point me out what's I'm doing
wrong here.

Re:

Posted by Mukul Gandhi <mu...@apache.org>.
Hi Asiri,
   I think, currently the Psychopath XPath engine is very much bound to
Xerces's DOM implementation (at least very much for the schema aware XPath
2.0 version). I can quickly suggest following ways to solve these problems,

1) If you've say an Axiom created Document object, you may serialize it to
file and then build a Document object from such a file as you wrote in
point 1) of your mail. This is a poor design approach in sense, that we're
processing twice for same function (i.e we've to do Document -> serialize
-> Document). If you're input documents are not very large, this approach
may be feasible.

2) Provide a functionality within Axiom, to utilize Xerces compliant
Document objects. This would allow such Document objects to be usable
with Psychopath
XPath engine.

I think, asking questions to use Psychopath XPath engine in another
environment (where Xerces is not directly involved, or where Xerces XSD 1.1
is not involved) may not be in scope to discuss on this list. Those
discussions need to occur on Eclipse WTP forum, or may be a subject of
personal research.

On Mon, Sep 23, 2013 at 6:26 PM, Asiri Liyana Arachchi
<as...@gmail.com>wrote:

> Hi all,
>
> What is the difference between the DOM document instances created using
>
> 1) Xerces
>
> InputStream is = new FileInputStream("resources/test.xml");DOMLoader loader = new XercesLoader();
> Document doc1 = loader.load(is);
>
> 2) Axiom
>
> OMElement documentElement = new StAXOMBuilder("resources/test.xml").getDocumentElement();OMFactory doomFactory = DOOMAbstractFactory.getOMFactory();  StAXOMBuilder doomBuilder = new StAXOMBuilder(doomFactory,documentElement.getXMLStreamReader());
> Document doc2 = (org.w3c.dom.Document) doomBuilder.getDocument();
>
> 3) Javax
>
> DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();DocumentBuilder builder = factory.newDocumentBuilder();
> Document doc3 = builder.parse(new File("resources/test.xml"));
>
> I wanted to pass these DOM instances to an XPath processor (Psychopath).
> But it worked only when the DOM instance created using xerces are passed. I
> want doc2 instance to be passed successfully.
>
> I would appreciate a lot if somebody can point me out what's I'm doing
> wrong here.
>



>
> --
> Regards,
> Mukul Gandhi
>