This discussion is archived
3 Replies Latest reply: Jul 9, 2012 4:25 PM by dvohra21 RSS

Parsing with StAX

761006 Newbie
Currently Being Moderated
I am trying to write some Java code to parse very large XML documents and would like to use a DOM parser. However the size of the XML document precludes this so I thought I'd use StAX and the transform sub-trees of the source XML into a DOMResult instance. I have written the basic code but get the following error:


XML-22004: (Fatal Error) Error while parsing input XML document (null).

The error occurs when I try to do the transformation and the relevant parts of the code are is as follows:

StAXSource source = new StAXSource(xsr) // xsr is my XMLStreamReader instance.
DOMResult dom = new DOMResult();
transformer.transform(source, dom);

I developed the code within JDeveloper as the code is intended to form part of an ADF application. However, I've run EXACTLY the same code using Eclipse as my IDE and it works perfectly. I've also tried to run it using the XML JDK and get the same error as with JDeveloper. The question is is this type of transformation not supported with the Oracle StaX/Transformer implementations and if it is, what do I need to add to my code to get the transformation to work?

Alternatively, does anyone know what implementation Oracle uses for the TransformerFactory class?

Many thanks,

George Nelson

Edited by: George Nelson on May 24, 2012 7:44 PM
  • 1. Re: Parsing with StAX
    dvohra21 Oracle ACE
    Currently Being Moderated
    XSLT may be used in JDeveloper. Refer
    http://my.safaribooksonline.com/book/databases/oracle/9781847196668/transforming-xml-with-xslt/ch05lvl1sec02#X2ludGVybmFsX0ZsYXNoUmVhZGVyP3htbGlkPTk3ODE4NDcxOTY2NjgvY2gwNQ==
  • 2. Re: Parsing with StAX
    761006 Newbie
    Currently Being Moderated
    Thanks for the link and a book I've added to my favourites on Safari. I need to find out more about SAXSources (I was using a StAXSource as the source object for the transform). However, using the JXSAXTransformerFactory implementation, I still get the same error: XML-22004: (Fatal Error) Error while parsing input XML document (null).

    I can find very little literature of any kind on doing a StaX->DOM transformation although I would have thought this would have been common for anybody parsing very large XML documents - DOM would be the preferred parsing method but the document size precludes it. The StAX->DOM transformation resolves the problem by converting sub-trees of the source document to DOM.

    George Nelson
  • 3. Re: Parsing with StAX
    dvohra21 Oracle ACE
    Currently Being Moderated
    Split the large XML document to small documents to parse with StAX.
    https://www.tibcommunity.com/docs/DOC-2207

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points