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

Last change on this file since 4525 was 4525, checked in by mwindhouwer, 10 years ago

M general-component-schema.xsd

  • only one root component is allowed
  • added schematron rules

-- to check for ambiguous siblings
-- reserved CMDI attributes
-- warn for possibly confusing nesting

  • 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: 16.8 KB
Line 
1<?xml version="1.0" encoding="UTF-8"?>
2<!--
3    $Revision: 4525 $
4    $Date: 2014-02-17 11:01:30 +0000 (Mon, 17 Feb 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:annotation>
259        <xs:union>
260            <xs:simpleType>
261                <xs:list itemType="xs:nonNegativeInteger"/>
262            </xs:simpleType>
263            <xs:simpleType>
264                <xs:restriction base="xs:string">
265                    <xs:enumeration value="unbounded"/>
266                </xs:restriction>
267            </xs:simpleType>
268        </xs:union>
269    </xs:simpleType>
270
271    <xs:simpleType name="allowed_attributetypes_type">
272        <xs:annotation>
273            <xs:documentation>Subset of XSD types that are allowed as CMD type</xs:documentation>
274        </xs:annotation>
275
276        <xs:restriction base="xs:token">
277            <xs:enumeration value="boolean"/>
278            <xs:enumeration value="decimal"/>
279            <xs:enumeration value="float"/>
280            <xs:enumeration value="int"/>
281            <xs:enumeration value="string"/>
282            <xs:enumeration value="anyURI"/>
283            <xs:enumeration value="date"/>
284            <xs:enumeration value="gDay"/>
285            <xs:enumeration value="gMonth"/>
286            <xs:enumeration value="gYear"/>
287            <xs:enumeration value="time"/>
288            <xs:enumeration value="dateTime"/>
289        </xs:restriction>
290    </xs:simpleType>
291
292    <xs:complexType name="enumeration_type">
293        <xs:annotation>
294            <xs:documentation>controlled vocabularies</xs:documentation>
295        </xs:annotation>
296        <xs:choice minOccurs="0" maxOccurs="unbounded">
297            <xs:element name="item" type="item_type">
298                <xs:annotation>
299                    <xs:documentation>An item from a controlled vocabulary.</xs:documentation>
300                </xs:annotation>
301            </xs:element>
302            <xs:element name="appinfo" type="xs:string">
303                <xs:annotation>
304                    <xs:documentation>End-user guidance about the value of the controlled vocabulary
305                        as a whole. Currently not used.</xs:documentation>
306                </xs:annotation>
307            </xs:element>
308        </xs:choice>
309    </xs:complexType>
310
311    <xs:complexType name="item_type">
312        <xs:annotation>
313            <xs:appinfo>
314                <sch:pattern id="item">
315                    <sch:title>CMD enumeration item</sch:title>
316                    <sch:rule context="item">
317                        <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>
318                    </sch:rule>
319                </sch:pattern>
320            </xs:appinfo>           
321        </xs:annotation>
322        <xs:simpleContent>
323            <xs:extension base="xs:string">
324                <xs:attribute type="xs:anyURI" name="ConceptLink">
325                    <xs:annotation>
326                        <xs:documentation>A link to the ISOcat data category registry (or any other
327                            concept registry) related to this controllec vocabulary
328                        item.</xs:documentation>
329                    </xs:annotation>
330                </xs:attribute>
331                <xs:attribute type="xs:string" name="AppInfo">
332                    <xs:annotation>
333                        <xs:documentation>End-user guidance about the value of this controlled
334                            vocabulary item.</xs:documentation>
335                    </xs:annotation>
336                </xs:attribute>
337            </xs:extension>
338        </xs:simpleContent>
339    </xs:complexType>
340
341</xs:schema>
Note: See TracBrowser for help on using the repository browser.