problem with schema and xml

P

pif34

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>
 
L

Lindberg

pif34 said:
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>
 
P

pif34

Le 30/12/2011 11:12, Lindberg a écrit :
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>
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top