I am getting errors when I try to validate a document that uses XInclude against a schema. The version of xerces being used is: 2.6.2.
The problem I am having is with the xml:base attribute. The XInclude FAQ says that to solve this problem one must modify the schema elements to allow the xml:base attribute. Unfortunately, I have been unable to figure out how to modify my schema to allow the attribute.
Currently, I have three documents: contacts.xml, name.xml and contacts.xsd. When I parse contacts.xml I get the following error message:
[Error] contacts.xsd:25:49: src-resolve: Cannot resolve the name 'xml:base' to a(n) 'attribute declaration' component.
[Error] contacts.xsd:25:49: s4s-elt-invalid-content.1: The content of 'nameType' is invalid. Element 'attribute' is invalid, misplaced, or occurs too often.
[Error] name.xml:2:6: Document is invalid: no grammar found.
[Error] name.xml:2:6: Document root element "name", must match DOCTYPE root "null".
contacts.xml
-----------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<contact xmlns="http://test"
xmlns:xi="http://www.w3.org/2003/XInclude"
xmlns:xsd="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xml="http://www.w3.org/XML/1998/namespace"
xsd:schemaLocation="http://test
contacts.xsd">
<xi:include href="">"name.xml"/>
</contact>
name.xml
--------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<name
xmlns="http://test">
<first>Carl</first>
<last>Stottlemyer</last>
</name>
contacts.xsd
-------------------------------------------------------------------------------------------------
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xml="http://www.w3.org/XML/1998/namespace"
xmlns:test="http://test"
targetNamespace="http://test"
elementFormDefault="qualified"
attributeFormDefault="unqualified">
<!--
(I also downloaded the xml.xsd from w3 and tried this)
<xsd:import namespace="http://www.w3.org/XML/1998/namespace"
schemaLocation="xml.xsd"/>
-->
<xsd:import namespace="http://www.w3.org/XML/1998/namespace"/>
<xsd:element name="contact">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="name" type="test:nameType"
maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:complexType name="nameType">
<xsd:sequence>
<xsd:element name="first"/>
<xsd:element name="last"/>
</xsd:sequence>
<xsd:attribute ref="xml:base" use="optional"/>
</xsd:complexType>
</xsd:schema>
Carl Stottlemyer