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

Description

XML 1 (file source1.xml) contains a list of authors. These authors are referred to in XML 2. The Schematron checks if for each referred author in XML 2 exists an entry in XML 1.

Schema


<schema xmlns="http://www.ascc.net/xml/schematron" >
     <pattern name="Compare with the database">
          <rule context="author">
               <assert test="document('source1.xml')//author[@id=current()/@id]">The author is not in the database </assert>
          </rule>
     </pattern>
</schema>

Sources and outputs

Source (XML 1)Output

<list>
     <author id="a1">Alice</author>
     <author id="p1">Paul</author>     
     <author id="p2">Peter</author>
</list>
(This file has not been checked.)

Source (XML 2)Output

<list>
     <author id="a1"/>
     <author id="a2"/>
     <author id="p1"/>     
     <author id="p2"/>
</list>
 Pattern: Compare with the database
/list/author[2]: The author is not in the database