Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

problem with schema and xml

1 view
Skip to first unread message

pif34

unread,
Dec 29, 2011, 4:32:03 PM12/29/11
to
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>

Lindberg

unread,
Dec 30, 2011, 5:12:15 AM12/30/11
to
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>

pif34

unread,
Dec 30, 2011, 5:35:06 AM12/30/11
to
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>
0 new messages