Oracle SOA 11g provides several ways using which we can validate input XML. Schematron is one of the way using which we van validate input XML used for routing rule in Mediator.
In Schematron xml file we can define various validation rules using rule element. The rule element has context attribute which defines for which node the rule will be applied.
A rule element can have one or multiple assert/report elements, each containing test attribute with the actual validation rule.
Let us consider the below example for using Schematron for validating input XML.
Let us know your valuable feedback for the post.
Happy Coding... :)
In Schematron xml file we can define various validation rules using rule element. The rule element has context attribute which defines for which node the rule will be applied.
A rule element can have one or multiple assert/report elements, each containing test attribute with the actual validation rule.
Let us consider the below example for using Schematron for validating input XML.
- Consider the XSD format as shown below.
- Consider a bussiness rule as : Employee salary should be greater than 1000.
- Create a schematron file with .sch extension. The code snippet is as shown below.
- Drag and drop a mediator in composite and select Synchronous Interface as the template.For input and output use employee.xsd elements.
- Double click the mediator to create a static routing rule with target type as echo( just for testing schematron validation).
- Select the schematron file in Validate Semantic of the routing rule.
- Create a Transformation transforming input to output( just for testing the flow.)
- Save and deploy the project.
- Now test it by giving salary value less than 1000. As per the validation rule defined in schematron it should be faulted.
- Now test it by giving salary value greater than 1000. Our XML validation will pass.
Let us know your valuable feedback for the post.
Happy Coding... :)
can u let me know the difference between scchematron and xsd validation
ReplyDelete