Schematron Rule-based validation - Schematron.
This standard is available free on the ISO Publicly Available Specifications list. Paper versions may be purchased from ISO or national standards bodies.
Schemas that use ISO/IEC FDIS 19757-3 should use the following namespace:
http://purl.oclc.org/dsdl/schematron
Sample rule
Schematron rules can be created using a standard XML editor.
The following is a sample schema:
xmlns="http://purl.oclc.org/dsdl/schematron">
<pattern>
<title>Date rules</title>
<rule context="Contract">
ContractDate < current-date()">ContractDate should be in the past because future contracts are not allowed.
</rule>
</pattern>
</schema>
In Plain words:
This rule checks to make sure that the ContractDate XML element has a date that is before the current date. If this rule fails the validation will fail and an error message which is the body of the assert element will be returned to the user.
In markup languages, Schematron is a rule-based validation language for making assertions about the presence or absence of patterns in XML trees. It is a structural schema language expressed in XML using a small number of elements and XPath.
Schematron Validation in SOA 11G Mediator
- The schematron validation allows loose coupling of Semantic validation of the incoming/outgoing mediator payload.This is accomodated while defining the routing rule for mediator payloads.
- The Schematron file is created with a file type having an .sch extention.
- This file can be maintained in the project workspace or alternately as artifact in MDS repository for taking the real advantage of loose coupling of validation semantics.
In below example I have maintained the schematron file in my Mediator project work space.
when assertion (i.e. the asserted test statement) evaluates to false, the asseted statement is thrown as validation error.
Deploy and test the Mediator from SOAP UI.