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


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 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>

Sources and outputs

Source (XML 1)Output

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

Source (XML 2)Output

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