source: ComponentRegistry/trunk/CMDValidate/src/test/resources/schema/general-component-schema.xsd @ 2011

Last change on this file since 2011 was 2011, checked in by mwindhouwer, 12 years ago

pom.xml:

  • [Twan] removed the dependency on the parent POM

TestCMDValidate.java:

  • added test for the new Schematron warnings on 'child' components/elements/attributes with the same name as the parent

CLARINWebService_warn-8.xml:

  • triggers the new Schematron warnings

general-component-schema.xsd:

  • rearranged Schematron rules a bit
  • added rules to check if a nested component/element/attribute has the same name as its parent
File size: 16.3 KB
Line 
1<?xml version="1.0" encoding="UTF-8"?>
2<!--
3    $Revision: 1816 $
4    $Date: 2010-06-24 11:36:11 +0200 (Thu, 24 Jun 2010) $
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" name="Check siblings">
41                    <sch:rule context="CMD_Component|CMD_Element">
42                        <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>
43                    </sch:rule>
44                </sch:pattern>
45                <sch:pattern id="c_nest" name="Check nesting">
46                    <sch:rule context="CMD_Component[exists(CMD_Component|CMD_Element)]" role="warning">
47                        <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>
48                    </sch:rule>
49                </sch:pattern>
50            </xs:appinfo>           
51        </xs:annotation>
52        <xs:sequence>
53            <!-- from small (attribute) to big (component) -->
54            <xs:element name="AttributeList" type="AttributeList_type" minOccurs="0" maxOccurs="1"/>
55            <xs:element name="CMD_Element" type="CMD_Element_type" minOccurs="0"
56                maxOccurs="unbounded"> </xs:element>
57            <xs:element name="CMD_Component" type="CMD_Component_type" minOccurs="0"
58                maxOccurs="unbounded"/>
59        </xs:sequence>
60    </xs:group>
61
62    <!-- type definitions -->
63    <xs:complexType name="CMD_Element_type">
64        <xs:sequence>
65            <xs:element name="AttributeList" type="AttributeList_type" minOccurs="0" maxOccurs="1">
66                <xs:annotation>
67                    <xs:documentation>The AttributeList child of an element contains a set of XML
68                        attributes for that element.</xs:documentation>
69                </xs:annotation>
70            </xs:element>
71            <xs:element minOccurs="0" maxOccurs="1" name="ValueScheme" type="ValueScheme_type">
72                <xs:annotation>
73                    <xs:documentation>When an element is linked to a regular expression or a
74                        controlled vocabulary, the ValueScheme sub-element contains more information
75                        about this.</xs:documentation>
76                </xs:annotation>
77            </xs:element>
78        </xs:sequence>
79        <xs:attributeGroup ref="clarin_element_attributes"/>
80    </xs:complexType>
81
82
83    <xs:complexType name="ValueScheme_type">
84        <xs:choice>
85            <xs:element name="pattern" type="xs:string" maxOccurs="1">
86                <xs:annotation>
87                    <xs:documentation>Specification of a regular expression the element should
88                        comply with.</xs:documentation>
89                </xs:annotation>
90            </xs:element>
91            <xs:element name="enumeration" type="enumeration_type">
92                <xs:annotation>
93                    <xs:documentation>A list of the allowed values of a controlled
94                    vocabulary.</xs:documentation>
95                </xs:annotation>
96            </xs:element>
97        </xs:choice>
98    </xs:complexType>
99
100
101    <xs:complexType name="AttributeList_type">
102        <xs:sequence>
103            <xs:element name="Attribute" minOccurs="1" maxOccurs="unbounded">
104                <xs:annotation>
105                    <xs:appinfo>
106                        <sch:pattern id="a_res" name="Check reserved attribute names">
107                            <sch:rule context="Attribute">
108                                <sch:assert test="not(Name=('ref','ComponentId'))">Attribute name shouldn't be 'ref' or 'ComponentId', as these are used internally by CMD!</sch:assert>
109                            </sch:rule>
110                        </sch:pattern>
111                        <sch:pattern id="a_sibs" name="Check attribute siblings">
112                            <sch:rule context="Attribute">
113                                <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>
114                            </sch:rule>
115                        </sch:pattern>
116                        <sch:pattern id="a_nest" name="Check attribute nesting">
117                            <sch:rule context="Attribute" role="warning">
118                                <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>
119                            </sch:rule>
120                        </sch:pattern>
121                    </xs:appinfo>           
122                </xs:annotation>
123                <xs:complexType>
124                    <xs:sequence>
125                        <xs:element name="Name" type="xs:string">
126                            <xs:annotation>
127                                <xs:documentation>The name of the attribute.</xs:documentation>
128                            </xs:annotation>
129                        </xs:element>
130                        <xs:element name="ConceptLink" type="xs:anyURI" minOccurs="0">
131                            <xs:annotation>
132                                <xs:documentation>A link to the ISOcat data category registry (or any other concept registry).</xs:documentation>
133                            </xs:annotation>
134                        </xs:element>
135                        <xs:choice>
136                            <xs:element name="Type" type="allowed_attributetypes_type">
137                                <xs:annotation>
138                                    <xs:documentation>For the use of simple XML types as the type of
139                                        the attribute.</xs:documentation>
140                                </xs:annotation>
141                            </xs:element>
142                            <xs:element name="ValueScheme" type="ValueScheme_type">
143                                <xs:annotation>
144                                    <xs:documentation>For the use of a regular expression or a
145                                        controlled vocabulary as the type of the
146                                    attribute.</xs:documentation>
147                                </xs:annotation>
148                            </xs:element>
149                        </xs:choice>
150                        <xs:element name="Required" type="xs:boolean" default="false" minOccurs="0">
151                            <xs:annotation>
152                                <xs:documentation>Is the attribute required or not.</xs:documentation>
153                            </xs:annotation>
154                        </xs:element>
155                    </xs:sequence>
156                </xs:complexType>
157            </xs:element>
158        </xs:sequence>
159    </xs:complexType>
160
161    <xs:complexType name="CMD_Component_type">
162        <xs:group ref="group" minOccurs="0"/>
163        <xs:attributeGroup ref="clarin_component_attributes"/>
164    </xs:complexType>
165
166
167    <!-- list of all attributes that can be bound to a cl_el -->
168    <xs:attributeGroup name="clarin_element_attributes">
169        <xs:attribute name="name" type="xs:Name" use="required">
170            <xs:annotation>
171                <xs:documentation>The name of the element.</xs:documentation>
172            </xs:annotation>
173        </xs:attribute>
174        <xs:attribute name="ConceptLink" type="xs:anyURI">
175            <xs:annotation>
176                <xs:documentation>A link to the ISOcat data category registry (or any other concept
177                    registry).</xs:documentation>
178            </xs:annotation>
179        </xs:attribute>
180        <xs:attribute name="ValueScheme" type="allowed_attributetypes_type">
181            <xs:annotation>
182                <xs:documentation>Used to specify that an element has a simple XML type (string,
183                    integer, etc)</xs:documentation>
184            </xs:annotation>
185        </xs:attribute>
186        <xs:attribute name="CardinalityMin" type="cardinality_type">
187            <xs:annotation>
188                <xs:documentation>Minimal number of occurrences.</xs:documentation>
189            </xs:annotation>
190        </xs:attribute>
191        <xs:attribute name="CardinalityMax" type="cardinality_type">
192            <xs:annotation>
193                <xs:documentation>Maximal number of occurrences.</xs:documentation>
194            </xs:annotation>
195        </xs:attribute>
196        <xs:attribute name="Documentation" type="xs:string">
197            <xs:annotation>
198                <xs:documentation>Some information an application (eg Arbil) can display to give
199                    guidance to the user when entering metadata.</xs:documentation>
200            </xs:annotation>
201        </xs:attribute>
202        <xs:attribute name="DisplayPriority" type="xs:integer">
203            <xs:annotation>
204                <xs:documentation>The element with the highest priority will be displayed as the
205                    label for a metadata file (eg in Arbil)</xs:documentation>
206            </xs:annotation>
207        </xs:attribute>
208        <xs:attribute name="Multilingual" type="xs:boolean">
209            <xs:annotation>
210                <xs:documentation>Indicates that this element can have values in multiple languages
211                    (and thus is repeatable). This will result in the possibility of using the
212                    xml:lang attribute in the metadata instances that are
213                created.</xs:documentation>
214            </xs:annotation>
215        </xs:attribute>
216    </xs:attributeGroup>
217
218    <!-- list of all attributes that can be bound to a cl_comp -->
219    <xs:attributeGroup name="clarin_component_attributes">
220        <xs:attribute name="name" type="xs:Name"/>
221        <xs:attribute name="ComponentId" type="xs:anyURI">
222            <xs:annotation>
223                <xs:documentation>Indicates that a component (using its unique ComponentId issued by
224                    the ComponentRegistry) should be included.</xs:documentation>
225            </xs:annotation>
226        </xs:attribute>
227        <xs:attribute name="ConceptLink" type="xs:anyURI">
228            <xs:annotation>
229                <xs:documentation>A link to the ISOcat data category registry (or any other concept
230                    registry). Currently not used.</xs:documentation>
231            </xs:annotation>
232        </xs:attribute>
233        <xs:attribute name="filename" type="xs:anyURI">
234            <xs:annotation>
235                <xs:documentation>Outdated way of including an external component. Here for backward
236                    compatibility with the XML-cmdi-toolkit.</xs:documentation>
237            </xs:annotation>
238        </xs:attribute>
239
240        <!-- (components cannot have a ValueScheme attribute) -->
241
242        <xs:attribute name="CardinalityMin" type="cardinality_type"/>
243        <xs:attribute name="CardinalityMax" type="cardinality_type"/>
244        <xs:attribute ref="xml:base"/>
245    </xs:attributeGroup>
246
247
248    <xs:simpleType name="cardinality_type">
249        <xs:annotation>
250            <xs:documentation>cardinality for elements and components</xs:documentation>
251        </xs:annotation>
252        <xs:union>
253            <xs:simpleType>
254                <xs:list itemType="xs:nonNegativeInteger"/>
255            </xs:simpleType>
256            <xs:simpleType>
257                <xs:restriction base="xs:string">
258                    <xs:enumeration value="unbounded"/>
259                </xs:restriction>
260            </xs:simpleType>
261        </xs:union>
262    </xs:simpleType>
263
264    <xs:simpleType name="allowed_attributetypes_type">
265        <xs:annotation>
266            <xs:documentation>Subset of XSD types that are allowed as CMD type</xs:documentation>
267        </xs:annotation>
268
269        <xs:restriction base="xs:token">
270            <xs:enumeration value="boolean"/>
271            <xs:enumeration value="decimal"/>
272            <xs:enumeration value="float"/>
273            <xs:enumeration value="string"/>
274            <xs:enumeration value="anyURI"/>
275            <xs:enumeration value="date"/>
276            <xs:enumeration value="gDay"/>
277            <xs:enumeration value="gMonth"/>
278            <xs:enumeration value="gYear"/>
279            <xs:enumeration value="time"/>
280            <xs:enumeration value="dateTime"/>
281        </xs:restriction>
282    </xs:simpleType>
283
284    <xs:complexType name="enumeration_type">
285        <xs:annotation>
286            <xs:documentation>controlled vocabularies</xs:documentation>
287        </xs:annotation>
288        <xs:choice minOccurs="0" maxOccurs="unbounded">
289            <xs:element name="item" type="item_type">
290                <xs:annotation>
291                    <xs:documentation>An item from a controlled vocabulary.</xs:documentation>
292                </xs:annotation>
293            </xs:element>
294            <xs:element name="appinfo" type="xs:string">
295                <xs:annotation>
296                    <xs:documentation>End-user guidance about the value of the controlled vocabulary
297                        as a whole. Currently not used.</xs:documentation>
298                </xs:annotation>
299            </xs:element>
300        </xs:choice>
301    </xs:complexType>
302
303    <xs:complexType name="item_type">
304        <xs:annotation>
305            <xs:appinfo>
306                <sch:pattern id="item" name="CMD enumeration item">
307                    <sch:rule context="item">
308                        <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>
309                    </sch:rule>
310                </sch:pattern>
311            </xs:appinfo>           
312        </xs:annotation>
313        <xs:simpleContent>
314            <xs:extension base="xs:string">
315                <xs:attribute type="xs:anyURI" name="ConceptLink">
316                    <xs:annotation>
317                        <xs:documentation>A link to the ISOcat data category registry (or any other
318                            concept registry) related to this controllec vocabulary
319                        item.</xs:documentation>
320                    </xs:annotation>
321                </xs:attribute>
322                <xs:attribute type="xs:string" name="AppInfo">
323                    <xs:annotation>
324                        <xs:documentation>End-user guidance about the value of this controlled
325                            vocabulary item.</xs:documentation>
326                    </xs:annotation>
327                </xs:attribute>
328            </xs:extension>
329        </xs:simpleContent>
330    </xs:complexType>
331
332</xs:schema>
Note: See TracBrowser for help on using the repository browser.