I'm pretty new to xsd and am running into some issues when trying to use 
Xinclude in my schema (with Xerces).


1)      All the sample documentation seemed to imply that you could import 
xinclude as follows:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema";
           xmlns:xi="http://www.w3.org/2001/XInclude"; >

<xs:import namespace="http://www.w3.org/2001/XInclude";
  schemaLocation="xinclude.xsd"/>

However I could only get this to work with a full URL:

i.e. schemaLocation="http://www.w3.org/2001/xinclude.xsd";

Does everyone else have xinclude.xsd downloaded somewhere local?


2)      When I actually go to include references to an inclusion in my xml file 
I'm hitting the following error:

cvc-complex-type.2.4.a: Invalid content was found starting with element 
'xi:include'. One of '{"http://www.w3.org/2001/XInclude":include,  
GlobalConfiguration, TestTemplate, TestGroup}' is expected.


Xsd:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema";
           xmlns:xi="http://www.w3.org/2001/XInclude"; >

<xs:import namespace="http://www.w3.org/2001/XInclude";
           schemaLocation="http://www.w3.org/2001/xinclude.xsd"/>

    <xs:element name="Gauntlet">

        <xs:complexType>
            <xs:sequence>
              <xs:choice maxOccurs="unbounded">
                <xs:element ref="xi:include" minOccurs="0" />
                <xs:element ref="GlobalConfiguration" maxOccurs="1" />
                <xs:element ref="TestTemplate" minOccurs="0" 
maxOccurs="unbounded" />
                <xs:element ref="TestGroup" maxOccurs="unbounded" />
              </xs:choice>
            </xs:sequence>

        </xs:complexType>


XML:

<?xml version="1.0" encoding="UTF-8"?>
<Gauntlet xmlns:xi="http://www.w3.org/2001/XInclude";>
  <xi:include href="fragment.xml" />

Thanks for any help,
Ben


Reply via email to