source: metadata/trunk/toolkit/xsd/cmd-component.xsd @ 5628

Last change on this file since 5628 was 5628, checked in by Menzo Windhouwer, 10 years ago

Refactoring the toolkit to support CMDI 1.2

  • Property svn:executable set to *
  • Property svn:keywords set to
    Rev
    Date
  • Property svn:mergeinfo set to (toggle deleted branches)
    /ComponentRegistry/branches/ComponentRegistry-1.12.0/ComponentRegistry/src/main/binding/general-component-schema.xsd2071-2124
    /ComponentRegistry/branches/ComponentRegistry-1.13.0-olha/ComponentRegistry/src/main/binding/components/general-component-schema.xsd2143-2514
    /ComponentRegistry/branches/ComponentRegistry-schematron/ComponentRegistry/src/main/binding/general-component-schema.xsd1751-1797
    /ComponentRegistry/tags/ComponentRegistry-1.8.1/ComponentRegistry/src/main/binding/general-component-schema.xsd1420-1453
    /ComponentRegistry/tags/ComponentRegistry-1.9.1/ComponentRegistry/src/main/binding/general-component-schema.xsd1565
    /ComponentRegistry/trunk/ComponentRegistry/src/main/binding/components/general-component-schema.xsd2143-2395
    /ComponentRegistry/trunk/ComponentRegistry/src/main/binding/general-component-schema.xsd17-1476
    /ComponentRegistry/trunk/ComponentRegistry/src/test/resources/clarin_catalog/general-component-schema.xsd3885-3892
