I am trying to transform a very large XML document using DOM4J in Java. Here's what I do:
1. Read in the original XML file using SAXReader (reader is a SAXReader object):
Document myDoc = reader.read(new File("very_large_xml_file.xml"))...
2. Pass the Document myDoc to the following function that transforms the file:
public Document stylesheet_trans(Document document, String stylesheet)
// load the transformer using JAXP
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer(
// now lets style the given document
DocumentSource source = new DocumentSource(document);
DocumentResult result = new DocumentResult();
// return the transformed document
Document transformedDoc = result.getDocument();
finally, write the returned Document to a new file:
final_file = new FileWriter("final_transformed_large_xml_file.xml");
The problem here is, when I opened the final_transformed_large_xml_file.xml in a browser, it tells me that the document is truncated (that is, the transformation process seems unable to handle such a large original file...) -- there is no real problem with the actual tag transformations, but it is just cut off before the end. Can anyone help me with this problem?