public InputStream convert(org.w3c.dom.Document
edoc) throws IOException {
final
org.w3c.dom.Document doc = edoc;
final PipedOutputStream pos = new
PipedOutputStream();
PipedInputStream pis = new
PipedInputStream();
pis.connect(pos);
(new
Thread(new Runnable() {
public
void run()
{
try
{
transform(doc,
pos);
}
catch (TransformerException _ex)
{
throw new RuntimeException("Failed to tranform org.w3c.dom.Document to
PipedOutputStream",
_ex);
}
finally
{
try
{
pos.close();
}
catch (IOException e) {
}
}
}
},
"MyClassName.convert(org.w3c.dom.Document edoc)")).start();
return
pis;
}
private void transform(org.w3c.dom.Document
edoc, PipedOutputStream pos) throws TransformerException {
TransformerFactory tFactory =
TransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer();
transformer.setOutputProperty("encoding",
"ISO-8859-1");
transformer.setOutputProperty("indent", "yes");
transformer.transform(new DOMSource(edoc), new StreamResult(pos));
}