problem with schema and xml

Discussion in 'XML' started by pif34, Dec 29, 2011.

  1. pif34

    pif34 Guest

    Hello, de XML document I want to create. My error message is :


    cvc-complex-type.2.4.a: Invalid content was found starting with element
    'personne'. One of '{personne}' is expected.

    Can you explain me the error ?

    Thanks.





    <?xml version="1.0" encoding="UTF-8"?>
    <users xmlns="..." xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="... users.xsd">
    <personne>
    <matricule>123456</matricule>
    <nom>Fabien</nom>
    <roles>
    <role>redacteur</role>
    <role>responsable_technique</role>
    </roles>
    </personne>
    </users>

    and here is my schema:

    <?xml version="1.0"?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
    targetNamespace="..." xmlns="...">
    <xs:element name="users">
    <xs:complexType>
    <xs:sequence>
    <xs:element name="personne" minOccurs="1" maxOccurs="unbounded">
    <xs:complexType>
    <xs:all>
    <xs:element name="matricule" type="xs:string"/>
    <xs:element name="nom" type="xs:string"/>
    <xs:element name="roles">
    <xs:complexType>
    <xs:sequence>
    <xs:element name="role" minOccurs="1" maxOccurs="unbounded">
    <xs:simpleType>
    <xs:restriction base="xs:string">
    <xs:pattern value="redacteur|responsable_technique"/>
    </xs:restriction>
    </xs:simpleType>
    </xs:element>
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    </xs:all>
    </xs:complexType>
    </xs:element>
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    </xs:schema>
    pif34, Dec 29, 2011
    #1
    1. Advertising

  2. pif34

    Lindberg Guest

    pif34 wrote:
    > Hello, de XML document I want to create. My error message is :
    >
    >
    > cvc-complex-type.2.4.a: Invalid content was found starting with element
    > 'personne'. One of '{personne}' is expected.
    >
    > Can you explain me the error ?


    Your Schema is just broken, garbage:

    <?xml version="1.0"?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
    targetNamespace="..." xmlns="...">
    <xs:element name="users">
    <xs:complexType>
    <xs:sequence>
    <xs:element name="personne" minOccurs="1" maxOccurs="unbounded">
    <xs:complexType>
    <xs:all>
    <xs:element name="matricule" type="xs:string"></xs:element>
    <xs:element name="nom" type="xs:string"></xs:element>
    <xs:element name="roles">
    <xs:complexType>
    <xs:sequence>
    <xs:element name="role" minOccurs="1"maxOc="unbounded">
    <xs:simpleType>
    <xs:restriction base="xs:string">
    <xs:pattern value="reur|r_hnique"></xs:pattern>
    </xs:restriction>
    </xs:simpleType>
    </xs:element>
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    </xs:all>
    </xs:complexType>
    </xs:element>
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    </xs:schema>
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    </xs:all>
    </xs:complexType>
    </xs:element>
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    </xs:schema>
    Lindberg, Dec 30, 2011
    #2
    1. Advertising

  3. pif34

    pif34 Guest

    Le 30/12/2011 11:12, Lindberg a écrit :
    > pif34 wrote:
    >> Hello, de XML document I want to create. My error message is :
    >>
    >>
    >> cvc-complex-type.2.4.a: Invalid content was found starting with
    >> element 'personne'. One of '{personne}' is expected.
    >>
    >> Can you explain me the error ?

    >
    > Your Schema is just broken, garbage:


    do you mean xsd is not valid ? perhaps I've made an error when
    pasting/indenting... but when I validate it, the xsd is ok.

    so here is another xsd that has same problem. Can you detail what is
    "broken" ?

    Thanks.

    <?xml version="1.0"?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
    targetNamespace="http://www.eurocopter.com/Users"
    xmlns="http://www.eurocopter.com/Users">
    <xs:element name="users" type="usersType">

    </xs:element>

    <xs:complexType name="userType">
    <xs:sequence>
    <xs:element name="matricule" type="xs:string" maxOccurs="1"
    minOccurs="1"></xs:element>
    <xs:element name="nom" type="xs:string" maxOccurs="1"
    minOccurs="1"></xs:element>
    <xs:element name="role" type="xs:string" maxOccurs="unbounded"
    minOccurs="1"></xs:element>
    </xs:sequence>
    </xs:complexType>


    <xs:complexType name="usersType">
    <xs:sequence>
    <xs:element name="user" type="userType"></xs:element>
    </xs:sequence>
    </xs:complexType>
    </xs:schema>


    <?xml version="1.0" encoding="UTF-8"?>
    <users xmlns="http://www.X.com/Users"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.x.com/Users users.xsd">
    <user>
    <matricule>123456</matricule>
    <nom>john</nom>
    <role>redacteur</role>
    <role>responsable_technique</role>
    </user>
    </users>
    pif34, Dec 30, 2011
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.

Share This Page