Sebastian Kerekes
Usenet Archive
- Joined
- Sep 1, 2004
- Messages
- 16
- Reaction score
- 0
Greetings,
I'm new to XSD and I'm trying to create a schema for the following: The document 'persons' should contain 0+ elements of type 'person', which has a subelement called 'name' which is a complex type consisting of the elements 'firstname' and 'lastname'. 'name' should be unique, no combination of firstname and lastname should appear twice.
And that's where I fail, at least XMLSpy tells my, that my code is not correct. I had a look at some sources in the internet, to me the code seems correct ..
Could someone have a look at the following code and tell my what my fault is?
Thanks for you answers in advance,
Sebastian
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified"> <xs:element name="persons"> <xs:complexType> <xs:all> <xs:element name="person"> <xs:unique> <xs:selector xpath="."/> <xs:field xpath="./name/firstname"/> </xs:unique> <xs:complexType> <xs:all> <xs:element name="name" type="name"/> </xs:all> </xs:complexType> </xs:element> </xs:all> </xs:complexType> </xs:element> <xs:complexType name="name"> <xs:all> <xs:element name="firstname" type="xs:string"/> <xs:element name="lastname" type="xs:string"/> </xs:all> </xs:complexType> </xs:schema>
I'm new to XSD and I'm trying to create a schema for the following: The document 'persons' should contain 0+ elements of type 'person', which has a subelement called 'name' which is a complex type consisting of the elements 'firstname' and 'lastname'. 'name' should be unique, no combination of firstname and lastname should appear twice.
And that's where I fail, at least XMLSpy tells my, that my code is not correct. I had a look at some sources in the internet, to me the code seems correct ..
Could someone have a look at the following code and tell my what my fault is?
Thanks for you answers in advance,
Sebastian
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified"> <xs:element name="persons"> <xs:complexType> <xs:all> <xs:element name="person"> <xs:unique> <xs:selector xpath="."/> <xs:field xpath="./name/firstname"/> </xs:unique> <xs:complexType> <xs:all> <xs:element name="name" type="name"/> </xs:all> </xs:complexType> </xs:element> </xs:all> </xs:complexType> </xs:element> <xs:complexType name="name"> <xs:all> <xs:element name="firstname" type="xs:string"/> <xs:element name="lastname" type="xs:string"/> </xs:all> </xs:complexType> </xs:schema>