Alex:
Thank you - you've hit it precisely on the head.
When I use the JAXP API as you suggested and pass the
altered personal-schema.xml document to it, I get a
SAXParseException, as I should. I DON'T get the
exception unless I set an ErrorHandler that throws it.
This ran counter to my intuition.
When I pass the same document to an Apache DOMParser
with the namespaces, dynamic, and validation features
turned on and the same ErrorHandler as the JAXP
instance the document is parsed and validated without
complaint.
In my opinion, it shouldn't be absolutely necessary to
use the JAXP API to accomplish this. I should be able
to use the Apache parser directly to accomplish the
same thing. (I'd say that JAXP is using the Apache
parser implementation behind the scenes.)
So my question remains - what am I leaving out from
the Apache parser that prevents it from catching this
invalid document? Thanks again, Alex. - 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/