Reputation: 27286
I am trying to validate the simplest possible XSD file against XMLSchema.xsd:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="a" type="xs:int"/>
</xs:schema>
To that end, I've downloaded file XMLSchema.xsd and pass it to my org.w3c.dom.ls.LSResourceResolver
to ensure that the locally provided XMLSchema.XSD
is used and not one fetched over the Internet. The code runs with Saxon-HE-9.4.jar
on my classpath.
However this fails with:
org.xml.sax.SAXParseException; cvc-elt.1: Cannot find the declaration of element 'xs:schema'.
which appears to be related to a previous message (emitted by my custom LSResourceResolver
subclass):
Failed to read schema document '[...]XMLSchema.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>.
When, however I comment out the entire DOCTYPE
section in the XMLSchema.XSD
file it is working.
I guess this means the parser can't handle the DOCTYPE
and ATTLIST
clauses in XMLSchema.xsd
.
So I have two questions:
XMLSchema.xsd
XML prolog? and is there any way to fix this without having to edit the XMLSchema.xsd
file?XMLSchema.xsd
file from http://www.w3.org/2001/XMLSchema.xsd without the XML prolog so I don't have to edit manually. A simple wget
fetches the XML prolog as well (which BTW does not appear when the link is visited with a browser).This is really too large to provide an SSCCE but if anyone wants to have a look I'll provide a github repository with the test case.
Upvotes: 0
Views: 1222
Reputation: 25034
If it's failing on the reference to XMLSchema.dtd, then one obvious solution (other than commenting out the DOCTYPE declaration, which you've already found) would be to download the DTD files (XMLSchema.dtd and datatypes.dtd) and supply them locally, as well.
Upvotes: 1