vivek agarwal wrote:

Hi,

I want to generate SAX events from DOM without using any proprietary
stuff, and this is the way I found to do it:

Source source = new DOMSource(doc);
SAXResult result = new SAXResult(handler);
Transformer xformer = TransformerFactory.newInstance().newTransformer();
xformer.transform(source, result);

Can some confirm if this is the best way to do it?

Yes, this is the the portable way to do it using JAXP.

How do I ignore the the whitespaces in DOM?

It depends what you mean by ignorable whitespace. This typically depends on your application and/or its schemas. Every text node in the input DOM will be reported to the SAX handler that you register. Thus, you can insert a SAX filter at that point to "ignore" whatever your app does not regard as information.

-- Santiago



Reply via email to