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

Description

The sum of values of all relevant elements equals 100.

Schema


<schema xmlns="http://www.ascc.net/xml/schematron" >
     <pattern name="Sum equals 100%.">
          <rule context="Total">
               <assert test="sum(//Percent) = 100">The values do not sum to 100%. </assert>
          </rule>
     </pattern>
</schema>

Sources and outputs

Source (XML 1)Output

<Total>
     <Percent>20</Percent>
     <Percent>30</Percent>
     <Percent>10</Percent>
     <Percent>50</Percent>          
</Total>
 Pattern: Sum equals 100%.
/Total: The values do not sum to 100%.


Source (XML 2)Output

<Total>
     <Percent>20</Percent>
     <Percent>10</Percent>
     <Percent>50</Percent>          
</Total>
 Pattern: Sum equals 100%.
/Total: The values do not sum to 100%.


Source (XML 3)Output

<Total>
     <Percent>20</Percent>
     <Percent>30</Percent>
     <Percent>50</Percent>          
</Total>
 Pattern: Sum equals 100%.