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 Ala Heno <al...@TTI-TELECOM.COM> on 2001/06/27 13:00:32 UTC
schema validation problems ...
Hi all,
I already described the problem I encounter but didn't get any solution ...
I will to describe the problem again.
I have the following very simple Schema:
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="Vars">
</xsd:element>
</xsd:schema>
I also have the following also very simple XML file to be validated
according to the previous Schema:
<?xml version="1.0" encoding="UTF-8"?>
<Vars xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="c:\my training\ala\xml\schema.xsd">
</Vars>
When running SAXCount sample, using Xerces v1.4.1, and using the -v option,
I got the following exception:
[Error] :2:127: Element type "Vars" must be declared.
org.xml.sax.SAXParseException: Element type "Vars" must be declared.
at org.apache.xerces.framework.XMLParser.reportError(XMLParser.java:969)
at
org.apache.xerces.validators.common.XMLValidator.reportRecoverableXMLError(X
MLValidator.java:1052)
at
org.apache.xerces.validators.common.XMLValidator.validateElementAndAttribute
s(XMLValidator.java:2393)
at
org.apache.xerces.validators.common.XMLValidator.callStartElement(XMLValidat
or.java:700)
at
org.apache.xerces.framework.XMLDocumentScanner.scanElement(XMLDocumentScanne
r.java:1852)
at
org.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.dispatch(XM
LDocumentScanner.java:1000)
at
org.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentScanner.
java:380)
at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:861)
at saxSamples.SAXCount.print(SAXCount.java:166)
at saxSamples.SAXCount.main(SAXCount.java:401)
[Error] :2:127: Attribute "xsi:noNamespaceSchemaLocation" must be declared
for element type "Vars".
org.xml.sax.SAXParseException: Attribute "xsi:noNamespaceSchemaLocation"
must be declared for element type "Vars".
at org.apache.xerces.framework.XMLParser.reportError(XMLParser.java:969)
at
org.apache.xerces.validators.common.XMLValidator.validateElementAndAttribute
s(XMLValidator.java:2451)
at
org.apache.xerces.validators.common.XMLValidator.callStartElement(XMLValidat
or.java:700)
at
org.apache.xerces.framework.XMLDocumentScanner.scanElement(XMLDocumentScanne
r.java:1852)
at
org.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.dispatch(XM
LDocumentScanner.java:1000)
at
org.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentScanner.
java:380)
at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:861)
at saxSamples.SAXCount.print(SAXCount.java:166)
My only guess is that the parse cannot find the Schema, but why? The schema
as it can be seen in the XML code is located locally along with the XML
file.
Moreover, having the following changes done and using a previous version of
Xerces (the one before 1.4.0), I got no exceptions!!
Schema:
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2000/10/XMLSchema">
<xsd:element name="Vars">
</xsd:element>
</xsd:schema>
XML:
<?xml version="1.0" encoding="UTF-8"?>
<Vars xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="c:\my training\ala\xml\schema.xsd">
</Vars>
As it can be noticed, the only change is in the schema version from 2001
back to 2000/10!
I ask again, what is wrong?
Thank you in advanced.
Ala