[jdom-interest] DOM-SAX?

Brian Wolf brianw at knowledgextensions.com
Mon Dec 31 02:02:39 PST 2001


Hi All, 

I am writing an app that merges smaller XML docs into a larger one based on some rules.
I am trying toget a handle om the "seamlessness" of SAX versus DOM access. Below, I 
start with the first XML doc and then grow it by adding to stuff from the  following XML files.


So my current program I pull the small files into "doc" documentand  I itereate down the "doc"  
dom tree of the small files until I find a specific node and use XPath to find the corresponding 
node in the largerer doc "largedoc" . So "largedoc" is filling up memory until it crashes. What do I need
to access "largedoc" seamlessly, but using  SAX to I don't fill up memory?

Cheers, Brian 



IE beginning.....
public static void main(String[] args) {

try { 

SAXBuilder builder3 = new SAXBuilder();

Document largedoc = builder3.build( args[0] );

Vector addrTextVect = new Vector();

elementProc eP = new elementProc(largedoc, addrTextVect);


Element rt = largedoc.getRootElement(); 


eP.processFile(rt,args[0]); 



Now here is where I add to "largedoc" stuff from "doc"

public void processAddresses(Element e)

{

List inchildren = new ArrayList();

inchildren = e.getChildren();

try

{

String xpath_str = "/file/addresses" ;

XPath xpath = new XPath( xpath_str );

Element eAddr = (Element) xpath.selectSingleNode( largedoc );



for(int i=0 ;i < inchildren.size() ;i++)

{



-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://jdom.org/pipermail/jdom-interest/attachments/20011231/38c17904/attachment.htm


More information about the jdom-interest mailing list