[xsl] java.lang.OutOfMemory Error When Transforming a Flat XML Document into Detailed XML Document via XSL

Subject: [xsl] java.lang.OutOfMemory Error When Transforming a Flat XML Document into Detailed XML Document via XSL
From: "David Haines" <david.f.haines@xxxxxxxx>
Date: Tue, 13 Nov 2001 16:08:22 -0600
We are developing a process that converts a fixed-length flat file into XML.
As of this point, I have performed the following steps via Java and XSL:

1. Created a Java class to take a flat file and create a flat XML file. For
instance, the flat XML file would look like:

<ROWSET>
<ROW>flat file record 1</ROW>
<ROW>flat file record 2</ROW>
...
</ROWSET>

2. Created an XSL stylesheet that would create a detailed XML document (see
below) based on the flat XML file.

<ROWSET>
<ROW>
<RECORD_ID>0342323</RECORD_ID>
<SUBMISSION_DATE>03/22/2001</SUBMISSION_DATE>
</ROW>
<ROW>
<RECORD_ID>0342324</RECORD_ID>
<SUBMISSION_DATE>03/23/2001</SUBMISSION_DATE>
</ROW>
</ROWSET>

3. Created a Java class to take the Flat XML file in (1) and transform it to
full XML based on the XSL document in (2).

public void convert() {
try {
javax.xml.transform.TransformerFactory tFactory =
javax.xml.transform.TransformerFactory.newInstance();
javax.xml.transform.Transformer transformer = tFactory.newTransformer(new
javax.xml.transform.stream.StreamSource(xslDoc));
transformer.transform(new javax.xml.transform.stream.StreamSource(inXML),
new javax.xml.transform.stream.StreamResult(
new java.io.FileOutputStream(outXML)));
}
catch (Exception ex) {
ex.printStackTrace();
}
}

4. When I run execute this Java class using a large file (e.g., 22 Mb), it
will process until it hits a java.lang.OutOfMemory error. Mind you that it
creates approximately half its task of creating of the full XML document
before hitting the OutOfMemory error.

Any thoughts on how to process large files using XSL transformation?


David Haines
david.f.haines@xxxxxxxx


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread