Hi Alex,

Just to add a couple of things to Ian's response:

Not all folks like to use the JAXP, and the DOMParser provides a nice
interface for a DOM tree for lots of people.  The class is also used in
Xerces's schema parsing:  it builds the schema grammar representation from
a DOM tree representation of the schema document created through the
DOMParser.

As to the features:  Xerces uses the SAX property interface to set parser
properties such as validation, whether DOM trees should be created as
needed etc.; just because it's SAX doesn't mean one can't use it in
conjunction with the DOM.

Cheers,
Neil

Neil Graham
XML Parser Development
IBM Toronto Lab
Phone:  416-448-3519, T/L 778-3519
E-mail:  [EMAIL PROTECTED]



"Alex Neth" <[EMAIL PROTECTED]> on 02/23/2001 01:25:34 AM

Please respond to [EMAIL PROTECTED]

To:   [EMAIL PROTECTED]
cc:
Subject:  Re: Using xml schema



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.&nbsp; What is the purpose of this class?&nbsp;
> I use the following method to parse the document:<br>
> <br>
>  &nbsp;&nbsp; DocumentBuilderFactory docFactory =
> DocumentBuilderFactory.newInstance();<br>
>  &nbsp;&nbsp; docFactory.setNamespaceAware(true);<br>
>  &nbsp;&nbsp; docFactory.setValidating(true);<br>
>  &nbsp;&nbsp; try {<br>
>  &nbsp;&nbsp; &nbsp; docBuilder_ =
> docFactory.newDocumentBuilder();<br>
>  &nbsp;&nbsp; } catch (ParserConfigurationException e)
> {<br>
>  &nbsp;&nbsp; }<br>
>  &nbsp;&nbsp; Document&nbsp; 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.&nbsp; 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]
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





Reply via email to