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


If an element contains an attribute , the attribute name must be id.


<schema xmlns="http://www.ascc.net/xml/schematron" >
     <pattern name="id is the only permited attribute name">
          <rule context="*">
               <report test="@*[not(name()='id')]">Atrribute
                    <name path="@*[not(name()='id')]"/> is forbidden in element

Sources and outputs

Source (XML 1)Output

<AAA name="aaa">
<BBB id="bbb"/>
<CCC color="ccc"/>
 Pattern: id is the only permited attribute name
/AAA: Atrribute name is forbidden in element AAA
/AAA/CCC: Atrribute color is forbidden in element CCC