Schematron rule validation
Posted: Mon Aug 18, 2008 1:47 pm
Dear All,
I am very new to the group and schematron and would need your help in order to debug an issue. I have got a sample xml file as follows:
<A>
<Items>
<Item no=1>
<Amount>0</Amount>
</Item>
<Item no=2>
<Amount>10</Amount>
</Item>
</Items>
</A>
I need to write a rule that should raise an error only when all Amount element's value is 0. I have written the following schematron snippet:
<sch:pattern name="Correct Amount">
<sch:rule context="/A/Items/Item/Amount">
<sch:assert test="normalize-space(.)!='0'">
All Amount must not be zero
</sch:assert>
</sch:rule>
</sch:pattern>
This works if both the amount is 0. But if one is 0 and the other non-zero, this doesn't work.
Any idea what the correct rule should be?
Thanks very much.
I am very new to the group and schematron and would need your help in order to debug an issue. I have got a sample xml file as follows:
<A>
<Items>
<Item no=1>
<Amount>0</Amount>
</Item>
<Item no=2>
<Amount>10</Amount>
</Item>
</Items>
</A>
I need to write a rule that should raise an error only when all Amount element's value is 0. I have written the following schematron snippet:
<sch:pattern name="Correct Amount">
<sch:rule context="/A/Items/Item/Amount">
<sch:assert test="normalize-space(.)!='0'">
All Amount must not be zero
</sch:assert>
</sch:rule>
</sch:pattern>
This works if both the amount is 0. But if one is 0 and the other non-zero, this doesn't work.
Any idea what the correct rule should be?
Thanks very much.