Schematron rule validation
Here should go questions about transforming XML with XSLT and FOP.
-
- Posts: 2
- Joined: Mon Aug 18, 2008 1:25 pm
Schematron rule validation
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.
-
- Posts: 4141
- Joined: Fri Mar 28, 2003 2:12 pm
Re: Schematron rule validation
Post by sorin_ristache »
Hello,
The rule should be like:
Regards,
Sorin
The rule should be like:
Code: Select all
<sch:pattern>
<sch:rule context="/A/Items">
<sch:assert test="count(Item/Amount[. != 0]) > 0">
All Amount must not be zero
</sch:assert>
</sch:rule>
</sch:pattern>
Sorin
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service