Changeset 2011


Ignore:
Timestamp:
07/06/12 11:00:54 (12 years ago)
Author:
mwindhouwer
Message:

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
Location:
ComponentRegistry/trunk/CMDValidate
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • ComponentRegistry/trunk/CMDValidate/pom.xml

    r2010 r2011  
    33         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    44    <modelVersion>4.0.0</modelVersion>
    5     <parent>
    6         <groupId>clarin.cmdi</groupId>
    7         <artifactId>componentRegistry.parent</artifactId>
    8         <version>1.0</version>
    9     </parent>
    105    <groupId>clarin.cmdi</groupId>
    116    <artifactId>cmd-validate</artifactId>
  • ComponentRegistry/trunk/CMDValidate/src/test/java/clarin/cmdi/schema/cmd/TestCMDValidate.java

    r1859 r2011  
    4545
    4646    @Test
    47     public void valid() throws Exception {
     47    public void valid_0() throws Exception {
    4848        assertTrue(validate("CLARINWebService.xml"));
    4949        assertEquals(0, cmdValidator.getMessages().size());
     
    140140        assertNotNull(message.text);
    141141    }
     142
     143    @Test
     144    public void valid_8() throws Exception {
     145        assertTrue(validate("CLARINWebService_warn-8.xml"));
     146
     147        final List<Message> messages = cmdValidator.getMessages();
     148        assertEquals(2, messages.size());
     149        Message message = messages.get(0);
     150        assertFalse(message.error);
     151        assertEquals("/CMD_ComponentSpec[1]/CMD_Component[1]",message.location);
     152        assertNotNull(message.test);
     153        assertEquals("A nested component or element has the same name ('Service') as this component! Please, consider to rename one of them.",message.text);
     154        message = messages.get(1);
     155        assertFalse(message.error);
     156        assertEquals("/CMD_ComponentSpec[1]/CMD_Component[1]/CMD_Component[1]/AttributeList[1]/Attribute[1]",message.location);
     157        assertNotNull(message.test);
     158        assertEquals("An attribute has the same name ('Service') as its element or component! Please, consider to rename one of them.",message.text);
     159    }
    142160}
  • ComponentRegistry/trunk/CMDValidate/src/test/resources/schema/general-component-schema.xsd

    r1877 r2011  
    3838        <xs:annotation>
    3939            <xs:appinfo>
    40                 <sch:pattern id="component" name="CMD component group">
     40                <sch:pattern id="c_sibs" name="Check siblings">
    4141                    <sch:rule context="CMD_Component|CMD_Element">
    4242                        <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>
    4348                    </sch:rule>
    4449                </sch:pattern>
     
    99104                <xs:annotation>
    100105                    <xs:appinfo>
    101                         <sch:pattern id="attribute" name="CMD attribute">
     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">
    102112                            <sch:rule context="Attribute">
    103113                                <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>
    104                                 <sch:assert test="not(Name=('ref','ComponentId'))">Attribute name shouldn't be 'ref' or 'ComponentId', as these are used internally by CMD!</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>
    105119                            </sch:rule>
    106120                        </sch:pattern>
Note: See TracChangeset for help on using the changeset viewer.