1 <?xml version="1.0" encoding="UTF-8"?>
2 <!-- $Header: /home/cvsroot/w3c-xml-schema/user/examples/first-complex-types.xsd,v 1.1 2001/11/12 20:54:00 vdv Exp $ -->
3 <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
5 <xs:simpleType name="string255">
6 <xs:restriction base="xs:token">
7 <xs:maxLength value="255"/>
11 <xs:simpleType name="string32">
12 <xs:restriction base="xs:token">
13 <xs:maxLength value="32"/>
17 <xs:simpleType name="isbn">
18 <xs:restriction base="xs:unsignedLong">
19 <xs:totalDigits value="10"/>
20 <xs:pattern value="\d{10}"/>
24 <xs:simpleType name="bookID">
25 <xs:restriction base="xs:ID">
26 <xs:pattern value="b\d{10}"/>
30 <xs:simpleType name="supportedLanguages">
31 <xs:restriction base="xs:language">
32 <xs:enumeration value="en"/>
33 <xs:enumeration value="es"/>
37 <xs:simpleType name="date">
38 <xs:restriction base="xs:date">
39 <xs:pattern value="[^:Z]*"/>
43 <xs:element name="name" type="string32"/>
44 <xs:element name="qualification" type="string255"/>
45 <xs:element name="born" type="date"/>
46 <xs:element name="dead" type="date"/>
47 <xs:element name="isbn" type="isbn"/>
49 <xs:attribute name="id" type="xs:ID"/>
50 <xs:attribute name="available" type="xs:boolean"/>
51 <xs:attribute name="lang" type="supportedLanguages"/>
53 <xs:complexType name="elementWithID">
54 <xs:attribute ref="id"/>
57 <xs:complexType name="bookTmp">
59 <xs:extension base="elementWithID">
61 <xs:element ref="isbn"/>
62 <xs:element ref="title"/>
63 <xs:element ref="author" minOccurs="0" maxOccurs="unbounded"/>
64 <xs:element ref="character" minOccurs="0" maxOccurs="unbounded"/>
66 <xs:attribute ref="available"/>
71 <xs:complexType name="personType">
73 <xs:extension base="elementWithID">
75 <xs:element ref="name"/>
76 <xs:element ref="born"/>
77 <xs:element ref="dead" minOccurs="0"/>
78 <xs:element ref="qualification" minOccurs="0"/>
84 <xs:element name="title">
87 <xs:extension base="string255">
88 <xs:attribute ref="lang"/>
94 <xs:element name="library">
97 <xs:element ref="book" maxOccurs="unbounded"/>
102 <xs:element name="book">
105 <xs:restriction base="bookTmp">
107 <xs:element ref="isbn"/>
108 <xs:element ref="title"/>
109 <xs:element ref="author" minOccurs="0" maxOccurs="unbounded"/>
110 <xs:element ref="character" minOccurs="0" maxOccurs="unbounded"/>
112 <xs:attribute name="id" type="bookID"/>
113 <xs:attribute ref="available"/>
119 <xs:element name="author">
122 <xs:restriction base="personType">
124 <xs:element ref="name"/>
125 <xs:element ref="born"/>
126 <xs:element ref="dead" minOccurs="0"/>
128 <xs:attribute ref="id"/>
135 <xs:element name="character">
138 <xs:restriction base="personType">
140 <xs:element ref="name"/>
141 <xs:element ref="born"/>
142 <xs:element ref="qualification"/>
144 <xs:attribute ref="id"/>