Hello Sandy,
Answering in reverse order:
But as there are lot of IO operations so the application is very slow.
Is there any way to pass the xml stream (using the string buffer that I am
writing into XML file) directly to xalan
From the string buffer construct a Reader and use
this in the StreamSource constructor.
StringBuffer sb= ....;
Transformer t= TransformerFactory.newInstance().newTransformer();
t.transform(new StreamSource(new StringReader(sb.toString()), "buffer:sb"),
new StreamResult(new File("output.xml")));
While this avoids disk-io, it does not avoid the parsing/lexical
analysis overhead.
I have some data stored in my internal data structure. I am writing this
data in an xml file and invoking xalan on this file to perform some
transformation.
A more efficient technique could be to generate SAX ContentHandler
events as you traverse your internal data structure. You could
then feed this contentHandler into the SAXSource constructor:
Class DSToXML implements ContentHandler ....;
DSToXML reporter;
t.transform(new SAXSource(reporter), ...);
Hope this gives you a start,
Nigel