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

Description

Character @ is forbidden in text.

Schema


<schema xmlns="http://www.ascc.net/xml/schematron" >
     <pattern name="Character @ forbidden">
          <rule context="*">
               <report test="contains(.,'@')">Text in element
                    <name/> must not contain character @
               </report>
          </rule>
     </pattern>
</schema>

Sources and outputs

Source (XML 1)Output

<AAA>
     <BBB>bbbb</BBB>
     <CCC>cccc</CCC>
</AAA>
 Pattern: Character @ forbidden


Source (XML 2)Output

<AAA>
     <BBB>bbbb@bbb.com</BBB>
     <CCC>ccc@ccc.com</CCC>
</AAA>
 Pattern: Character @ forbidden
/AAA: Text in element AAA must not contain character @
/AAA/BBB: Text in element BBB must not contain character @
/AAA/CCC: Text in element CCC must not contain character @


Source (XML 3)Output

<AAA>
     <BBB>bbbb</BBB>
     <CCC>cccc</CCC>
     aaa@aaa.net
</AAA>
 Pattern: Character @ forbidden
/AAA: Text in element AAA must not contain character @