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

Description

Each schema can specify several patterns.

Schema


<schema xmlns="http://www.ascc.net/xml/schematron" >
     <pattern name="Print both cases">
          <rule context="AAA">
               <assert test="BBB">BBB element is missing.</assert>
               <report test="BBB">BBB element is present.</report>
               <assert test="@name">AAA misses attribute name.</assert>
               <report test="@name">AAA contains attribute name.</report>
          </rule>
     </pattern>
     <pattern name="Print positive result only">
          <rule context="AAA">
               <report test="BBB">BBB element is present.</report>
               <report test="@name">AAA contains attribute name.</report>
          </rule>
     </pattern>
     <pattern name="Print negative result only">
          <rule context="AAA">
               <assert test="BBB">BBB element is missing.</assert>
               <assert test="@name">AAA misses attribute name.</assert>
          </rule>
     </pattern>
</schema>

Sources and outputs

Source (XML 1)Output

<AAA>
     <BBB/>
</AAA>
 Pattern: Print both cases
/AAA: BBB element is present.
/AAA: AAA misses attribute name.

 Pattern: Print positive result only
/AAA: BBB element is present.

 Pattern: Print negative result only
/AAA: AAA misses attribute name.


Source (XML 2)Output

<AAA>
     <CCC/>
</AAA>
 Pattern: Print both cases
/AAA: BBB element is missing.
/AAA: AAA misses attribute name.

 Pattern: Print positive result only

 Pattern: Print negative result only
/AAA: BBB element is missing.
/AAA: AAA misses attribute name.