OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Zerces 1.4.2, JAXP, schema - can't validate



Thanks for the reply / confirmation. More comments and questions in-line...

At 8/7/2001 03:52 AM, Zehavi, Gil wrote:
>You need to tell the parser to use the schema for validation using:
>setFeature("http://apache.org/xml/features/validation/schema", true);

----
I think that is what DocumentBuilderFactory.setValidating(boolean) is 
supposed to do, and, to an extent is doing (as parser does try to validate 
the elements as they are encountered). The JAXP only supports 
setFeature(String, Object).


>I could not manage to do it (setFeature command) using the same code you
>wrote. Therefore I used the DOMParser class to parse the doc and then
>continue with JAXP classes. Here is the code:
>
>DOMParser parser = new DOMParser();
>parser.setFeature("http://xml.org/sax/features/validation", true);
>parser.setFeature("http://apache.org/xml/features/validation/schema", true);
>parser.setErrorHandler(_errorHandler);
>parser.parse(filePath);
>Document doc = parser.getDocument();

----
This does work, but is not JAXP compliant.

What really appears to be occurring is that the schema location is simply 
being ignored - as I can put anything in the noNamespaceSchemaLocation / 
SchemaLocation attribute and get the same results. I figured I would at 
least get an error if the schema document couldn't be obtained.

Should an error be thrown if the document referenced by the URI can't be 
obtained? Is this a bug in Xerces or am I the one with coding?

Pete