M
matt hegarty
Hi
I am relatively new to XML, but am having problems with a validation
issue.
When the XML is parsed and validated using Xerces, the following error
is seen:
cvc-complex-type.3.2.2: Attribute 'xsi:noNamespaceSchemaLocation' is
not allowed to appear in element 'questionFeed'.
This error does not appear when the file is validated against the
schema using the XMLSpy tool. The file passes validation when the
'noNamespaceSchemaLocation' entry in the XML is removed. So I guess
the question is: how can I structure my schema so that this error is
not seen? Incidentally, the 'noNamespaceSchemaLocation' is
irrelevant in the XML - I validate programmatically.
Snippets of both schema and XML are attached:
== SCHEMA FILE ===
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:simpleType name="nonEmptyString">
<xs:restriction base="xs:string">
<xs:minLength value="1"/>
<xs:whiteSpace value="collapse"/>
</xs:restriction>
</xs:simpleType>
<xs:element name="questionFeed">
<!-- snipped -->
</xs:element>
</xs:schema>
== XML FILE ===
<?xml version="1.0" encoding="UTF-8"?>
<!--Sample XML file generated by XMLSPY v5 rel. 4 U
(http://www.xmlspy.com)-->
<questionFeed xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="blah.xsd">
<pq>
<!-- snipped -->
</pq>
</questionFeed>
I am relatively new to XML, but am having problems with a validation
issue.
When the XML is parsed and validated using Xerces, the following error
is seen:
cvc-complex-type.3.2.2: Attribute 'xsi:noNamespaceSchemaLocation' is
not allowed to appear in element 'questionFeed'.
This error does not appear when the file is validated against the
schema using the XMLSpy tool. The file passes validation when the
'noNamespaceSchemaLocation' entry in the XML is removed. So I guess
the question is: how can I structure my schema so that this error is
not seen? Incidentally, the 'noNamespaceSchemaLocation' is
irrelevant in the XML - I validate programmatically.
Snippets of both schema and XML are attached:
== SCHEMA FILE ===
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:simpleType name="nonEmptyString">
<xs:restriction base="xs:string">
<xs:minLength value="1"/>
<xs:whiteSpace value="collapse"/>
</xs:restriction>
</xs:simpleType>
<xs:element name="questionFeed">
<!-- snipped -->
</xs:element>
</xs:schema>
== XML FILE ===
<?xml version="1.0" encoding="UTF-8"?>
<!--Sample XML file generated by XMLSPY v5 rel. 4 U
(http://www.xmlspy.com)-->
<questionFeed xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="blah.xsd">
<pq>
<!-- snipped -->
</pq>
</questionFeed>