File size: 24.9 KB
Line 
1<?xml version="1.0" encoding="UTF-8"?>
2<!--
3    $Revision: 5628 $
4    $Date: 2014-09-15 10:21:49 +0000 (Mon, 15 Sep 2014) $
5-->
6
7<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:sch="http://purl.oclc.org/dsdl/schematron">
8   
9    <xs:import namespace="http://www.w3.org/XML/1998/namespace"
10        schemaLocation="http://www.w3.org/2005/08/xml.xsd"/>
11
12    <!-- root element -->
13    <xs:element name="ComponentSpec">
14        <xs:annotation>
15            <xs:appinfo>
16                <sch:pattern id="h_succ">
17                    <sch:title>Check successor</sch:title>
18                    <sch:rule context="Header/Successor">
19                        <sch:assert test="../Status='deprecated'">There can only be a successor component/profile if the status of this component/profile is deprecated!</sch:assert>
20                    </sch:rule>
21                </sch:pattern>
22                <sch:pattern id="r_card">
23                    <sch:title>Cardinality root component</sch:title>
24                    <sch:rule context="ComponentSpec/Component">
25                        <sch:assert test="empty(@CardinalityMin) or @CardinalityMin='1'">The minimum cardinality of the root component should be 1!</sch:assert>
26                        <sch:assert test="empty(@CardinalityMax) or @CardinalityMax='1'">The maximum cardinality of the root component should be 1!</sch:assert>
27                    </sch:rule>
28                </sch:pattern>
29            </xs:appinfo>
30        </xs:annotation>
31        <xs:complexType>
32            <xs:sequence>
33                <xs:element name="Header">
34                    <xs:complexType>
35                        <xs:sequence>
36                            <xs:element name="ID" type="xs:anyURI" minOccurs="0"/>
37                            <xs:element name="Name" type="xs:string" minOccurs="0"/>
38                            <xs:element name="Description" type="xs:string" minOccurs="0"/>
39                            <!-- status information -->
40                            <xs:element name="Status" minOccurs="1" maxOccurs="1">
41                                <xs:simpleType>
42                                    <xs:restriction base="xs:string">
43                                        <xs:enumeration value="development"/>
44                                        <xs:enumeration value="production"/>
45                                        <xs:enumeration value="deprecated"/>
46                                    </xs:restriction>
47                                </xs:simpleType>
48                            </xs:element>
49                            <xs:element name="StatusComment" type="xs:string" minOccurs="0" maxOccurs="1"/>
50                            <xs:element name="Successor" type="xs:anyURI" minOccurs="0" maxOccurs="1"/>
51                        </xs:sequence>
52                    </xs:complexType>
53                </xs:element>
54                <xs:element name="Component" type="Component_type">
55                    <xs:annotation>
56                        <xs:documentation>At the root level there should always be a
57                        Component.</xs:documentation>
58                    </xs:annotation>
59                </xs:element>
60            </xs:sequence>
61            <xs:attribute name="isProfile" type="xs:boolean" use="required"/>
62        </xs:complexType>
63    </xs:element>
64
65    <!-- recursive construction: A component can contain elements and/or other components  -->
66    <xs:group name="group">
67        <xs:annotation>
68            <xs:appinfo>
69                <sch:pattern id="c_sibs">
70                    <sch:title>Check siblings</sch:title>
71                    <sch:rule context="Component|Element">
72                        <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>
73                    </sch:rule>
74                </sch:pattern>
75                <sch:pattern id="c_csibs">
76                    <sch:title>Check component siblings</sch:title>
77                    <sch:rule context="Component">
78                        <sch:assert test="empty(preceding-sibling::Component[@ComponentId=current()/@ComponentId])">Sibling components should all be different. Found multiple components with id '<sch:value-of select="@ComponentId"/>'!</sch:assert>
79                    </sch:rule>
80                </sch:pattern>
81                <!-- TODO: check: the names of referenced external components are not known, so we can't currently check if two or more of them use the same name -->
82                <sch:pattern id="c_nest">
83                    <sch:title>Check nesting</sch:title>
84                    <sch:rule context="Component[exists(Component|Element)]" role="warning">
85                        <sch:assert test="empty((Component|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>
86                    </sch:rule>
87                </sch:pattern>
88            </xs:appinfo>
89        </xs:annotation>
90        <xs:sequence>
91            <xs:element name="Documentation" type="Documentation_type" minOccurs="0" maxOccurs="unbounded"/>
92            <!-- from small (attribute) to big (component) -->
93            <xs:element name="AttributeList" type="AttributeList_type" minOccurs="0" maxOccurs="1"/>
94            <xs:element name="Element" type="Element_type" minOccurs="0"
95                maxOccurs="unbounded"> </xs:element>
96            <xs:element name="Component" type="Component_type" minOccurs="0"
97                maxOccurs="unbounded"/>
98        </xs:sequence>
99    </xs:group>
100
101    <!-- type definitions -->
102    <xs:complexType name="Documentation_type">
103        <xs:annotation>
104            <xs:documentation>Some information an application (eg Arbil) can display to give
105                guidance to the user when entering metadata.</xs:documentation>
106            <xs:appinfo>
107                <sch:pattern id="d_dsibs">
108                    <sch:title>Check Documentation siblings</sch:title>
109                    <sch:rule context="Documentation">
110                        <sch:assert test="empty(preceding-sibling::Documentation[@xml:lang=current()/@xml:lang])">Sibling Documentation elements should all be for different languages. Found multiple Documentation elements with xml:lang '<sch:value-of select="@xml:lang"/>'!</sch:assert>
111                    </sch:rule>
112                </sch:pattern>
113            </xs:appinfo>
114        </xs:annotation>
115        <xs:simpleContent>
116            <xs:extension base="xs:string">
117                <xs:attribute ref="xml:lang" use="optional"/>
118            </xs:extension>
119        </xs:simpleContent>
120    </xs:complexType>
121   
122    <xs:complexType name="Element_type">
123        <xs:annotation>
124            <xs:appinfo>
125                <sch:pattern id="e_vs">
126                    <sch:title>Check Element ValueScheme</sch:title>
127                    <sch:rule context="Element">
128                        <sch:assert test="exists(@ValueScheme) or exists(ValueScheme)">An Element must have either a @ValueScheme or a ./ValueScheme!</sch:assert>
129                    </sch:rule>
130                </sch:pattern>
131            </xs:appinfo>
132        </xs:annotation>
133        <xs:sequence>
134            <xs:element name="Documentation" type="Documentation_type" minOccurs="0" maxOccurs="unbounded"/>
135            <xs:element name="AttributeList" type="AttributeList_type" minOccurs="0" maxOccurs="1">
136                <xs:annotation>
137                    <xs:documentation>The AttributeList child of an element contains a set of XML
138                        attributes for that element.</xs:documentation>
139                </xs:annotation>
140            </xs:element>
141            <xs:element minOccurs="0" maxOccurs="1" name="ValueScheme" type="ValueScheme_type">
142                <xs:annotation>
143                    <xs:documentation>When an element is linked to a regular expression or a
144                        controlled vocabulary, the ValueScheme sub-element contains more information
145                        about this.</xs:documentation>
146                </xs:annotation>
147            </xs:element>
148            <xs:element name="AutoValue" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
149        </xs:sequence>
150        <xs:attributeGroup ref="element_attributes"/>
151    </xs:complexType>
152
153    <xs:complexType name="ValueScheme_type">
154        <xs:annotation>
155            <xs:appinfo>
156                <sch:pattern id="v_uri">
157                    <sch:title>Check Vocabulary URI</sch:title>
158                    <sch:rule context="Vocabulary[exists(@URI)]">
159                        <sch:assert test="exists(@ValueProperty)">When an external vocabulary (identified by the @URI) a @ValueProperty has to be specified!</sch:assert>
160                    </sch:rule>
161                </sch:pattern>
162            </xs:appinfo>
163        </xs:annotation>
164        <xs:choice>
165            <xs:element name="pattern" type="xs:string" maxOccurs="1">
166                <xs:annotation>
167                    <xs:documentation>Specification of a regular expression the element should
168                        comply with.</xs:documentation>
169                </xs:annotation>
170            </xs:element>
171            <xs:element name="Vocabulary" type="Vocabulary_type">
172                <xs:annotation>
173                    <xs:documentation>Specification of an open or closed vocabulary</xs:documentation>
174                </xs:annotation>
175            </xs:element>
176        </xs:choice>
177    </xs:complexType>
178
179    <xs:complexType name="Vocabulary_type">
180        <xs:sequence>
181            <xs:element name="enumeration" type="enumeration_type" minOccurs="0" maxOccurs="1">
182                <xs:annotation>
183                    <xs:documentation>A list of the allowed values of a controlled vocabulary.</xs:documentation>
184                </xs:annotation>
185            </xs:element>
186        </xs:sequence>
187        <xs:attribute name="URI" type="xs:anyURI"/>
188        <!-- optionally selects a label -->
189        <xs:attribute name="ValueProperty" type="xs:string"/>
190        <!-- optionally selects a language -->
191        <xs:attribute name="ValueLanguage" type="xs:language"/>
192    </xs:complexType>
193
194    <xs:complexType name="AttributeList_type">
195        <xs:annotation>
196            <xs:appinfo>
197                <sch:pattern id="a_vs">
198                    <sch:title>Check Attribute ValueScheme</sch:title>
199                    <sch:rule context="Attribute">
200                        <sch:assert test="exists(@ValueScheme) or exists(ValueScheme)">An Attribute must have either a @ValueScheme or a ./ValueScheme!</sch:assert>
201                    </sch:rule>
202                </sch:pattern>
203            </xs:appinfo>
204        </xs:annotation>
205        <xs:sequence>
206            <xs:element name="Attribute" minOccurs="1" maxOccurs="unbounded">
207                <xs:annotation>
208                    <xs:appinfo>
209                        <sch:pattern id="a_res">
210                            <sch:title>Check reserved attribute names</sch:title>
211                            <sch:rule context="Attribute">
212                                <sch:assert test="not(@name=('ref','ComponentId'))">Attribute name shouldn't be 'ref' or 'ComponentId', as these are used internally by CMD!</sch:assert>
213                            </sch:rule>
214                        </sch:pattern>
215                        <sch:pattern id="a_sibs">
216                            <sch:title>Check attribute siblings</sch:title>
217                            <sch:rule context="Attribute">
218                                <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>
219                            </sch:rule>
220                        </sch:pattern>
221                        <sch:pattern id="a_nest">
222                            <sch:title>Check attribute nesting</sch:title>
223                            <sch:rule context="Attribute" role="warning">
224                                <sch:assert test="empty((ancestor::Component|ancestor::Element)[1][@name=current()/@ame])">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>
225                            </sch:rule>
226                        </sch:pattern>
227                    </xs:appinfo>
228                </xs:annotation>
229                <xs:complexType>
230                    <xs:sequence>
231                        <xs:element name="Documentation" type="Documentation_type" minOccurs="0" maxOccurs="unbounded"/>
232                        <xs:element name="ValueScheme" type="ValueScheme_type" minOccurs="0">
233                            <xs:annotation>
234                                <xs:documentation>For the use of a regular expression or a
235                                    controlled vocabulary as the type of the
236                                    attribute.</xs:documentation>
237                            </xs:annotation>
238                        </xs:element>
239                        <xs:element name="AutoValue" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
240                    </xs:sequence>
241                    <xs:attributeGroup ref="attribute_attributes"/>
242                </xs:complexType>
243            </xs:element>
244        </xs:sequence>
245    </xs:complexType>
246
247    <xs:complexType name="Component_type">
248        <xs:group ref="group" minOccurs="0"/>
249        <xs:attributeGroup ref="component_attributes"/>
250    </xs:complexType>
251
252    <xs:attributeGroup name="attribute_attributes">
253        <xs:attribute name="name" type="xs:Name" use="required">
254            <xs:annotation>
255                <xs:documentation>The name of the attribute.</xs:documentation>
256            </xs:annotation>
257        </xs:attribute>
258        <xs:attribute name="ConceptLink" type="xs:anyURI">
259            <xs:annotation>
260                <xs:documentation>A link to the ISOcat data category registry (or any other concept
261                    registry).</xs:documentation>
262            </xs:annotation>
263        </xs:attribute>
264        <xs:attribute name="ValueScheme" type="allowed_attributetypes_type">
265            <xs:annotation>
266                <xs:documentation>For the use of simple XML types as the type of
267                    the attribute.</xs:documentation>
268            </xs:annotation>
269        </xs:attribute>
270        <xs:attribute name="Required" type="xs:boolean">
271            <xs:annotation>
272                <xs:documentation>Is the attribute required or not?</xs:documentation>
273            </xs:annotation>
274        </xs:attribute>
275        <xs:anyAttribute namespace="http://www.clarin.eu/cmdi/cues/display/1.0" processContents="lax"/>
276    </xs:attributeGroup>
277   
278    <xs:attributeGroup name="element_attributes">
279        <xs:attribute name="name" type="xs:Name" use="required">
280            <xs:annotation>
281                <xs:documentation>The name of the element.</xs:documentation>
282            </xs:annotation>
283        </xs:attribute>
284        <xs:attribute name="ConceptLink" type="xs:anyURI">
285            <xs:annotation>
286                <xs:documentation>A link to the ISOcat data category registry (or any other concept
287                    registry).</xs:documentation>
288            </xs:annotation>
289        </xs:attribute>
290        <xs:attribute name="ValueScheme" type="allowed_attributetypes_type">
291            <xs:annotation>
292                <xs:documentation>Used to specify that an element has a simple XML type (string,
293                    integer, etc)</xs:documentation>
294            </xs:annotation>
295        </xs:attribute>
296        <xs:attribute name="CardinalityMin" type="cardinality_type">
297            <xs:annotation>
298                <xs:documentation>Minimal number of occurrences.</xs:documentation>
299            </xs:annotation>
300        </xs:attribute>
301        <xs:attribute name="CardinalityMax" type="cardinality_type">
302            <xs:annotation>
303                <xs:documentation>Maximal number of occurrences.</xs:documentation>
304            </xs:annotation>
305        </xs:attribute>
306        <xs:attribute name="Multilingual" type="xs:boolean">
307            <xs:annotation>
308                <xs:documentation>Indicates that this element can have values in multiple languages
309                    (and thus is repeatable). This will result in the possibility of using the
310                    xml:lang attribute in the metadata instances that are
311                created.</xs:documentation>
312            </xs:annotation>
313        </xs:attribute>
314        <xs:anyAttribute namespace="http://www.clarin.eu/cmdi/cues/display/1.0" processContents="lax"/>
315    </xs:attributeGroup>
316
317    <xs:attributeGroup name="component_attributes">
318        <xs:attribute name="name" type="xs:Name"/>
319        <xs:attribute name="ComponentId" type="xs:anyURI">
320            <xs:annotation>
321                <xs:documentation>Indicates that a component (using its unique ComponentId issued by
322                    the ComponentRegistry) should be included.</xs:documentation>
323            </xs:annotation>
324        </xs:attribute>
325        <xs:attribute name="ConceptLink" type="xs:anyURI">
326            <xs:annotation>
327                <xs:documentation>A link to the ISOcat data category registry (or any other concept
328                    registry). Currently not used.</xs:documentation>
329            </xs:annotation>
330        </xs:attribute>
331        <xs:attribute name="CardinalityMin" type="cardinality_type"/>
332        <xs:attribute name="CardinalityMax" type="cardinality_type"/>
333        <xs:attribute ref="xml:base"/>
334        <xs:anyAttribute namespace="http://www.clarin.eu/cmdi/cues/display/1.0" processContents="lax"/>
335    </xs:attributeGroup>
336
337
338    <xs:simpleType name="cardinality_type">
339        <xs:annotation>
340            <xs:documentation>cardinality for elements and components</xs:documentation>
341            <xs:appinfo>
342                <sch:pattern id="c_card">
343                    <sch:title>Check cardinalities</sch:title>
344                    <!--
345                        case minimum   maximum   check
346                        1    UNK       UNK       OK
347                        2    UNK       number    maximum ne 0
348                        3    UNK       unbounded OK
349                        4    number    UNK       minimum le 1
350                        5    number    number    minimum le maximum
351                        6    number    unbounded OK
352                        7    unbounded UNK       NOK
353                        8    unbounded number    NOK
354                        9    unbounded unbounded OK
355                       
356                        UNK can be either a missing attribute or an empty value, both can be detected with normalize-space(@...)=''
357                       
358                        default CardinalityMin is 1 (based on the XSD minOccurs default value)
359                        default CardinalityMax is 1 (based on the XSD maxOccurs default value)
360                       
361                        If a basic XSLT 2.0 engine, like Saxon HE, is used for Schematron validation we can't cast to xs:nonNegativeInteger.
362                        So we cast to xs:integer. The XSD validator should have already validated that the values are valid cardinality_types.
363                    -->
364                    <!-- skip case 1 -->
365                    <!-- case 2 -->
366                    <sch:rule context="*[(normalize-space(@CardinalityMin)='')][@CardinalityMax castable as xs:integer]">
367                        <sch:assert test="xs:integer(@CardinalityMax) ne 0">Maximum cardinality (0) cannot be lower than the default minimum cardinality (1)!</sch:assert>
368                    </sch:rule>
369                    <!-- skip case 3 -->
370                    <!-- case 4 -->
371                    <sch:rule context="*[@CardinalityMin castable as xs:integer][normalize-space(@CardinalityMax)='']">
372                        <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>
373                    </sch:rule>
374                    <!-- case 5 -->
375                    <sch:rule context="*[@CardinalityMin castable as xs:integer][@CardinalityMax castable as xs:integer]">
376                        <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>
377                    </sch:rule>
378                    <!-- skip case 6 -->
379                    <!-- case 7, 8 and 9 -->
380                    <sch:rule context="*[@CardinalityMin='unbounded']">
381                        <!-- case 7 and 8 -->
382                        <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>
383                        <!-- skip case 9 -->
384                    </sch:rule>
385                </sch:pattern>
386            </xs:appinfo>
387        </xs:annotation>
388        <xs:union>
389            <xs:simpleType>
390                <xs:list itemType="xs:nonNegativeInteger"/>
391            </xs:simpleType>
392            <xs:simpleType>
393                <xs:restriction base="xs:string">
394                    <xs:enumeration value="unbounded"/>
395                </xs:restriction>
396            </xs:simpleType>
397        </xs:union>
398    </xs:simpleType>
399
400    <xs:simpleType name="allowed_attributetypes_type">
401        <xs:annotation>
402            <xs:documentation>Subset of XSD types that are allowed as CMD type</xs:documentation>
403        </xs:annotation>
404
405        <xs:restriction base="xs:token">
406            <xs:enumeration value="boolean"/>
407            <xs:enumeration value="decimal"/>
408            <xs:enumeration value="float"/>
409            <xs:enumeration value="int"/>
410            <xs:enumeration value="string"/>
411            <xs:enumeration value="anyURI"/>
412            <xs:enumeration value="date"/>
413            <xs:enumeration value="gDay"/>
414            <xs:enumeration value="gMonth"/>
415            <xs:enumeration value="gYear"/>
416            <xs:enumeration value="time"/>
417            <xs:enumeration value="dateTime"/>
418        </xs:restriction>
419    </xs:simpleType>
420
421    <xs:complexType name="enumeration_type">
422        <xs:annotation>
423            <xs:documentation>controlled vocabularies</xs:documentation>
424        </xs:annotation>
425        <xs:choice minOccurs="0" maxOccurs="unbounded">
426            <xs:element name="item" type="item_type">
427                <xs:annotation>
428                    <xs:documentation>An item from a controlled vocabulary.</xs:documentation>
429                </xs:annotation>
430            </xs:element>
431            <xs:element name="appinfo" type="xs:string">
432                <xs:annotation>
433                    <xs:documentation>End-user guidance about the value of the controlled vocabulary
434                        as a whole. Currently not used.</xs:documentation>
435                </xs:annotation>
436            </xs:element>
437        </xs:choice>
438    </xs:complexType>
439
440    <xs:complexType name="item_type">
441        <xs:annotation>
442            <xs:appinfo>
443                <sch:pattern id="item">
444                    <sch:title>CMD enumeration item</sch:title>
445                    <sch:rule context="item">
446                        <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>
447                    </sch:rule>
448                </sch:pattern>
449            </xs:appinfo>           
450        </xs:annotation>
451        <xs:simpleContent>
452            <xs:extension base="xs:string">
453                <xs:attribute type="xs:anyURI" name="ConceptLink">
454                    <xs:annotation>
455                        <xs:documentation>A link to the ISOcat data category registry (or any other
456                            concept registry) related to this controllec vocabulary
457                        item.</xs:documentation>
458                    </xs:annotation>
459                </xs:attribute>
460                <xs:attribute type="xs:string" name="AppInfo">
461                    <xs:annotation>
462                        <xs:documentation>End-user guidance about the value of this controlled
463                            vocabulary item.</xs:documentation>
464                    </xs:annotation>
465                </xs:attribute>
466                <xs:anyAttribute namespace="http://www.clarin.eu/cmdi/cues/display/1.0" processContents="lax"/>
467            </xs:extension>
468        </xs:simpleContent>
469    </xs:complexType>
470
471</xs:schema>
Note: See TracBrowser for help on using the repository browser.