Tesing number of decimal digits in schematron
Posted: Fri Sep 08, 2017 5:21 pm
Hi,
I have another interesting Schematron issue: I need to test that the numeric value should have not more than 3 decimal positions. The data type is xsd:decimal, so there may be also no decimal digits, which makes it more difficult to check (to me anyway). My XML is:
The correct values would be: 5, 5.1, 5.11, but not 5.111
I created the following test using regular expression:
but this requires exactly 2 decimals, which is not the intention. How can I say 0, 1 or 2 decimal digits?
Best Regards,
Ewa
I have another interesting Schematron issue: I need to test that the numeric value should have not more than 3 decimal positions. The data type is xsd:decimal, so there may be also no decimal digits, which makes it more difficult to check (to me anyway). My XML is:
Code: Select all
<A>
<measurement>
<height>5.11</height>
</measurement>
<measurement>
<height>5</height>
</measurement>
</A>
I created the following test using regular expression:
Code: Select all
<sch:rule context="//measurement">
<sch:assert test="height[matches(., '[\.][\d]{2}$')]">Maximum 2 decimal digits are allowed</sch:assert>
</sch:rule>
Best Regards,
Ewa