The DocumentBuilder API is part of the Sun API, whereas the DOMParser is proprietary to Xerces.
I was just wondering why this class exists when it is redundant.
I guess you are actually setting the sax feature
http://xml.org/sax/features/validation
to true in order to enable parsing on the DOMParser???
It would be nice if there was actually some information about the distinctions here on the apache site or in the docs. I haven't found any.
-Alex
Michael Duffy wrote:
The name says it all, Alex: it's a parser that parses
an XML document and creates a DOM tree.
Your DocumentBuilder is probably using one behind the scenes to do the same thing.
The only difference is that you're
DocumentBuilderFactory uses methods like
setNamespaceAware() and setValidating() instead of the
XML-Apache setFeature() method on the DOMParser class
itself. I'll try that and see if it makes a
difference.
Thanks for the suggestion - anything helps. What I'm doing now is obviously wrong, because I'm not failing when I parse invalid documents! - MOD
--- Alex Neth <[EMAIL PROTECTED]> wrote:
<HR> <html><head></head><body>I don't use the DOMParser class. What is the purpose of this class? I use the following method to parse the document:<br> <br> DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();<br> docFactory.setNamespaceAware(true);<br> docFactory.setValidating(true);<br> try {<br> docBuilder_ = docFactory.newDocumentBuilder();<br> } catch (ParserConfigurationException e) {<br> }<br> Document doc = docBuilder_.parse(f);<br> <br> Shouldn't enabling validation here work?<br> <br> It definitely does something because I don't get the "grammar not found" error when validation is set to false.<br> <br> Also, the validation "feature" has "sax" in the feature name. I would think that means it's a SAX specific feature.<br> <br> Thanks<br> <br> <br> Ian Roberts wrote:<br> <blockquote type="cite" cite="mid:[EMAIL PROTECTED]"><pre wrap="">On Wed, 21 Feb 2001, Alex Neth wrote:<br><br></pre> <blockquote type="cite"><pre wrap="">Also, does validation have to be enabled in order to get the parser to load<br>the schema and apply fixed/default attribute values?<br></pre></blockquote> <pre wrap=""><!----><br>To get the parser to do schema validation at all, you need to set the<br>validation, validation/schema and namespaces features (see the Features<br>page of the xerces-j website for the exact feature URIs).<br><br>Ian<br><br></pre> </blockquote> <br> </body></html>
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
__________________________________________________ Do You Yahoo!? Yahoo! Auctions - Buy the things you want at great prices! http://auctions.yahoo.com/
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
