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

Description

A paragraph in XML 2 can only start with words specified in XML 1 (file source1.xml)

Schema


<schema xmlns="http://www.ascc.net/xml/schematron" >
     <pattern name="Start of paragraph restriction.">
          <rule context="p">
               <assert test="document('source1.xml')//*[name()=substring-before(current(),' ')]">The word at the beginning of sentence is not listed in XML 1.</assert>
          </rule>
     </pattern>
</schema>

Sources and outputs

Source (XML 1)Output

<list>
     <Alice/>
     <Peter/>
     <Paul/>
</list>
(This file has not been checked.)

Source (XML 2)Output

<Document>
     <p>Alice is a nice girl.</p>
     <p>Where is Peter.</p>
     <p>Paul was invited.</p>
     <p>But Paul did not come.</p>
</Document>
 Pattern: Start of paragraph restriction.
/Document/p[2]: The word at the beginning of sentence is not listed in XML 1.
/Document/p[4]: The word at the beginning of sentence is not listed in XML 1.