[
Lists Home |
Date Index |
Thread Index
]
Schematron is another schema language. It lets you take your
natural language statements and wrap them with XPath-based
tests.
Here is the description:
<ORDER> can contain any number of child elements
<UID> must be included
<DEALER> must be included
<ORDERS> must be included
<ORDERS> can contain multiple ITEM(s) but restricted to just ITEM nodes
<ITEM> must have unique id property and the value of item must be numeric > 0
Here is a Schematron schema for those:
<schema xmlns="http://www.ascc.net/xml/schematron">
<title>Example Schema</title>
<pattern name="Contents">
<rule context="ORDER">
<assert test="true()" >ORDER can contain any number of child elements</assert>
<assert test="UID" >UID must be included</assert>
<assert test="DEALER" >DEALER must be included</assert>
<assert test="ORDERS" >ORDERS must be included</assert>
</rule>
<rule context="ORDERS">
<assert test="count(*) = count(ITEM)"
>ORDERS can contain multiple ITEM(s) but restricted to just ITEM nodes
</assert>
</rule>
<rule context="ITEM">
<assert test="count(//ITEM[@id=current()/@id]) = 1" >
ITEM must have unique id property</assert>
<assert test="./number() > 0 ">
The value of ITEM must be numeric > 0</assert>
</rule>
</pattern>
</schema>
Cheers
Rick Jelliffe
|