Question

I'm getting the error s4s-elt-invalid-content.1: The content of '#AnonType_clienttourDatabase' is invalid. Element 'element' is invalid, misplaced, or occurs too often.

from the following; Schema File:

 <?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:element name="tourDatabase">
        <xs:complexType>
            <xs:sequence>
                <xs:element maxOccurs="unbounded" name="client">
                    <xs:complexType>
                        <xs:sequence>
                            <xs:element name="name" type="xs:string"/>
                            <xs:element name="address" type="xs:string"/>
                            <xs:element name="county" type="xs:string"/>
                            <xs:element name="postcode" type="xs:string"/>
                            <xs:element name="dob" type="xs:date"/>
                        </xs:sequence>  
                                <xs:complexType>
                                    <xs:sequence>
                                        <xs:element maxOccurs="unbounded" name="clienttour">
                                            <xs:complexType>
                                                <xs:sequence>
                                                    <xs:element maxOccurs="unbounded" name="tourid" type="xs:integer"/>
                                                    <xs:element maxOccurs="unbounded" name="paid" type="xs:integer"/>
                                                </xs:sequence>
                                                    <xs:attribute name="ctourid" type="xs:integer" use="required"/>
                                            </xs:complexType>
                                        </xs:element>
                                    </xs:sequence>
                                </xs:complexType>
                        </xs:sequence>
                            <xs:attribute name="id" type="xs:integer" use="required"/>
                    </xs:complexType>
                </xs:element>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
</xs:schema>

And the XML File:

    <?xml version="1.0" encoding="UTF-8"?>
<!-- Set of clients Table -->
<tourDatabase
        xmlns:xs="http://www.w3.org/2001/XMLSchema"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        <client id="1">
            <name>Fulton</name>
            <address>Turpis Road</address>
            <county>Stirlingshire</county>
            <postcode>FK8 5RD</postcode>
            <dob>1941-01-16</dob>
            <clientTour ctourid="1">
              <tourid>1</tourid>
              <paid>1</paid>
            </clientTour>
        </client>
        <client id="2">
            <name>Zachery</name>
            <address>Egestas Rd</address>
            <county>Herefordshire</county>
            <postcode>MM85 8DF</postcode>
            <dob>1993-02-13</dob>
            <clientTour ctourid="2">
              <tourid>1</tourid>
              <paid>1</paid>
            </clientTour>
        </client>
            <client id="3">
            <name>Lawrence</name>
            <address>Barrywhale close</address>
            <county>Anor Londo</county>
            <postcode>A0 2PX</postcode>
            <dob>1950-09-24</dob>
            <clientTour ctourid="3">
              <tourid>1</tourid>
              <paid>0</paid>
            </clientTour>
        </client>
        <client id="4">
            <name>Bert</name>
            <address>Old Long Johnston Road</address>
            <county>Blighttown</county>
            <postcode>B3L 4AS</postcode>
            <dob>1993-12-12</dob>
            <clientTour ctourid="4">
              <tourid>1</tourid>
              <paid>0</paid>
            </clientTour>
        </client>
        <client id="5">
            <name>Ernie</name>
            <address>Stevenson Avenue</address>
            <county>Perthshire</county>
            <postcode>B3P 7AS</postcode>
            <dob>1993-12-12</dob>
            <clientTour ctourid="5">
              <tourid>1</tourid>
              <paid>0</paid>
            </clientTour>
        </client>
        <client id="6">
            <name>Bertha</name>
            <address>Firelink crescent</address>
            <county>Stenns Fortress</county>
            <postcode>A8L 9AT</postcode>
            <dob>1973-01-21</dob>
            <clientTour ctourid="6">
              <tourid>1</tourid>
              <paid>1</paid>
            </clientTour>
        </client>
        <client id="7">
            <name>Oliver</name>
            <address>Old River</address>
            <county>Majula</county>
            <postcode>A3T 4PZ</postcode>
            <dob>1963-02-02</dob>
            <clientTour ctourid="7">
              <tourid>1</tourid>
              <paid>1</paid>
            </clientTour>
        </client>
        <client id="8">
            <name>Emerald Herald</name>
            <address>Old Long Johnston Road</address>
            <county>Blighttown</county>
            <postcode>B3L 4AS</postcode>
            <dob>1943-10-10</dob>
            <clientTour ctourid="8">
              <tourid>1</tourid>
              <paid>0</paid>
            </clientTour>
        </client>
</tourDatabase>
Was it helpful?

Solution

Your XML Schema file is invalid. You can't have a complexType inside a complexType. clientTour is a child of client just like name, address, etc. so it's part of the sequence. There are some other problems as well. I fixed it based on your instance:

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:element name="tourDatabase">
        <xs:complexType>
            <xs:sequence>
                <xs:element maxOccurs="unbounded" name="client">
                    <xs:complexType>
                        <xs:sequence>
                            <xs:element name="name" type="xs:string"/>
                            <xs:element name="address" type="xs:string"/>
                            <xs:element name="county" type="xs:string"/>
                            <xs:element name="postcode" type="xs:string"/>
                            <xs:element name="dob" type="xs:date"/>
                            <xs:element maxOccurs="unbounded" name="clientTour">
                                <xs:complexType>
                                    <xs:sequence>
                                        <xs:element maxOccurs="unbounded" name="tourid" type="xs:integer"/>
                                        <xs:element maxOccurs="unbounded" name="paid" type="xs:integer"/>
                                    </xs:sequence>
                                    <xs:attribute name="ctourid" type="xs:integer" use="required"/>
                                </xs:complexType>
                            </xs:element>
                        </xs:sequence>  
                        <xs:attribute name="id" type="xs:integer" use="required"/>
                    </xs:complexType>
                </xs:element>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
</xs:schema>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top