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

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

M toolkit/general-component-schema.xsd

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