You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by "Peter C. Chapin" <pc...@ecet.vtc.edu> on 2003/07/19 03:01:41 UTC
Problem validating schema based document with a declaration. (Followup)
In an earlier message I said:
> Hello!
>
> I have a document that starts out like this
>
> ---- cut here ----
> <?xml version="1.0"?>
>
> <!DOCTYPE observation-set [
> <!ENTITY copy "©">
> ]>
>
> <observation-set
> xmlns="http://www.ecet.vtc.edu/~pchapin/AOML_0.0"
> xmlns:xhtml="http://www.w3.org/1999/xhtml"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://www.ecet.vtc.edu/~pchapin/AOML_0.0
> AOML.xsd">
>
> <!-- etc -->
> </observation-set>
>
> ---- cut here ----
This document does not validate. However, if the <!DOCTYPE>
declaration is removed (along with the references to the
© entity) the document validates fine. I now understand
why, but I don't know how to fix it.
I attempted to validate the document using the sax.Counter
sample program provided with Xerces-J. I also wrote a simple
program of my own to explore the issues. I turned on the
following features:
http://xml.org/sax/features/validation
http://apache.org/xml/features/validation/schema
It is my understanding that I need both of these features to
effect schema validation. However, the FAQ (in the Xerces-J
documentation) says:
Q: What happens if I set both validation and schema validation
features on?
A: ... if the instance document has both DTD and XML Schema
grammars, validation errors for both DTD and XML Schema are
reported...
In my case I need a DTD for the <!ENTITY> declaration. Thus
Xerces will report both DTD and XML Schema validation errors.
However since my DTD declares no elements, the DTD validation
process reports an "undeclared element" for every element in
my document. I noticed that if I inject a violation of the XML
Schema into the document then I get an error about that
violation in addition to all the "undeclared element" errors.
Thus it appears that the DTD validation and XML Schema
validation processes are occuring in parallel and largely
independently.
The FAQ in the Xerces documentation goes on:
Q: How can I tell the parser to validate against XML Schema
and not to report DTD validation errors?
A: Currently this is impossible. We hope that JAXP 1.2 will
provide this capability via its schema language property.
This would be a good time to state that I'm using Xerces-J
v2.4.0 and the "readme" section of the documentation implies
that JAXP 1.2 is supported. So the documentation seems
somewhat inconsistent, but I guess that's not a shocking
thing.
In any case, it appears that it is not possible to validate a
document based on an XML Schema and that uses <!DOCTYPE> only
for purposes of introducing entities. Is this really true? It
seems somewhat incredible but the FAQ in the documentation is
clear. The list of supported features does not seem to include
anything that would allow me to specify that only XML Schema
validation errors should be reported. Am I missing something?
Peter
P.S. I'm using j2sdk1.4.1
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org