I am trying to validate the simplest possible XSD file against XMLSchema.xsd:
<xs:schema xmlns:xs="http://ift.tt/tphNwY">
<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:
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:
- why is the parser failing to handle the
XMLSchema.xsdXML prolog? and is there any way to fix this without having to edit theXMLSchema.xsdfile? - if there is no way around #1, how can I download the
XMLSchema.xsdfile from enter link description here without the XML prolog so I don't have to edit manually. A simplewgetfetches 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.
No comments:
Post a Comment