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/12 05:12:30 UTC
Problem validating schema based document with a declaration.
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 ----
The document is controlled by an XML Schema but I wanted to
introduce a few useful entities so I needed a <!DOCTYPE>
declaration to create a place to declare those entities.
This document validates fine with MSXML (XMLSpy) and with XSV.
However, Xerces-J (v2.4.0 and v2.3.0) complains saying that
"observation-set" is undeclared. In fact, it says that every
element in my document is undeclared. Xerces is fine with the
document if I remove the <!DOCTYPE> and the internal DTD
subset (and any relevant entity references, of course). It
seems like Xerces sees the DOCTYPE and becomes convinced that
the document is fully described by a DTD. Since no DTD is
present to declare any of the elements, Xerces complains. The
fact that there is an XML Schema for the document goes
unnoticed.
Is this an issue with Xerces or my document? If it's an issue
with my document, then how does on go about declaring and
using entities in documents that are based on a Schema?
In case it matters, I'm running Xerces using one of the sample
programs with the following batch file (this is under Win2k):
---- cut here ----
java sax.Counter -n -np -v -s -f %1
---- cut here ----
TIA,
Peter
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org
RE: Problem validating schema based document with a declaration.
Posted by "Peter C. Chapin" <pc...@ecet.vtc.edu>.
On 13 Jul 2003 at 15:57, Vinay Shukla wrote:
> How do you get hold of the parser. If you use jaxp1.2 apis xerces
> behaviour is as per specified in the jaxp1.2 spec.
>
> As per the jaxp1.2 spec if schema language property is set the document
> will only be validated against a schema and never against a dtd.
Well, I'm using the sax.Counter sample program. I see from the
source that it is getting its default parser like so:
parser =
XMLReaderFactory.createXMLReader(DEFAULT_PARSER_NAME);
Where "DEFAULT_PARSER_NAME" is
org.apache.xerces.parsers.SAXParser
I'm not sure if this is the Jaxp API or not.
When you say "never against a DTD" do you mean that it won't
even process the internal DTD subset? I need it to at least
find the entity definitions there... even though the parser
should use the schema for validation.
Peter
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org
Problem validating schema based document with a declaration. (Followup)
Posted by "Peter C. Chapin" <pc...@ecet.vtc.edu>.
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
Re: SAX Parsing too slow
Posted by Elliotte Rusty Harold <el...@metalab.unc.edu>.
At 6:53 PM -0400 7/13/03, Shital Joshi wrote:
>Hi there,
>
>I am parsing a very big xml document(1.2 gb) using Xerces SAX Parser. It
>takes more than 15 minutes before it actually starts thorwing start element
>and end element events. Since this is not a DOM Parser, I suspect it doesn't
>load the document in memory and all. Then nwhy does it take so long before
>throwing any events? Is there any way to make it faster?
>
There could be any number of reasons, but since you're wisely using
AX the simplest solution is try other parsers such as Crimson and
Piccolo and see if any of them provide better performance on your
documents. If they're all equally slow the problem is probably in
your code. For instance, how do you know it takes 15 minutes before
it starts firing start element and end element events? Isd it
possible it actually starts much sooner but your output gets buffered
until then?
--
Elliotte Rusty Harold
elharo@metalab.unc.edu
Processing XML with Java (Addison-Wesley, 2002)
http://www.cafeconleche.org/books/xmljava
http://www.amazon.com/exec/obidos/ISBN%3D0201771861/cafeaulaitA
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org
SAX Parsing too slow
Posted by Shital Joshi <sh...@mfgsys.com>.
Hi there,
I am parsing a very big xml document(1.2 gb) using Xerces SAX Parser. It
takes more than 15 minutes before it actually starts thorwing start element
and end element events. Since this is not a DOM Parser, I suspect it doesn't
load the document in memory and all. Then nwhy does it take so long before
throwing any events? Is there any way to make it faster?
Any help is appreciated.
Thanks,
-Shital Joshi
MFG Systems
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org
RE: Problem validating schema based document with a declaration.
Posted by Vinay Shukla <vi...@oracle.com>.
How do you get hold of the parser. If you use jaxp1.2 apis xerces
behaviour is as per specified in the jaxp1.2 spec.
As per the jaxp1.2 spec if schema language property is set the document
will only be validated against a schema and never against a dtd.
thanks,
Vinay
-----Original Message-----
From: Peter C. Chapin [mailto:pchapin@ecet.vtc.edu]
Sent: Friday, July 11, 2003 11:13 PM
To: xerces-j-user@xml.apache.org
Subject: Problem validating schema based document with a <!DOCTYPE>
declaration.
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 ----
The document is controlled by an XML Schema but I wanted to
introduce a few useful entities so I needed a <!DOCTYPE>
declaration to create a place to declare those entities.
This document validates fine with MSXML (XMLSpy) and with XSV.
However, Xerces-J (v2.4.0 and v2.3.0) complains saying that
"observation-set" is undeclared. In fact, it says that every
element in my document is undeclared. Xerces is fine with the
document if I remove the <!DOCTYPE> and the internal DTD
subset (and any relevant entity references, of course). It
seems like Xerces sees the DOCTYPE and becomes convinced that
the document is fully described by a DTD. Since no DTD is
present to declare any of the elements, Xerces complains. The
fact that there is an XML Schema for the document goes
unnoticed.
Is this an issue with Xerces or my document? If it's an issue
with my document, then how does on go about declaring and
using entities in documents that are based on a Schema?
In case it matters, I'm running Xerces using one of the sample
programs with the following batch file (this is under Win2k):
---- cut here ----
java sax.Counter -n -np -v -s -f %1
---- cut here ----
TIA,
Peter
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org