source: metadata/branches/cmdi-1.1/toolkit/general-component-schema.xsd @ 6909

Last change on this file since 6909 was 6909, checked in by Menzo Windhouwer, 9 years ago

M toolkit/general-component-schema.xsd

  • removed the a_nest Schematron rule, which was checking a best practice.
  • 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: 19.2 KB
Line 
1<?xml version="1.0" encoding="UTF-8"?>
2<!--
3    $Revision: 6909 $
4    $Date: 2016-01-14 13:06:02 +0000 (Thu, 14 Jan 2016) $
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            </xs:appinfo>           
58        </xs:annotation>
59        <xs:sequence>
60            <!-- from small (attribute) to big (component) -->
61            <xs:element name="AttributeList" type="AttributeList_type" minOccurs="0" maxOccurs="1"/>
62            <xs:element name="CMD_Element" type="CMD_Element_type" minOccurs="0"
63                maxOccurs="unbounded"> </xs:element>
64            <xs:element name="CMD_Component" type="CMD_Component_type" minOccurs="0"
65                maxOccurs="unbounded"/>
66        </xs:sequence>
67    </xs:group>
68
69    <!-- type definitions -->
70    <xs:complexType name="CMD_Element_type">
71        <xs:sequence>
72            <xs:element name="AttributeList" type="AttributeList_type" minOccurs="0" maxOccurs="1">
73                <xs:annotation>
74                    <xs:documentation>The AttributeList child of an element contains a set of XML
75                        attributes for that element.</xs:documentation>
76                </xs:annotation>
77            </xs:element>
78            <xs:element minOccurs="0" maxOccurs="1" name="ValueScheme" type="ValueScheme_type">
79                <xs:annotation>
80                    <xs:documentation>When an element is linked to a regular expression or a
81                        controlled vocabulary, the ValueScheme sub-element contains more information
82                        about this.</xs:documentation>
83                </xs:annotation>
84            </xs:element>
85        </xs:sequence>
86        <xs:attributeGroup ref="clarin_element_attributes"/>
87    </xs:complexType>
88
89
90    <xs:complexType name="ValueScheme_type">
91        <xs:choice>
92            <xs:element name="pattern" type="xs:string" maxOccurs="1">
93                <xs:annotation>
94                    <xs:documentation>Specification of a regular expression the element should
95                        comply with.</xs:documentation>
96                </xs:annotation>
97            </xs:element>
98            <xs:element name="enumeration" type="enumeration_type">
99                <xs:annotation>
100                    <xs:documentation>A list of the allowed values of a controlled
101                    vocabulary.</xs:documentation>
102                </xs:annotation>
103            </xs:element>
104        </xs:choice>
105    </xs:complexType>
106
107
108    <xs:complexType name="AttributeList_type">
109        <xs:sequence>
110            <xs:element name="Attribute" minOccurs="1" maxOccurs="unbounded">
111                <xs:annotation>
112                    <xs:appinfo>
113                        <sch:pattern id="a_res">
114                            <sch:title>Check reserved attribute names</sch:title>
115                            <sch:rule context="Attribute">
116                                <sch:assert test="not(exists(parent::AttributeList/parent::Component) and Name=('ref','ComponentId'))">Component attribute name shouldn't be 'ref' or 'ComponentId', as these are used internally by CMD!</sch:assert>
117                            </sch:rule>
118                        </sch:pattern>
119                        <sch:pattern id="a_sibs">
120                            <sch:title>Check attribute siblings</sch:title>
121                            <sch:rule context="Attribute">
122                                <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>
123                            </sch:rule>
124                        </sch:pattern>
125                    </xs:appinfo>           
126                </xs:annotation>
127                <xs:complexType>
128                    <xs:sequence>
129                        <xs:element name="Name" type="xs:string">
130                            <xs:annotation>
131                                <xs:documentation>The name of the attribute.</xs:documentation>
132                            </xs:annotation>
133                        </xs:element>
134                        <xs:element name="ConceptLink" type="xs:anyURI" minOccurs="0">
135                            <xs:annotation>
136                                <xs:documentation>A link to the ISOcat data category registry (or any other concept registry).</xs:documentation>
137                            </xs:annotation>
138                        </xs:element>
139                        <xs:choice>
140                            <xs:element name="Type" type="allowed_attributetypes_type">
141                                <xs:annotation>
142                                    <xs:documentation>For the use of simple XML types as the type of
143                                        the attribute.</xs:documentation>
144                                </xs:annotation>
145                            </xs:element>
146                            <xs:element name="ValueScheme" type="ValueScheme_type">
147                                <xs:annotation>
148                                    <xs:documentation>For the use of a regular expression or a
149                                        controlled vocabulary as the type of the
150                                    attribute.</xs:documentation>
151                                </xs:annotation>
152                            </xs:element>
153                        </xs:choice>
154                    </xs:sequence>
155                </xs:complexType>
156            </xs:element>
157        </xs:sequence>
158    </xs:complexType>
159
160    <xs:complexType name="CMD_Component_type">
161        <xs:group ref="group" minOccurs="0"/>
162        <xs:attributeGroup ref="clarin_component_attributes"/>
163    </xs:complexType>
164
165
166    <!-- list of all attributes that can be bound to a cl_el -->
167    <xs:attributeGroup name="clarin_element_attributes">
168        <xs:attribute name="name" type="xs:Name" use="required">
169            <xs:annotation>
170                <xs:documentation>The name of the element.</xs:documentation>
171            </xs:annotation>
172        </xs:attribute>
173        <xs:attribute name="ConceptLink" type="xs:anyURI">
174            <xs:annotation>
175                <xs:documentation>A link to the ISOcat data category registry (or any other concept
176                    registry).</xs:documentation>
177            </xs:annotation>
178        </xs:attribute>
179        <xs:attribute name="ValueScheme" type="allowed_attributetypes_type">
180            <xs:annotation>
181                <xs:documentation>Used to specify that an element has a simple XML type (string,
182                    integer, etc)</xs:documentation>
183            </xs:annotation>
184        </xs:attribute>
185        <xs:attribute name="CardinalityMin" type="cardinality_type">
186            <xs:annotation>
187                <xs:documentation>Minimal number of occurrences.</xs:documentation>
188            </xs:annotation>
189        </xs:attribute>
190        <xs:attribute name="CardinalityMax" type="cardinality_type">
191            <xs:annotation>
192                <xs:documentation>Maximal number of occurrences.</xs:documentation>
193            </xs:annotation>
194        </xs:attribute>
195        <xs:attribute name="Documentation" type="xs:string">
196            <xs:annotation>
197                <xs:documentation>Some information an application (eg Arbil) can display to give
198                    guidance to the user when entering metadata.</xs:documentation>
199            </xs:annotation>
200        </xs:attribute>
201        <xs:attribute name="DisplayPriority" type="xs:integer">
202            <xs:annotation>
203                <xs:documentation>The element with the highest priority will be displayed as the
204                    label for a metadata file (eg in Arbil)</xs:documentation>
205            </xs:annotation>
206        </xs:attribute>
207        <xs:attribute name="Multilingual" type="xs:boolean">
208            <xs:annotation>
209                <xs:documentation>Indicates that this element can have values in multiple languages
210                    (and thus is repeatable). This will result in the possibility of using the
211                    xml:lang attribute in the metadata instances that are
212                created.</xs:documentation>
213            </xs:annotation>
214        </xs:attribute>
215    </xs:attributeGroup>
216
217    <!-- list of all attributes that can be bound to a cl_comp -->
218    <xs:attributeGroup name="clarin_component_attributes">
219        <xs:attribute name="name" type="xs:Name"/>
220        <xs:attribute name="ComponentId" type="xs:anyURI">
221            <xs:annotation>
222                <xs:documentation>Indicates that a component (using its unique ComponentId issued by
223                    the ComponentRegistry) should be included.</xs:documentation>
224            </xs:annotation>
225        </xs:attribute>
226        <xs:attribute name="ConceptLink" type="xs:anyURI">
227            <xs:annotation>
228                <xs:documentation>A link to the ISOcat data category registry (or any other concept
229                    registry). Currently not used.</xs:documentation>
230            </xs:annotation>
231        </xs:attribute>
232        <xs:attribute name="filename" type="xs:anyURI">
233            <xs:annotation>
234                <xs:documentation>Outdated way of including an external component. Here for backward
235                    compatibility with the XML-cmdi-toolkit.</xs:documentation>
236            </xs:annotation>
237        </xs:attribute>
238
239        <!-- (components cannot have a ValueScheme attribute) -->
240
241        <xs:attribute name="CardinalityMin" type="cardinality_type"/>
242        <xs:attribute name="CardinalityMax" type="cardinality_type"/>
243        <xs:attribute ref="xml:base"/>
244    </xs:attributeGroup>
245
246
247    <xs:simpleType name="cardinality_type">
248        <xs:annotation>
249            <xs:documentation>cardinality for elements and components</xs:documentation>
250            <xs:appinfo>
251                <sch:pattern id="c_card">
252                    <sch:title>Check cardinalities</sch:title>
253                    <!--
254                        case minimum   maximum   check
255                        1    UNK       UNK       OK
256                        2    UNK       number    maximum ne 0
257                        3    UNK       unbounded OK
258                        4    number    UNK       minimum le 1
259                        5    number    number    minimum le maximum
260                        6    number    unbounded OK
261                        7    unbounded UNK       NOK
262                        8    unbounded number    NOK
263                        9    unbounded unbounded OK
264                       
265                        UNK can be either a missing attribute or an empty value, both can be detected with normalize-space(@...)=''
266                       
267                        default CardinalityMin is 1 (based on the XSD minOccurs default value)
268                        default CardinalityMax is 1 (based on the XSD maxOccurs default value)
269                       
270                        If a basic XSLT 2.0 engine, like Saxon HE, is used for Schematron validation we can't cast to xs:nonNegativeInteger.
271                        So we cast to xs:integer. The XSD validator should have already validated that the values are valid cardinality_types.
272                    -->
273                    <!-- skip case 1 -->
274                    <!-- case 2 -->
275                    <sch:rule context="*[(normalize-space(@CardinalityMin)='')][@CardinalityMax castable as xs:integer]">
276                        <sch:assert test="xs:integer(@CardinalityMax) ne 0">Maximum cardinality (0) cannot be lower than the default minimum cardinality (1)!</sch:assert>
277                    </sch:rule>
278                    <!-- skip case 3 -->
279                    <!-- case 4 -->
280                    <sch:rule context="*[@CardinalityMin castable as xs:integer][normalize-space(@CardinalityMax)='']">
281                        <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>
282                    </sch:rule>
283                    <!-- case 5 -->
284                    <sch:rule context="*[@CardinalityMin castable as xs:integer][@CardinalityMax castable as xs:integer]">
285                        <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>
286                    </sch:rule>
287                    <!-- skip case 6 -->
288                    <!-- case 7, 8 and 9 -->
289                    <sch:rule context="*[@CardinalityMin='unbounded']">
290                        <!-- case 7 and 8 -->
291                        <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>
292                        <!-- skip case 9 -->
293                    </sch:rule>
294                </sch:pattern>
295            </xs:appinfo>
296        </xs:annotation>
297        <xs:union>
298            <xs:simpleType>
299                <xs:list itemType="xs:nonNegativeInteger"/>
300            </xs:simpleType>
301            <xs:simpleType>
302                <xs:restriction base="xs:string">
303                    <xs:enumeration value="unbounded"/>
304                </xs:restriction>
305            </xs:simpleType>
306        </xs:union>
307    </xs:simpleType>
308
309    <xs:simpleType name="allowed_attributetypes_type">
310        <xs:annotation>
311            <xs:documentation>Subset of XSD types that are allowed as CMD type</xs:documentation>
312        </xs:annotation>
313
314        <xs:restriction base="xs:token">
315            <xs:enumeration value="boolean"/>
316            <xs:enumeration value="decimal"/>
317            <xs:enumeration value="float"/>
318            <xs:enumeration value="int"/>
319            <xs:enumeration value="string"/>
320            <xs:enumeration value="anyURI"/>
321            <xs:enumeration value="date"/>
322            <xs:enumeration value="gDay"/>
323            <xs:enumeration value="gMonth"/>
324            <xs:enumeration value="gYear"/>
325            <xs:enumeration value="time"/>
326            <xs:enumeration value="dateTime"/>
327        </xs:restriction>
328    </xs:simpleType>
329
330    <xs:complexType name="enumeration_type">
331        <xs:annotation>
332            <xs:documentation>controlled vocabularies</xs:documentation>
333        </xs:annotation>
334        <xs:choice minOccurs="0" maxOccurs="unbounded">
335            <xs:element name="item" type="item_type">
336                <xs:annotation>
337                    <xs:documentation>An item from a controlled vocabulary.</xs:documentation>
338                </xs:annotation>
339            </xs:element>
340            <xs:element name="appinfo" type="xs:string">
341                <xs:annotation>
342                    <xs:documentation>End-user guidance about the value of the controlled vocabulary
343                        as a whole. Currently not used.</xs:documentation>
344                </xs:annotation>
345            </xs:element>
346        </xs:choice>
347    </xs:complexType>
348
349    <xs:complexType name="item_type">
350        <xs:annotation>
351            <xs:appinfo>
352                <sch:pattern id="item">
353                    <sch:title>CMD enumeration item</sch:title>
354                    <sch:rule context="item">
355                        <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>
356                    </sch:rule>
357                </sch:pattern>
358            </xs:appinfo>           
359        </xs:annotation>
360        <xs:simpleContent>
361            <xs:extension base="xs:string">
362                <xs:attribute type="xs:anyURI" name="ConceptLink">
363                    <xs:annotation>
364                        <xs:documentation>A link to the ISOcat data category registry (or any other
365                            concept registry) related to this controllec vocabulary
366                        item.</xs:documentation>
367                    </xs:annotation>
368                </xs:attribute>
369                <xs:attribute type="xs:string" name="AppInfo">
370                    <xs:annotation>
371                        <xs:documentation>End-user guidance about the value of this controlled
372                            vocabulary item.</xs:documentation>
373                    </xs:annotation>
374                </xs:attribute>
375            </xs:extension>
376        </xs:simpleContent>
377    </xs:complexType>
378
379</xs:schema>
Note: See TracBrowser for help on using the repository browser.