>> English << | českyZVON > Tutorials > Schematron Tutorial
>> Example 14 << | Prev | Next | Contents

Description

The element must be a child of selected elements.

Schema


<schema xmlns="http://www.ascc.net/xml/schematron" >
     <pattern name="a child of selected elements">
          <rule context="CCC">
               <assert test="parent::*[name()='BBB' or name()='DDD']">Element CCC must not be a child of element
                    <name path="parent::*"/>
               </assert>
          </rule>
     </pattern>
</schema>

Sources and outputs

Source (XML 1)Output

<AAA>
     <BBB>
          <CCC/>
     </BBB>
     <CCC/>
     <DDD>
          <CCC/>
          <EEE>
               <CCC/>
          </EEE>
     </DDD>
</AAA>
 Pattern: a child of selected elements
/AAA/CCC: Element CCC must not be a child of element AAA
/AAA/DDD/EEE/CCC: Element CCC must not be a child of element EEE