Schematron Pretty

Schema for Purchase Order Example

     Pattern           

address type

     Rule   
name| city | state | zip
     Assert   
parent::*/streetAn address should have a street.
     Assert   
parent::*/cityAn address should have a city.
     Assert   
parent::*/stateAn address should have a state.
     Assert   
parent::*/zipAn address should have a zip.
     Assert   
parent::*/@typeAn address should have a type attribute.
     Rule   
/name | /city | /state | /zip
     Report   
self::*The elements <name path=""/> is not expected at the top of a document. They form part of an address.



     Pattern           

purchase order type

     Rule   
shipTo | shipDate | Items
     Assert   
parent::*/shipToA purchase order should have a shipTo element.
     Assert   
parent::*/shipDateA purchase order should have a shipDate element.
     Assert   
parent::*/ItemsA purchase order should have an Items element.
     Assert   
parent::*/@orderDateA purchase order should have an orderDate attribute.
     Rule   
/shipTo | /shipDate | /Items
     Report   
self::*The element <name path=""/> is not expected at the top of a document. It should be in the body of a purchase order.



     Pattern           

Specific Elements

     Rule   
PurchaseOrder
     Assert   
shipToA purchase order element should have a shipping address. There should be a shipTo element contained by the PurchaseOrder element.
     Rule   
shipTo
     Assert   
nameA shipping address element should have a name element.
     Rule   
Items
     Assert   
count(child::*) = count(child::Item)The Items element can only contain Item elements
     Rule   
Item
     Assert   
productNameThe Item element should contain a product name.
     Assert   
quantityThe Item element should contain a quantity element
     Assert   
priceThe Item element should contain a price element.
     Rule   
comment
     Report   
child::*A comment should have no subelements
     Assert   
parent::Item | parent::PurchaseOrder A comment can only appear in an Item or a Purchase Order




Schematron Pretty by Rick Jelliffe. The Schematron by Rick Jelliffe, Academia Sinica Computing Centre.