aspose file tools*
The moose likes XML and Related Technologies and the fly likes OutOfMemory (the correct one). Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "OutOfMemory (the correct one)." Watch "OutOfMemory (the correct one)." New topic
Author

OutOfMemory (the correct one).

Wim Lambrecht
Greenhorn

Joined: Jun 26, 2003
Posts: 6
Hi,
We get an OutOfMemoryException during the run of the code at the bottom of this message. The XML-file to parse is about 72M big. After 30 sec it runs out of memory. Maybe it has something to do with the parser Xalan vs. Xerces ...
Any ideas ? TIA
wil


EDIT: I took the privilege of adding CODE tags for your code snippet and removed the duplicate post.
[ October 06, 2003: Message edited by: Lasse Koskela ]
Christophe Grosjean
Ranch Hand

Joined: Jan 22, 2002
Posts: 51
I may be wrong but :
72M is quite huge... The transformation requires the building of a DOM-like structure of the XML (in Xalan, I think that they have a "light" implementation of DOM), so it takes memory !
If your XSL is simple, perhaps a solution is to parse your XML with SAX and to output the content in your text file (doing the XSL job in the java code instead).
Christophe
Wim Lambrecht
Greenhorn

Joined: Jun 26, 2003
Posts: 6
Do i need a SAXTransformerFactory instead of a TransformerFactory then ?
TIA. wil.
Christophe Grosjean
Ranch Hand

Joined: Jan 22, 2002
Posts: 51
No. In fact, what I'm suggesting is to avoid using Transformer and XSL.
Perhaps you can do the transformation by yourself by :
1) parse the XML input file with a SAX parser
2) sets to the SAX parser an XMLFilter as ContentHandler
3) sets an XMLWriter as the parent for the XMLFilter
4) The XMLFilter set in (2) must be a subclass of XMLFitlerImpl in which the event methods have been overriden (do specific job that was in your XSL, for instance in the startElement()).
But :
* this works if your output format is XML
* if not (HTML, text...) do not use XMLFilter and XMLWriter, but simply create an implementation of ContentHandler directly writing the output data in a File.
Questions :
* Did you try your transformation with a smaller version of your document ? Was it working ?
* Is your transformation complex ? An example ?
Christophe
Wim Lambrecht
Greenhorn

Joined: Jun 26, 2003
Posts: 6
A quick reply: with a smaller document it works perfect. I will reply later on ...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: OutOfMemory (the correct one).