users@jaxb.java.net

Processing Large XML Files

From: Marc Dumontier <dumontier_at_mshri.on.ca>
Date: Fri, 31 Oct 2003 23:49:09 -0500

Hi,

I'm trying to find the best solution to progressing a very large XML file.
This XML file is filled with independent elements which i want to unmarshall
one at a time because of memory constraints (the file is about 60GB).

<BIND-Interaction-Set>
  <BIND-Interaction>
    ...
   </BIND-Interaction>
    ....
    ....
</BIND-Interaction-Set>


I've tried to build individual DOM documents from a SAX stream...and that
works ok (using transformations), but then JAXB won't unmarshall it. It
seems that it gets a nullpointerexception in the unmarshaller because the
localName in startElement() is null.

here's some sample code
any better approaches would be appreciated

from my content handler's endElement()

               if(localName.equals("BIND-Interaction")) {
                        System.out.println("end of interaction");
                        consumer.endDocument();
                        Document doc = getDocument();
                        JAXBContext jc = JAXBContextManager.getContext();
                                Unmarshaller u = jc.createUnmarshaller();
                                u.setValidating( false );
                                BINDInteraction o =
(BINDInteraction)u.unmarshal( doc );

                 }



from the contentHandler's startElement

                               try{

                                        TransformerHandler handler =
factory.newTransformerHandler();
                                        setConsumer(handler);
                                        result = new DOMResult();
                                        handler.setResult(result);
                                        consumer.startDocument();


thanks,
Marc

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
For additional commands, e-mail: users-help_at_jaxb.dev.java.net