|
Hi,
This is not very efficient
though (you're serializing the document to a string first, right?). I think
there's a class somewhere in GNU that generates SAX events directly from a DOM
document. Another place to look would be �lfred.
I remember reading
about this in O'Reilly's SAX2 book, which I'd recommend
buying.
Cheers,
Alex
Ok! Got a Solution!
Used StringWriter to hold the
XML DOM tree and used it as input to SAX InputSource.
DOMSource objXMLSource = new
DOMSource(sourceDocument);
StringWriter stringOut = new
StringWriter(); StreamResult objResultStream
= new StreamResult(stringOut); Transformer
objTransformer =
TransformerFactory.newInstance().newTransformer();
objTransformer.transform(objXMLSource, objResultStream);
String xmlString =
stringOut.toString();
ByteArrayInputStream stream
= new ByteArrayInputStream(xmlString.getBytes());
InputSource is = new
InputSource(stream);
Regards
Prasanna Kumar
Hi All,
Is there any way by which I
can generate SAX InputSource from a org.w3c.dom.Document object, without
generating temporary XML file.
I am using iText library to
generate PDF from an XML source. As an XML Source I have a Document object.
But the iText library only supports input in the form
of SAX InputSource.
Any
suggestions?
Thanks,
|