File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes XML and Related Technologies and the fly likes Memory Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Memory Problem" Watch "Memory Problem" New topic
Author

Memory Problem

Luciano A. Pozzo
Ranch Hand

Joined: Jun 20, 2005
Posts: 112
Hi,

I am with a memory problem because we are loading a big xml for a simple update. Actually, I just want to put a new tag or just change some value. I do not want to load all the xml for it.

So, how can I solve this problem? I tried SAX, but... SAX just read! Any idea?

The current method, with DOM:




Thank's
[ July 20, 2007: Message edited by: Luciano A. Pozzo ]
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18886
    
    8

Chapter 8 (SAX Filters) of this online book should help you out.
Luciano A. Pozzo
Ranch Hand

Joined: Jun 20, 2005
Posts: 112
Hummm... ok, understood.
Just for explain what I tested:

The main ideia is to change the data manipulated by the handler before the handler execute. So I do not have to load all the XML in memory (with the DOM).

But I still have to do a thing! Take all the out that I created(the xml with the changes) and substitute the current XML. For me sounds a little weird and dangerous. But I guess that is the best sollution.

Next, the snippet of the code:

The Main



A snippet of the first ContentHandler that 'intercept' the other (called parent).
The code, bellow, add a tag 'NEW_TAG' before any element start.



Thank's Paul for the link
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Memory Problem