Changeset 4525 for metadata


Ignore:
Timestamp:
02/17/14 11:01:30 (10 years ago)
Author:
mwindhouwer
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • metadata/trunk/toolkit/general-component-schema.xsd

    r3893 r4525  
    55-->
    66
    7 <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
     7<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:sch="http://purl.oclc.org/dsdl/schematron">
     8   
    89    <xs:import namespace="http://www.w3.org/XML/1998/namespace"
    910        schemaLocation="http://www.w3.org/2005/08/xml.xsd"/>
     
    2223                    </xs:complexType>
    2324                </xs:element>
    24                 <xs:element name="CMD_Component" type="CMD_Component_type" maxOccurs="unbounded">
     25                <xs:element name="CMD_Component" type="CMD_Component_type">
    2526                    <xs:annotation>
    2627                        <xs:documentation>At the root level there should always be a
     
    3536    <!-- recursive construction: A component can contain elements and/or other components  -->
    3637    <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>
    3761        <xs:sequence>
    3862            <!-- from small (attribute) to big (component) -->
     
    87111        <xs:sequence>
    88112            <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>
    89135                <xs:complexType>
    90136                    <xs:sequence>
     
    264310
    265311    <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>
    266322        <xs:simpleContent>
    267323            <xs:extension base="xs:string">
Note: See TracChangeset for help on using the changeset viewer.