1 | <?xml version="1.0" encoding="UTF-8"?> |
---|
2 | <!-- |
---|
3 | $Revision: 5198 $ |
---|
4 | $Date: 2014-05-14 14:56:59 +0000 (Wed, 14 May 2014) $ |
---|
5 | |
---|
6 | CMDI 1.1 General Component Schema |
---|
7 | |
---|
8 | http://www.clarin.eu/cmdi |
---|
9 | --> |
---|
10 | |
---|
11 | <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:sch="http://purl.oclc.org/dsdl/schematron"> |
---|
12 | |
---|
13 | <xs:import namespace="http://www.w3.org/XML/1998/namespace" |
---|
14 | schemaLocation="http://www.w3.org/2005/08/xml.xsd"/> |
---|
15 | |
---|
16 | <!-- root element --> |
---|
17 | <xs:element name="CMD_ComponentSpec"> |
---|
18 | <xs:complexType> |
---|
19 | <xs:sequence> |
---|
20 | <xs:element name="Header"> |
---|
21 | <xs:complexType> |
---|
22 | <xs:sequence> |
---|
23 | <xs:element name="ID" type="xs:anyURI" minOccurs="0"/> |
---|
24 | <xs:element name="Name" type="xs:string" minOccurs="0"/> |
---|
25 | <xs:element name="Description" type="xs:string" minOccurs="0"/> |
---|
26 | </xs:sequence> |
---|
27 | </xs:complexType> |
---|
28 | </xs:element> |
---|
29 | <xs:element name="CMD_Component" type="CMD_Component_type"> |
---|
30 | <xs:annotation> |
---|
31 | <xs:documentation>At the root level there should always be a |
---|
32 | Component.</xs:documentation> |
---|
33 | </xs:annotation> |
---|
34 | </xs:element> |
---|
35 | </xs:sequence> |
---|
36 | <xs:attribute name="isProfile" type="xs:boolean" use="required"/> |
---|
37 | </xs:complexType> |
---|
38 | </xs:element> |
---|
39 | |
---|
40 | <!-- recursive construction: A component can contain elements and/or other components --> |
---|
41 | <xs:group name="group"> |
---|
42 | <xs:annotation> |
---|
43 | <xs:appinfo> |
---|
44 | <sch:pattern id="c_sibs"> |
---|
45 | <sch:title>Check siblings</sch:title> |
---|
46 | <sch:rule context="CMD_Component|CMD_Element"> |
---|
47 | <sch:assert test="empty(preceding-sibling::*[@name=current()/@name])">Sibling components or elements should all have a different name. Found multiple components or elements named '<sch:value-of select="@name"/>'!</sch:assert> |
---|
48 | </sch:rule> |
---|
49 | </sch:pattern> |
---|
50 | <sch:pattern id="c_csibs"> |
---|
51 | <sch:title>Check component siblings</sch:title> |
---|
52 | <sch:rule context="CMD_Component"> |
---|
53 | <sch:assert test="empty(preceding-sibling::CMD_Component[@ComponentId=current()/@ComponentId])">Sibling components should all be different. Found multiple components with id '<sch:value-of select="@ComponentId"/>'!</sch:assert> |
---|
54 | </sch:rule> |
---|
55 | </sch:pattern> |
---|
56 | <!-- TODO: the names of referenced external components are not known, so we can't currently check two or more of them use the same name --> |
---|
57 | <sch:pattern id="c_nest"> |
---|
58 | <sch:title>Check nesting</sch:title> |
---|
59 | <sch:rule context="CMD_Component[exists(CMD_Component|CMD_Element)]" role="warning"> |
---|
60 | <sch:assert test="empty((CMD_Component|CMD_Element)[@name=current()/@name])">A nested component or element has the same name ('<sch:value-of select="@name"/>') as this component! Please, consider to rename one of them.</sch:assert> |
---|
61 | </sch:rule> |
---|
62 | </sch:pattern> |
---|
63 | </xs:appinfo> |
---|
64 | </xs:annotation> |
---|
65 | <xs:sequence> |
---|
66 | <!-- from small (attribute) to big (component) --> |
---|
67 | <xs:element name="AttributeList" type="AttributeList_type" minOccurs="0" maxOccurs="1"/> |
---|
68 | <xs:element name="CMD_Element" type="CMD_Element_type" minOccurs="0" |
---|
69 | maxOccurs="unbounded"> </xs:element> |
---|
70 | <xs:element name="CMD_Component" type="CMD_Component_type" minOccurs="0" |
---|
71 | maxOccurs="unbounded"/> |
---|
72 | </xs:sequence> |
---|
73 | </xs:group> |
---|
74 | |
---|
75 | <!-- type definitions --> |
---|
76 | <xs:complexType name="CMD_Element_type"> |
---|
77 | <xs:sequence> |
---|
78 | <xs:element name="AttributeList" type="AttributeList_type" minOccurs="0" maxOccurs="1"> |
---|
79 | <xs:annotation> |
---|
80 | <xs:documentation>The AttributeList child of an element contains a set of XML |
---|
81 | attributes for that element.</xs:documentation> |
---|
82 | </xs:annotation> |
---|
83 | </xs:element> |
---|
84 | <xs:element minOccurs="0" maxOccurs="1" name="ValueScheme" type="ValueScheme_type"> |
---|
85 | <xs:annotation> |
---|
86 | <xs:documentation>When an element is linked to a regular expression or a |
---|
87 | controlled vocabulary, the ValueScheme sub-element contains more information |
---|
88 | about this.</xs:documentation> |
---|
89 | </xs:annotation> |
---|
90 | </xs:element> |
---|
91 | </xs:sequence> |
---|
92 | <xs:attributeGroup ref="clarin_element_attributes"/> |
---|
93 | </xs:complexType> |
---|
94 | |
---|
95 | |
---|
96 | <xs:complexType name="ValueScheme_type"> |
---|
97 | <xs:choice> |
---|
98 | <xs:element name="pattern" type="xs:string" maxOccurs="1"> |
---|
99 | <xs:annotation> |
---|
100 | <xs:documentation>Specification of a regular expression the element should |
---|
101 | comply with.</xs:documentation> |
---|
102 | </xs:annotation> |
---|
103 | </xs:element> |
---|
104 | <xs:element name="enumeration" type="enumeration_type"> |
---|
105 | <xs:annotation> |
---|
106 | <xs:documentation>A list of the allowed values of a controlled |
---|
107 | vocabulary.</xs:documentation> |
---|
108 | </xs:annotation> |
---|
109 | </xs:element> |
---|
110 | </xs:choice> |
---|
111 | </xs:complexType> |
---|
112 | |
---|
113 | |
---|
114 | <xs:complexType name="AttributeList_type"> |
---|
115 | <xs:sequence> |
---|
116 | <xs:element name="Attribute" minOccurs="1" maxOccurs="unbounded"> |
---|
117 | <xs:annotation> |
---|
118 | <xs:appinfo> |
---|
119 | <sch:pattern id="a_res"> |
---|
120 | <sch:title>Check reserved attribute names</sch:title> |
---|
121 | <sch:rule context="Attribute"> |
---|
122 | <sch:assert test="not(Name=('ref','ComponentId'))">Attribute name shouldn't be 'ref' or 'ComponentId', as these are used internally by CMD!</sch:assert> |
---|
123 | </sch:rule> |
---|
124 | </sch:pattern> |
---|
125 | <sch:pattern id="a_sibs"> |
---|
126 | <sch:title>Check attribute siblings</sch:title> |
---|
127 | <sch:rule context="Attribute"> |
---|
128 | <sch:assert test="empty(preceding-sibling::Attribute[Name=current()/Name])">All attributes in an attribute list should have a different name. Found multiple attributes named '<sch:value-of select="Name"/>'!</sch:assert> |
---|
129 | </sch:rule> |
---|
130 | </sch:pattern> |
---|
131 | <sch:pattern id="a_nest"> |
---|
132 | <sch:title>Check attribute nesting</sch:title> |
---|
133 | <sch:rule context="Attribute" role="warning"> |
---|
134 | <sch:assert test="empty((ancestor::CMD_Component|ancestor::CMD_Element)[1][@name=current()/Name])">An attribute has the same name ('<sch:value-of select="Name"/>') as its element or component! Please, consider to rename one of them.</sch:assert> |
---|
135 | </sch:rule> |
---|
136 | </sch:pattern> |
---|
137 | </xs:appinfo> |
---|
138 | </xs:annotation> |
---|
139 | <xs:complexType> |
---|
140 | <xs:sequence> |
---|
141 | <xs:element name="Name" type="xs:string"> |
---|
142 | <xs:annotation> |
---|
143 | <xs:documentation>The name of the attribute.</xs:documentation> |
---|
144 | </xs:annotation> |
---|
145 | </xs:element> |
---|
146 | <xs:element name="ConceptLink" type="xs:anyURI" minOccurs="0"> |
---|
147 | <xs:annotation> |
---|
148 | <xs:documentation>A link to the ISOcat data category registry (or any other concept registry).</xs:documentation> |
---|
149 | </xs:annotation> |
---|
150 | </xs:element> |
---|
151 | <xs:choice> |
---|
152 | <xs:element name="Type" type="allowed_attributetypes_type"> |
---|
153 | <xs:annotation> |
---|
154 | <xs:documentation>For the use of simple XML types as the type of |
---|
155 | the attribute.</xs:documentation> |
---|
156 | </xs:annotation> |
---|
157 | </xs:element> |
---|
158 | <xs:element name="ValueScheme" type="ValueScheme_type"> |
---|
159 | <xs:annotation> |
---|
160 | <xs:documentation>For the use of a regular expression or a |
---|
161 | controlled vocabulary as the type of the |
---|
162 | attribute.</xs:documentation> |
---|
163 | </xs:annotation> |
---|
164 | </xs:element> |
---|
165 | </xs:choice> |
---|
166 | </xs:sequence> |
---|
167 | </xs:complexType> |
---|
168 | </xs:element> |
---|
169 | </xs:sequence> |
---|
170 | </xs:complexType> |
---|
171 | |
---|
172 | <xs:complexType name="CMD_Component_type"> |
---|
173 | <xs:group ref="group" minOccurs="0"/> |
---|
174 | <xs:attributeGroup ref="clarin_component_attributes"/> |
---|
175 | </xs:complexType> |
---|
176 | |
---|
177 | |
---|
178 | <!-- list of all attributes that can be bound to a cl_el --> |
---|
179 | <xs:attributeGroup name="clarin_element_attributes"> |
---|
180 | <xs:attribute name="name" type="xs:Name" use="required"> |
---|
181 | <xs:annotation> |
---|
182 | <xs:documentation>The name of the element.</xs:documentation> |
---|
183 | </xs:annotation> |
---|
184 | </xs:attribute> |
---|
185 | <xs:attribute name="ConceptLink" type="xs:anyURI"> |
---|
186 | <xs:annotation> |
---|
187 | <xs:documentation>A link to the ISOcat data category registry (or any other concept |
---|
188 | registry).</xs:documentation> |
---|
189 | </xs:annotation> |
---|
190 | </xs:attribute> |
---|
191 | <xs:attribute name="ValueScheme" type="allowed_attributetypes_type"> |
---|
192 | <xs:annotation> |
---|
193 | <xs:documentation>Used to specify that an element has a simple XML type (string, |
---|
194 | integer, etc)</xs:documentation> |
---|
195 | </xs:annotation> |
---|
196 | </xs:attribute> |
---|
197 | <xs:attribute name="CardinalityMin" type="cardinality_type"> |
---|
198 | <xs:annotation> |
---|
199 | <xs:documentation>Minimal number of occurrences.</xs:documentation> |
---|
200 | </xs:annotation> |
---|
201 | </xs:attribute> |
---|
202 | <xs:attribute name="CardinalityMax" type="cardinality_type"> |
---|
203 | <xs:annotation> |
---|
204 | <xs:documentation>Maximal number of occurrences.</xs:documentation> |
---|
205 | </xs:annotation> |
---|
206 | </xs:attribute> |
---|
207 | <xs:attribute name="Documentation" type="xs:string"> |
---|
208 | <xs:annotation> |
---|
209 | <xs:documentation>Some information an application (eg Arbil) can display to give |
---|
210 | guidance to the user when entering metadata.</xs:documentation> |
---|
211 | </xs:annotation> |
---|
212 | </xs:attribute> |
---|
213 | <xs:attribute name="DisplayPriority" type="xs:integer"> |
---|
214 | <xs:annotation> |
---|
215 | <xs:documentation>The element with the highest priority will be displayed as the |
---|
216 | label for a metadata file (eg in Arbil)</xs:documentation> |
---|
217 | </xs:annotation> |
---|
218 | </xs:attribute> |
---|
219 | <xs:attribute name="Multilingual" type="xs:boolean"> |
---|
220 | <xs:annotation> |
---|
221 | <xs:documentation>Indicates that this element can have values in multiple languages |
---|
222 | (and thus is repeatable). This will result in the possibility of using the |
---|
223 | xml:lang attribute in the metadata instances that are |
---|
224 | created.</xs:documentation> |
---|
225 | </xs:annotation> |
---|
226 | </xs:attribute> |
---|
227 | </xs:attributeGroup> |
---|
228 | |
---|
229 | <!-- list of all attributes that can be bound to a cl_comp --> |
---|
230 | <xs:attributeGroup name="clarin_component_attributes"> |
---|
231 | <xs:attribute name="name" type="xs:Name"/> |
---|
232 | <xs:attribute name="ComponentId" type="xs:anyURI"> |
---|
233 | <xs:annotation> |
---|
234 | <xs:documentation>Indicates that a component (using its unique ComponentId issued by |
---|
235 | the ComponentRegistry) should be included.</xs:documentation> |
---|
236 | </xs:annotation> |
---|
237 | </xs:attribute> |
---|
238 | <xs:attribute name="ConceptLink" type="xs:anyURI"> |
---|
239 | <xs:annotation> |
---|
240 | <xs:documentation>A link to the ISOcat data category registry (or any other concept |
---|
241 | registry). Currently not used.</xs:documentation> |
---|
242 | </xs:annotation> |
---|
243 | </xs:attribute> |
---|
244 | <xs:attribute name="filename" type="xs:anyURI"> |
---|
245 | <xs:annotation> |
---|
246 | <xs:documentation>Outdated way of including an external component. Here for backward |
---|
247 | compatibility with the XML-cmdi-toolkit.</xs:documentation> |
---|
248 | </xs:annotation> |
---|
249 | </xs:attribute> |
---|
250 | |
---|
251 | <!-- (components cannot have a ValueScheme attribute) --> |
---|
252 | |
---|
253 | <xs:attribute name="CardinalityMin" type="cardinality_type"/> |
---|
254 | <xs:attribute name="CardinalityMax" type="cardinality_type"/> |
---|
255 | <xs:attribute ref="xml:base"/> |
---|
256 | </xs:attributeGroup> |
---|
257 | |
---|
258 | |
---|
259 | <xs:simpleType name="cardinality_type"> |
---|
260 | <xs:annotation> |
---|
261 | <xs:documentation>cardinality for elements and components</xs:documentation> |
---|
262 | <xs:appinfo> |
---|
263 | <sch:pattern id="c_card"> |
---|
264 | <sch:title>Check cardinalities</sch:title> |
---|
265 | <!-- |
---|
266 | case minimum maximum check |
---|
267 | 1 UNK UNK OK |
---|
268 | 2 UNK number maximum ne 0 |
---|
269 | 3 UNK unbounded OK |
---|
270 | 4 number UNK minimum le 1 |
---|
271 | 5 number number minimum le maximum |
---|
272 | 6 number unbounded OK |
---|
273 | 7 unbounded UNK NOK |
---|
274 | 8 unbounded number NOK |
---|
275 | 9 unbounded unbounded OK |
---|
276 | |
---|
277 | UNK can be either a missing attribute or an empty value, both can be detected with normalize-space(@...)='' |
---|
278 | |
---|
279 | default CardinalityMin is 1 (based on the XSD minOccurs default value) |
---|
280 | default CardinalityMax is 1 (based on the XSD maxOccurs default value) |
---|
281 | |
---|
282 | If a basic XSLT 2.0 engine, like Saxon HE, is used for Schematron validation we can't cast to xs:nonNegativeInteger. |
---|
283 | So we cast to xs:integer. The XSD validator should have already validated that the values are valid cardinality_types. |
---|
284 | --> |
---|
285 | <!-- skip case 1 --> |
---|
286 | <!-- case 2 --> |
---|
287 | <sch:rule context="*[(normalize-space(@CardinalityMin)='')][@CardinalityMax castable as xs:integer]"> |
---|
288 | <sch:assert test="xs:integer(@CardinalityMax) ne 0">Maximum cardinality (0) cannot be lower than the default minimum cardinality (1)!</sch:assert> |
---|
289 | </sch:rule> |
---|
290 | <!-- skip case 3 --> |
---|
291 | <!-- case 4 --> |
---|
292 | <sch:rule context="*[@CardinalityMin castable as xs:integer][normalize-space(@CardinalityMax)='']"> |
---|
293 | <sch:assert test="xs:integer(@CardinalityMin) le 1">Minimum cardinality (<sch:value-of select="@CardinalityMin"/>) should be lower or equal then the default maximum cardinality (1)!</sch:assert> |
---|
294 | </sch:rule> |
---|
295 | <!-- case 5 --> |
---|
296 | <sch:rule context="*[@CardinalityMin castable as xs:integer][@CardinalityMax castable as xs:integer]"> |
---|
297 | <sch:assert test="xs:integer(@CardinalityMin) le xs:integer(@CardinalityMax)">Minimum cardinality (<sch:value-of select="@CardinalityMin"/>) should be lower or equal then the maximum cardinality (<sch:value-of select="@CardinalityMax"/>)!</sch:assert> |
---|
298 | </sch:rule> |
---|
299 | <!-- skip case 6 --> |
---|
300 | <!-- case 7, 8 and 9 --> |
---|
301 | <sch:rule context="*[@CardinalityMin='unbounded']"> |
---|
302 | <!-- case 7 and 8 --> |
---|
303 | <sch:assert test="@CardinalityMax='unbounded'">Minimum cardinality (unbounded) can't be higher than the (default) maximum cardinality (<sch:value-of select="if (normalize-space(@CardinalityMax)='') then ('1') else (@CardinalityMax)"/>)!</sch:assert> |
---|
304 | <!-- skip case 9 --> |
---|
305 | </sch:rule> |
---|
306 | </sch:pattern> |
---|
307 | </xs:appinfo> |
---|
308 | </xs:annotation> |
---|
309 | <xs:union> |
---|
310 | <xs:simpleType> |
---|
311 | <xs:list itemType="xs:nonNegativeInteger"/> |
---|
312 | </xs:simpleType> |
---|
313 | <xs:simpleType> |
---|
314 | <xs:restriction base="xs:string"> |
---|
315 | <xs:enumeration value="unbounded"/> |
---|
316 | </xs:restriction> |
---|
317 | </xs:simpleType> |
---|
318 | </xs:union> |
---|
319 | </xs:simpleType> |
---|
320 | |
---|
321 | <xs:simpleType name="allowed_attributetypes_type"> |
---|
322 | <xs:annotation> |
---|
323 | <xs:documentation>Subset of XSD types that are allowed as CMD type</xs:documentation> |
---|
324 | </xs:annotation> |
---|
325 | |
---|
326 | <xs:restriction base="xs:token"> |
---|
327 | <xs:enumeration value="boolean"/> |
---|
328 | <xs:enumeration value="decimal"/> |
---|
329 | <xs:enumeration value="float"/> |
---|
330 | <xs:enumeration value="int"/> |
---|
331 | <xs:enumeration value="string"/> |
---|
332 | <xs:enumeration value="anyURI"/> |
---|
333 | <xs:enumeration value="date"/> |
---|
334 | <xs:enumeration value="gDay"/> |
---|
335 | <xs:enumeration value="gMonth"/> |
---|
336 | <xs:enumeration value="gYear"/> |
---|
337 | <xs:enumeration value="time"/> |
---|
338 | <xs:enumeration value="dateTime"/> |
---|
339 | </xs:restriction> |
---|
340 | </xs:simpleType> |
---|
341 | |
---|
342 | <xs:complexType name="enumeration_type"> |
---|
343 | <xs:annotation> |
---|
344 | <xs:documentation>controlled vocabularies</xs:documentation> |
---|
345 | </xs:annotation> |
---|
346 | <xs:choice minOccurs="0" maxOccurs="unbounded"> |
---|
347 | <xs:element name="item" type="item_type"> |
---|
348 | <xs:annotation> |
---|
349 | <xs:documentation>An item from a controlled vocabulary.</xs:documentation> |
---|
350 | </xs:annotation> |
---|
351 | </xs:element> |
---|
352 | <xs:element name="appinfo" type="xs:string"> |
---|
353 | <xs:annotation> |
---|
354 | <xs:documentation>End-user guidance about the value of the controlled vocabulary |
---|
355 | as a whole. Currently not used.</xs:documentation> |
---|
356 | </xs:annotation> |
---|
357 | </xs:element> |
---|
358 | </xs:choice> |
---|
359 | </xs:complexType> |
---|
360 | |
---|
361 | <xs:complexType name="item_type"> |
---|
362 | <xs:annotation> |
---|
363 | <xs:appinfo> |
---|
364 | <sch:pattern id="item"> |
---|
365 | <sch:title>CMD enumeration item</sch:title> |
---|
366 | <sch:rule context="item"> |
---|
367 | <sch:assert test="empty(preceding-sibling::item[.=current()])">All items in an enumeration should be different. Found multiple items with value '<sch:value-of select="."/>'!</sch:assert> |
---|
368 | </sch:rule> |
---|
369 | </sch:pattern> |
---|
370 | </xs:appinfo> |
---|
371 | </xs:annotation> |
---|
372 | <xs:simpleContent> |
---|
373 | <xs:extension base="xs:string"> |
---|
374 | <xs:attribute type="xs:anyURI" name="ConceptLink"> |
---|
375 | <xs:annotation> |
---|
376 | <xs:documentation>A link to the ISOcat data category registry (or any other |
---|
377 | concept registry) related to this controllec vocabulary |
---|
378 | item.</xs:documentation> |
---|
379 | </xs:annotation> |
---|
380 | </xs:attribute> |
---|
381 | <xs:attribute type="xs:string" name="AppInfo"> |
---|
382 | <xs:annotation> |
---|
383 | <xs:documentation>End-user guidance about the value of this controlled |
---|
384 | vocabulary item.</xs:documentation> |
---|
385 | </xs:annotation> |
---|
386 | </xs:attribute> |
---|
387 | </xs:extension> |
---|
388 | </xs:simpleContent> |
---|
389 | </xs:complexType> |
---|
390 | |
---|
391 | </xs:schema> |
---|