Schematron Component

Available as of Camel 2.14

Schematron is an XML-based language for validating XML instance documents. It is used to make assertions about data in an XML document and it is also used to express operational and business rules. Schematron is an ISO Standard. The schematron component uses the leading implementation of ISO schematron. It is an XSLT based implementation. The schematron rules is run through four XSLT pipelines, which generates a final XSLT which will be used as the basis for running the assertion against the XML document. The component is written in a way that Schematron rules are loaded at the start of the endpoint (only once) this is to minimise the overhead of instantiating a Java Templates object representing the rules.

URI format

URI options

NameDefault valueDescription
pathmandatoryThe path to the schematron rules file. Can either be in class path or location in the file system.
abortfalseflag to abort the route and throw a schematron validation exception.

Headers

NameDescriptionTypeIn/Out
CamelSchematronValidationStatusThe schematron validation status: SUCCESS / FAILEDStringIN
CamelSchematronValidationReportThe schematrion report body in XML format. See an example belowStringIN

URI and path syntax

The following example shows how to invoke the schematron processor in Java DSL. The schematron rules file is sourced from the class path:

 

The following example shows how to invoke the schematron processor in XML DSL. The schematrion rules file is sourced from the file system:

Where to store schematron rules?

Schematron rules can change with business requirement, as such it is recommended to store these rules somewhere in file system. When the schematron component endpoint is started, the rules are compiled into XSLT as a  Java Templates Object. This is done only once to minimise the overhead of instantiating Java Templates object, which can be an expensive operation for large set of rules and given that the process goes through four pipelines of XSLT transformations. So if you happen to store the rules in the file system, in the event of an update, all you need is to restart the route or the component. No harm in storing these rules in the class path though, but you will have to build and deploy the component to pick up the changes.

Schematron rules and report samples

Here is an example of schematron rules

 

Here is an example of schematron report:

 

 

Useful Links and resources

 

 

 

© 2004-2015 The Apache Software Foundation.
Apache Camel, Camel, Apache, the Apache feather logo, and the Apache Camel project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.
Graphic Design By Hiram