]> Pierre Choffet | Git repositories - wdef_schemas.git/blob - wdef.xsd
First schema version
[wdef_schemas.git] / wdef.xsd
1 <?xml version="1.0" encoding="utf-8"?>
2 <!--
3 Schemas required to validate WDEF compatible XML content.
4 Copyright (C) 2020, 2021 Pierre Choffet
5
6 This program is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>.
17 -->
18
19 <xsd:schema xml:lang="en" xmlns:wdef="https://purl.choffet.net/wdef"
20 xmlns:xsd="http://www.w3.org/2001/XMLSchema"
21 targetNamespace="https://purl.choffet.net/wdef" attributeFormDefault="qualified"
22 elementFormDefault="qualified">
23 <xsd:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="xml.xsd" />
24
25 <xsd:element name="knowledge">
26 <xsd:annotation>
27 <xsd:documentation>
28 The root of a WDEF content. It can contain one or more element only.
29 </xsd:documentation>
30 </xsd:annotation>
31 <xsd:complexType>
32 <xsd:sequence>
33 <xsd:element ref="wdef:element" minOccurs="0" maxOccurs="unbounded" />
34 </xsd:sequence>
35 </xsd:complexType>
36
37 <xsd:key name="key-element">
38 <xsd:selector xpath="wdef:element" />
39 <xsd:field xpath="@wdef:id" />
40 </xsd:key>
41 </xsd:element>
42
43 <xsd:element name="element">
44 <xsd:annotation>
45 <xsd:documentation>
46 A Wikidata element.
47 </xsd:documentation>
48 </xsd:annotation>
49 <xsd:complexType>
50 <xsd:choice maxOccurs="unbounded">
51 <xsd:element ref="wdef:label" />
52 <xsd:element ref="wdef:description" />
53 <xsd:element ref="wdef:alias" />
54 <xsd:element ref="wdef:property" />
55 </xsd:choice>
56 <xsd:attribute name="id" type="wdef:element-id" use="required" />
57 <xsd:anyAttribute processContents="skip" />
58 </xsd:complexType>
59
60 <xsd:key name="key-property">
61 <xsd:selector xpath="wdef:property" />
62 <xsd:field xpath="@wdef:id" />
63 </xsd:key>
64
65 <xsd:key name="key-value">
66 <xsd:selector xpath="wdef:value" />
67 <xsd:field xpath="@wdef:id" />
68 </xsd:key>
69
70 <xsd:unique name="unique-label-lang">
71 <xsd:selector xpath="wdef:label" />
72 <xsd:field xpath="@xml:lang" />
73 </xsd:unique>
74
75 <xsd:unique name="unique-description-lang">
76 <xsd:selector xpath="wdef:description" />
77 <xsd:field xpath="@xml:lang" />
78 </xsd:unique>
79 </xsd:element>
80
81 <xsd:element name="label" type="wdef:translation" />
82 <xsd:element name="description" type="wdef:translation" />
83 <xsd:element name="alias" type="wdef:translation" />
84
85 <xsd:element name="property">
86 <xsd:annotation>
87 <xsd:documentation>
88 A Wikidata property.
89 </xsd:documentation>
90 </xsd:annotation>
91 <xsd:complexType>
92 <xsd:choice maxOccurs="unbounded">
93 <xsd:element ref="wdef:value" />
94 <xsd:element ref="wdef:novalue" maxOccurs="1" />
95 <xsd:element ref="wdef:somevalue" maxOccurs="1" />
96 </xsd:choice>
97 <xsd:attribute name="id" type="wdef:property-id2" use="required" />
98 <xsd:attribute name="pid" type="wdef:property-id" use="required" />
99 <xsd:anyAttribute processContents="skip" />
100 </xsd:complexType>
101 </xsd:element>
102
103 <xsd:element name="value">
104 <xsd:annotation>
105 <xsd:documentation>
106 A Wikidata value.
107 </xsd:documentation>
108 </xsd:annotation>
109 <xsd:complexType>
110 <xsd:choice maxOccurs="unbounded">
111 <xsd:element ref="wdef:literal" maxOccurs="1" />
112 <xsd:element ref="wdef:ref-element" maxOccurs="1" />
113 <xsd:element ref="wdef:translation" maxOccurs="1" />
114 <xsd:element ref="wdef:quantity" maxOccurs="1" />
115 <xsd:element ref="wdef:time" maxOccurs="1" />
116 <xsd:element ref="wdef:coordinate" maxOccurs="1" />
117 <xsd:element ref="wdef:qualifier" />
118 </xsd:choice>
119 <xsd:attribute name="id" type="wdef:value-id" use="required" />
120 </xsd:complexType>
121 </xsd:element>
122
123 <xsd:element name="literal" type="xsd:normalizedString" />
124
125 <xsd:element name="ref-element" type="wdef:element-id" />
126
127 <xsd:element name="translation" type="wdef:translation" />
128
129 <xsd:element name="quantity">
130 <xsd:complexType>
131 <xsd:simpleContent>
132 <xsd:extension base="xsd:decimal">
133 <xsd:attribute name="unit" type="wdef:element-id" use="required" />
134 </xsd:extension>
135 </xsd:simpleContent>
136 </xsd:complexType>
137 </xsd:element>
138
139 <xsd:element name="time">
140 <xsd:complexType>
141 <xsd:simpleContent>
142 <xsd:extension base="wdef:date-time">
143 <xsd:attribute name="precision" use="required">
144 <xsd:simpleType>
145 <xsd:restriction base="xsd:positiveInteger">
146 <xsd:maxInclusive value="14" />
147 </xsd:restriction>
148 </xsd:simpleType>
149 </xsd:attribute>
150 <xsd:attribute name="calendar" use="required">
151 <xsd:simpleType>
152 <xsd:restriction base="xsd:normalizedString">
153 <xsd:enumeration value="julian" />
154 <xsd:enumeration value="gregorian" />
155 </xsd:restriction>
156 </xsd:simpleType>
157 </xsd:attribute>
158 </xsd:extension>
159 </xsd:simpleContent>
160 </xsd:complexType>
161 </xsd:element>
162
163 <xsd:element name="coordinate">
164 <xsd:complexType>
165 <xsd:simpleContent>
166 <xsd:extension base="wdef:date-time">
167 <xsd:attribute name="latitude" use="required">
168 <xsd:simpleType>
169 <xsd:restriction base="xsd:float">
170 <xsd:minInclusive value="-90" />
171 <xsd:maxInclusive value="90" />
172 </xsd:restriction>
173 </xsd:simpleType>
174 </xsd:attribute>
175 <xsd:attribute name="longitude" use="required">
176 <xsd:simpleType>
177 <xsd:restriction base="xsd:float">
178 <xsd:minInclusive value="-180" />
179 <xsd:maxInclusive value="180" />
180 </xsd:restriction>
181 </xsd:simpleType>
182 </xsd:attribute>
183 </xsd:extension>
184 </xsd:simpleContent>
185 </xsd:complexType>
186 </xsd:element>
187
188 <xsd:element name="novalue">
189 <xsd:complexType>
190 <xsd:choice maxOccurs="unbounded">
191 <xsd:element ref="wdef:qualifier" />
192 </xsd:choice>
193 <xsd:attribute name="id" type="wdef:value-id" use="required" />
194 </xsd:complexType>
195 </xsd:element>
196
197 <xsd:element name="somevalue">
198 <xsd:complexType />
199 </xsd:element>
200
201 <xsd:element name="qualifier">
202 <xsd:complexType>
203 <xsd:all>
204 <xsd:element ref="wdef:property" />
205 </xsd:all>
206 <xsd:anyAttribute processContents="skip" />
207 </xsd:complexType>
208 </xsd:element>
209
210 <!-- Attributes groups -->
211
212 <!-- Types -->
213 <xsd:complexType name="translation">
214 <xsd:simpleContent>
215 <xsd:extension base="wdef:non-empty-normalized-string">
216 <xsd:attribute ref="xml:lang" use="required" />
217 </xsd:extension>
218 </xsd:simpleContent>
219 </xsd:complexType>
220
221 <xsd:simpleType name="element-id">
222 <xsd:restriction base="xsd:normalizedString">
223 <xsd:pattern value="(\?E|Q)[0-9]+" />
224 </xsd:restriction>
225 </xsd:simpleType>
226
227 <xsd:simpleType name="property-id">
228 <xsd:restriction base="xsd:normalizedString">
229 <xsd:pattern value="P[0-9]+" />
230 </xsd:restriction>
231 </xsd:simpleType>
232
233 <xsd:simpleType name="property-id2">
234 <xsd:restriction base="xsd:normalizedString">
235 <xsd:pattern value="\?P[0-9\?\-EP]+" />
236 </xsd:restriction>
237 </xsd:simpleType>
238
239 <xsd:simpleType name="value-id">
240 <xsd:restriction base="xsd:normalizedString">
241 <xsd:pattern value="\?V.+" />
242 </xsd:restriction>
243 </xsd:simpleType>
244
245 <xsd:simpleType name="non-empty-normalized-string">
246 <xsd:restriction base="xsd:normalizedString">
247 <xsd:minLength value="1" />
248 </xsd:restriction>
249 </xsd:simpleType>
250
251 <xsd:simpleType name="date-time">
252 <xsd:restriction base="xsd:normalizedString">
253 <xsd:pattern value="(-|\+)[0-9]+-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z" />
254 </xsd:restriction>
255 </xsd:simpleType>
256 </xsd:schema>