Bug #3970
closed
XSLT unnecessarily writes to a file
Added by Chris Weed over 15 years ago.
Updated over 15 years ago.
Description
Instead of creating a temporary file that may fail, write the XSLT output to a string buffer.
//XSLT.java
StringWriter sw = new StringWriter();
// Executes the Transformer
try {
transformer.transform(xml, new StreamResult(sw));
htmlStr = sw.toString();
} catch (Exception e) {
MessageHandler.error("Transform error", e);
}
Some XML documents are large enough that String representations can memory limited. By using temporary files properly, we can avoid these memory issues (assuming the XMl isn't loaded into memory somewhere else, of course). Would it be acceptable to simply fix the temporary files problem?
(In reply to comment #1)
Some XML documents are large enough that String representations can memory
limited. By using temporary files properly, we can avoid these memory issues
(assuming the XMl isn't loaded into memory somewhere else, of course). Would it
be acceptable to simply fix the temporary files problem?
I would agree with you if the output of the class was a file name string pointing to where the output is stored, but you are returning the string itself. You have to allocate that memory anyway to return it.
XSLTActor no longer writes the output to a temporary file.
Original Bugzilla ID was 3970
Also available in: Atom
PDF