Changeset 4524


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

M src/test/resources/schema/general-component-schema.xsd

  • added a Schematron rule to test if there are no multiple references to the same component among siblings

A src/test/resources/docs/CLARINWebService_faulty-9.xml
M src/test/java/clarin/cmdi/schema/cmd/TestCMDValidate.java

  • added test on faulty document with a double component reference
Location:
ComponentRegistry/trunk/CMDValidate/src/test
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • ComponentRegistry/trunk/CMDValidate/src/test/java/clarin/cmdi/schema/cmd/TestCMDValidate.java

    r2011 r4524  
    158158        assertEquals("An attribute has the same name ('Service') as its element or component! Please, consider to rename one of them.",message.text);
    159159    }
     160
     161    @Test
     162    public void invalid_9() throws Exception {
     163        assertFalse(validate("CLARINWebService_faulty-9.xml"));
     164
     165        final List<Message> messages = cmdValidator.getMessages();
     166        assertEquals(1, messages.size());
     167        Message message = messages.get(0);
     168        assertTrue(message.error);
     169        assertEquals("/CMD_ComponentSpec[1]/CMD_Component[1]/CMD_Component[1]/CMD_Component[2]/CMD_Component[1]/CMD_Component[2]/CMD_Component[3]", message.location);
     170        assertEquals("empty(preceding-sibling::CMD_Component[@ComponentId=current()/@ComponentId])", message.test);
     171        assertNotNull(message.text);
     172    }
     173
    160174}
  • ComponentRegistry/trunk/CMDValidate/src/test/resources/schema/general-component-schema.xsd

    r4098 r4524  
    3838        <xs:annotation>
    3939            <xs:appinfo>
    40                 <sch:pattern id="c_sibs" name="Check siblings">
     40                <sch:pattern id="c_sibs">
     41                    <sch:title>Check siblings</sch:title>
    4142                    <sch:rule context="CMD_Component|CMD_Element">
    4243                        <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>
    4344                    </sch:rule>
    4445                </sch:pattern>
    45                 <sch:pattern id="c_nest" name="Check nesting">
     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>
    4655                    <sch:rule context="CMD_Component[exists(CMD_Component|CMD_Element)]" role="warning">
    4756                        <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>
     
    104113                <xs:annotation>
    105114                    <xs:appinfo>
    106                         <sch:pattern id="a_res" name="Check reserved attribute names">
     115                        <sch:pattern id="a_res">
     116                            <sch:title>Check reserved attribute names</sch:title>
    107117                            <sch:rule context="Attribute">
    108118                                <sch:assert test="not(Name=('ref','ComponentId'))">Attribute name shouldn't be 'ref' or 'ComponentId', as these are used internally by CMD!</sch:assert>
    109119                            </sch:rule>
    110120                        </sch:pattern>
    111                         <sch:pattern id="a_sibs" name="Check attribute siblings">
     121                        <sch:pattern id="a_sibs">
     122                            <sch:title>Check attribute siblings</sch:title>
    112123                            <sch:rule context="Attribute">
    113124                                <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>
    114125                            </sch:rule>
    115126                        </sch:pattern>
    116                         <sch:pattern id="a_nest" name="Check attribute nesting">
     127                        <sch:pattern id="a_nest">
     128                            <sch:title>Check attribute nesting</sch:title>
    117129                            <sch:rule context="Attribute" role="warning">
    118130                                <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>
     
    305317        <xs:annotation>
    306318            <xs:appinfo>
    307                 <sch:pattern id="item" name="CMD enumeration item">
     319                <sch:pattern id="item">
     320                    <sch:title>CMD enumeration item</sch:title>
    308321                    <sch:rule context="item">
    309322                        <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>
Note: See TracChangeset for help on using the changeset viewer.