I don't have a grammar for the DOM created which can be used to determine the ignorable whitespaces, but, if I know that the XML represented as DOM has no mixed content, then how can I ignore the ignorable whitespaces (between 2 start tags) while generating SAX events?
Well yes, I can add filters and do stuff, but I was wondering if there exists a property which I can leverage to ignore the ignorable whitespaces? Thanks, Vivek. On Thu, 24 Feb 2005 10:44:36 -0500, Santiago Pericas-Geertsen <[EMAIL PROTECTED]> wrote: > 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 > >
