Changeset 6854 for metadata


Ignore:
Timestamp:
11/30/15 14:28:22 (8 years ago)
Author:
Menzo Windhouwer
Message:

M toolkit/src/main/resources/toolkit/xsd/cmd-component.xsd

  • cleanup of enumeration_type, it now allows an optional appinfo followed by a sequence of items
  • made cardinality/occurence indicators explicit

M toolkit/src/main/resources/toolkit/xslt/comp2schema.xsl

  • removed some debug statements

A|M toolkit/src/test*

  • added test for required attributes
  • added test for invalid component
Location:
metadata/trunk/toolkit/src
Files:
5 added
3 edited

Legend:

Unmodified
Added
Removed
  • metadata/trunk/toolkit/src/main/resources/toolkit/xsd/cmd-component.xsd

    r6255 r6854  
    3535                    <xs:complexType>
    3636                        <xs:sequence>
    37                             <xs:element name="ID" type="xs:anyURI" minOccurs="0"/>
    38                             <xs:element name="Name" type="xs:string" minOccurs="0"/>
    39                             <xs:element name="Description" type="xs:string" minOccurs="0"/>
     37                            <xs:element name="ID" type="xs:anyURI" minOccurs="0" maxOccurs="1"/>
     38                            <xs:element name="Name" type="xs:string" minOccurs="1" maxOccurs="1"/>
     39                            <xs:element name="Description" type="xs:string" minOccurs="0" maxOccurs="1"/>
    4040                            <!-- status information -->
    4141                            <xs:element name="Status" minOccurs="1" maxOccurs="1">
     
    5555                <xs:element name="Component" type="Component_type">
    5656                    <xs:annotation>
    57                         <xs:documentation>At the root level there should always be a
    58                         Component.</xs:documentation>
     57                        <xs:documentation>At the root level there should always be a Component.</xs:documentation>
    5958                    </xs:annotation>
    6059                </xs:element>
     
    9392            <!-- from small (attribute) to big (component) -->
    9493            <xs:element name="AttributeList" type="AttributeList_type" minOccurs="0" maxOccurs="1"/>
    95             <xs:element name="Element" type="Element_type" minOccurs="0"
    96                 maxOccurs="unbounded"> </xs:element>
    97             <xs:element name="Component" type="Component_type" minOccurs="0"
    98                 maxOccurs="unbounded"/>
     94            <xs:element name="Element" type="Element_type" minOccurs="0" maxOccurs="unbounded"/>
     95            <xs:element name="Component" type="Component_type" minOccurs="0" maxOccurs="unbounded"/>
    9996        </xs:sequence>
    10097    </xs:group>
     
    164161        </xs:annotation>
    165162        <xs:choice>
    166             <xs:element name="pattern" type="xs:string" maxOccurs="1">
     163            <xs:element name="pattern" type="xs:string" minOccurs="1" maxOccurs="1">
    167164                <xs:annotation>
    168165                    <xs:documentation>Specification of a regular expression the element should
     
    170167                </xs:annotation>
    171168            </xs:element>
    172             <xs:element name="Vocabulary" type="Vocabulary_type">
     169            <xs:element name="Vocabulary" type="Vocabulary_type" minOccurs="1" maxOccurs="1">
    173170                <xs:annotation>
    174171                    <xs:documentation>Specification of an open or closed vocabulary</xs:documentation>
     
    186183            </xs:element>
    187184        </xs:sequence>
    188         <xs:attribute name="URI" type="xs:anyURI"/>
     185        <xs:attribute name="URI" type="xs:anyURI" use="optional"/>
    189186        <!-- optionally selects a label -->
    190         <xs:attribute name="ValueProperty" type="xs:string"/>
     187        <xs:attribute name="ValueProperty" type="xs:string" use="optional"/>
    191188        <!-- optionally selects a language -->
    192         <xs:attribute name="ValueLanguage" type="xs:language"/>
     189        <xs:attribute name="ValueLanguage" type="xs:language" use="optional"/>
    193190    </xs:complexType>
    194191
     
    231228                    <xs:sequence>
    232229                        <xs:element name="Documentation" type="Documentation_type" minOccurs="0" maxOccurs="unbounded"/>
    233                         <xs:element name="ValueScheme" type="ValueScheme_type" minOccurs="0">
     230                        <xs:element name="ValueScheme" type="ValueScheme_type" minOccurs="0" maxOccurs="1">
    234231                            <xs:annotation>
    235232                                <xs:documentation>For the use of a regular expression or a
     
    257254            </xs:annotation>
    258255        </xs:attribute>
    259         <xs:attribute name="ConceptLink" type="xs:anyURI">
     256        <xs:attribute name="ConceptLink" type="xs:anyURI" use="optional">
    260257            <xs:annotation>
    261258                <xs:documentation>A link to the ISOcat data category registry (or any other concept
     
    263260            </xs:annotation>
    264261        </xs:attribute>
    265         <xs:attribute name="ValueScheme" type="allowed_attributetypes_type">
     262        <xs:attribute name="ValueScheme" type="allowed_attributetypes_type" use="optional">
    266263            <xs:annotation>
    267264                <xs:documentation>For the use of simple XML types as the type of
     
    269266            </xs:annotation>
    270267        </xs:attribute>
    271         <xs:attribute name="Required" type="xs:boolean">
     268        <xs:attribute name="Required" type="xs:boolean" use="optional">
    272269            <xs:annotation>
    273270                <xs:documentation>Is the attribute required or not?</xs:documentation>
     
    283280            </xs:annotation>
    284281        </xs:attribute>
    285         <xs:attribute name="ConceptLink" type="xs:anyURI">
     282        <xs:attribute name="ConceptLink" type="xs:anyURI" use="optional">
    286283            <xs:annotation>
    287284                <xs:documentation>A link to the ISOcat data category registry (or any other concept
     
    289286            </xs:annotation>
    290287        </xs:attribute>
    291         <xs:attribute name="ValueScheme" type="allowed_attributetypes_type">
     288        <xs:attribute name="ValueScheme" type="allowed_attributetypes_type" use="optional">
    292289            <xs:annotation>
    293290                <xs:documentation>Used to specify that an element has a simple XML type (string,
     
    295292            </xs:annotation>
    296293        </xs:attribute>
    297         <xs:attribute name="CardinalityMin" type="cardinality_type">
     294        <xs:attribute name="CardinalityMin" type="cardinality_type" use="optional" default="1">
    298295            <xs:annotation>
    299296                <xs:documentation>Minimal number of occurrences.</xs:documentation>
    300297            </xs:annotation>
    301298        </xs:attribute>
    302         <xs:attribute name="CardinalityMax" type="cardinality_type">
     299        <xs:attribute name="CardinalityMax" type="cardinality_type" use="optional" default="1">
    303300            <xs:annotation>
    304301                <xs:documentation>Maximal number of occurrences.</xs:documentation>
    305302            </xs:annotation>
    306303        </xs:attribute>
    307         <xs:attribute name="Multilingual" type="xs:boolean">
     304        <xs:attribute name="Multilingual" type="xs:boolean" use="optional">
    308305            <xs:annotation>
    309306                <xs:documentation>Indicates that this element can have values in multiple languages
     
    317314
    318315    <xs:attributeGroup name="component_attributes">
    319         <xs:attribute name="name" type="xs:Name"/>
    320         <xs:attribute name="ComponentId" type="xs:anyURI">
     316        <xs:annotation>
     317            <xs:appinfo>
     318                <sch:pattern id="c_atts">
     319                    <sch:title>Check component attributes</sch:title>
     320                    <sch:rule context="Component">
     321                        <sch:assert test="normalize-space(@name)!='' or normalize-space(@ComponentId)!=''">A Component should have a name or a ComponentId!</sch:assert>
     322                    </sch:rule>
     323                </sch:pattern>
     324            </xs:appinfo>
     325        </xs:annotation>
     326        <xs:attribute name="name" type="xs:Name" use="optional"/>
     327        <xs:attribute name="ComponentId" type="xs:anyURI" use="optional">
    321328            <xs:annotation>
    322329                <xs:documentation>Indicates that a component (using its unique ComponentId issued by
     
    324331            </xs:annotation>
    325332        </xs:attribute>
    326         <xs:attribute name="ConceptLink" type="xs:anyURI">
     333        <xs:attribute name="ConceptLink" type="xs:anyURI" use="optional">
    327334            <xs:annotation>
    328335                <xs:documentation>A link to the ISOcat data category registry (or any other concept
     
    330337            </xs:annotation>
    331338        </xs:attribute>
    332         <xs:attribute name="CardinalityMin" type="cardinality_type"/>
    333         <xs:attribute name="CardinalityMax" type="cardinality_type"/>
    334         <xs:attribute ref="xml:base"/>
     339        <xs:attribute name="CardinalityMin" type="cardinality_type" use="optional" default="1"/>
     340        <xs:attribute name="CardinalityMax" type="cardinality_type" use="optional" default="1"/>
     341        <xs:attribute ref="xml:base" use="optional"/>
    335342        <xs:anyAttribute namespace="http://www.clarin.eu/cmdi/cues/display/1.0" processContents="lax"/>
    336343    </xs:attributeGroup>
     
    424431            <xs:documentation>controlled vocabularies</xs:documentation>
    425432        </xs:annotation>
    426         <xs:choice minOccurs="0" maxOccurs="unbounded">
    427             <xs:element name="item" type="item_type">
    428                 <xs:annotation>
    429                     <xs:documentation>An item from a controlled vocabulary.</xs:documentation>
    430                 </xs:annotation>
    431             </xs:element>
    432             <xs:element name="appinfo" type="xs:string">
     433        <xs:sequence>
     434            <xs:element name="appinfo" type="xs:string" minOccurs="0" maxOccurs="1">
    433435                <xs:annotation>
    434436                    <xs:documentation>End-user guidance about the value of the controlled vocabulary
     
    436438                </xs:annotation>
    437439            </xs:element>
    438         </xs:choice>
     440            <xs:element name="item" type="item_type" minOccurs="0" maxOccurs="unbounded">
     441                <xs:annotation>
     442                    <xs:documentation>An item from a controlled vocabulary.</xs:documentation>
     443                </xs:annotation>
     444            </xs:element>
     445        </xs:sequence>
    439446    </xs:complexType>
    440447
     
    452459        <xs:simpleContent>
    453460            <xs:extension base="xs:string">
    454                 <xs:attribute type="xs:anyURI" name="ConceptLink">
     461                <xs:attribute type="xs:anyURI" name="ConceptLink" use="optional">
    455462                    <xs:annotation>
    456463                        <xs:documentation>A link to the ISOcat data category registry (or any other
     
    459466                    </xs:annotation>
    460467                </xs:attribute>
    461                 <xs:attribute type="xs:string" name="AppInfo">
     468                <xs:attribute type="xs:string" name="AppInfo" use="optional">
    462469                    <xs:annotation>
    463470                        <xs:documentation>End-user guidance about the value of this controlled
  • metadata/trunk/toolkit/src/main/resources/toolkit/xslt/comp2schema.xsl

    r6833 r6854  
    135135    <xsl:template match="Element/ValueScheme[exists(Vocabulary/enumeration)]" mode="types">
    136136       
    137         <xsl:message>DBG: create complex types</xsl:message>
    138        
    139137        <!-- only handle the ValueScheme if this is the first occurence of the Component -->
    140138        <xsl:variable name="Component" select="ancestor::Component[exists(@ComponentId)]"/>
    141139        <xsl:if test="empty($Component/preceding::Component[@ComponentId=$Component/@ComponentId])">
    142             <xsl:message>DBG: first occurence</xsl:message>
    143140           
    144141            <!-- create a unique suffix (the path to the element) to ensure the unicity of the types to be created -->
  • metadata/trunk/toolkit/src/test/java/eu/clarin/cmd/toolkit/TestCMDToolkit.java

    r6262 r6854  
    197197
    198198    @Test
     199    public void testAdelheid2() throws Exception {
     200        String profile = "/toolkit/Adelheid/profiles/clarin.eu:cr1:p_1311927752306_1_2.xml";
     201        String record  = "/toolkit/Adelheid/records/Adelheid_1_2-invalid.cmdi";
     202       
     203        // validate the 1.2 profile
     204        boolean validProfile = validateCMDSpec(profile,new javax.xml.transform.stream.StreamSource(new java.io.File(TestCMDToolkit.class.getResource(profile).toURI())));
     205       
     206        // assertions
     207        // the upgraded profile should be a valid CMDI 1.2 profile
     208        assertTrue(validProfile);
     209        // so there should be no errors
     210        assertEquals(0, countErrors(validateCMDSpec));
     211       
     212        Document profileSchema = transformCMDSpecInXSD(profile,new javax.xml.transform.stream.StreamSource(new java.io.File(TestCMDToolkit.class.getResource(profile).toURI())));
     213        SchemAnon profileAnon = new SchemAnon(new DOMSource(profileSchema));
     214       
     215        // validate the 1.2 record
     216        boolean validRecord = validateCMDRecord(profile,profileAnon,record,new javax.xml.transform.stream.StreamSource(new java.io.File(TestCMDToolkit.class.getResource(record).toURI())));
     217       
     218        // assertions
     219        // the record should be a invalid as it misses a the required CoreVersion attribute
     220        assertFalse(validRecord);
     221    }
     222
     223    @Test
    199224    public void testTEI() throws Exception {
    200225        String record  = "/toolkit/TEI/records/sundhed_dsn.teiHeader.ref.xml";
     
    248273        assertFalse(validRecord);
    249274    }
     275
     276    @Test
     277    public void testCMD() throws Exception {
     278        String profile = "/toolkit/CMD/profiles/components.xml";
     279
     280        // validate the 1.2 profile
     281        boolean validProfile = validateCMDSpec(profile,new javax.xml.transform.stream.StreamSource(new java.io.File(TestCMDToolkit.class.getResource(profile).toURI())));
     282
     283        // assertions
     284        assertFalse(validProfile);
     285    }
    250286}
Note: See TracChangeset for help on using the changeset viewer.