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

Description

Test, if the value of an element is an integer

Schema


<schema xmlns="http://www.ascc.net/xml/schematron" >
     <pattern name="Test integer">
          <rule context="AAA">
               <report test="floor(.) = number(.)">O.K.</report>
               <assert test="floor(.) = number(.)">The AAA value is not an integer.</assert>
          </rule>
     </pattern>
</schema>

Sources and outputs

Source (XML 1)Output

<AAA>
aaa
</AAA>
 Pattern: Test integer
/AAA: The AAA value is not an integer.


Source (XML 2)Output

<AAA>
 12.234
</AAA>
 Pattern: Test integer
/AAA: The AAA value is not an integer.


Source (XML 3)Output

<AAA>
45
</AAA>
 Pattern: Test integer
/AAA: O.K.


Source (XML 4)Output

<AAA>
0
</AAA>
 Pattern: Test integer
/AAA: O.K.


Source (XML 5)Output

<AAA>
-45
</AAA>
 Pattern: Test integer
/AAA: O.K.