source: metadata/trunk/toolkit/general-component-schema.xsd @ 4627

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

M general-component-schema.xsd

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