I have developed a simple utility that validates an input document against a schematron file and returns a validation report that returns the status of validation, together with the list of assertions that failed.
The utlity is registered as an XPath function and can be invoked from within the XSL Mapper.
Here are the steps for using the utlity.
a) Download the jar file from http://blogs.oracle.com/rammenon/SchematronValidator.jar
b) Copy the file into $JDEV_HOME/jdev/lib/ext
c) Create a new file named “SchematronExtensionFunctions.xml” and copy the following content within it.
<?xml version="1.0" encoding="UTF-8"?>
<function name="sch:validateDocument" as="node-set">
<param name="schFileName" as="string"/>
<param name="inputDoc" as="node-set"/>
Save the file onto the local file system.
d) Open JDev and navigate to Tools –> Preferences –> XSL Map.
e) Select the above file for the “User defined Extension Functions config file” and restart JDeveloper.
f) Create a new empty project/BPEL Project.
g) Add the following XSD into the project - http://blogs.oracle.com/rammenon/ValidationReport.xsd. This XSD will define the report of errors if any during the schematron validation.
h) Also add the XSD for the document you wish to validate [if you havent added it yet]
i) Create a new XSL Map and choose the source as the input XSD in (h) and the target as the validationReport.xsd.
j) Choose “validateDocument” from the “User defined Extension functions” palette page of the component palette and drag it into the center pane.
k) Edit the parameters of the xpath function – the first argument is the absolute URL to the “.sch” file. The second argument should be the root element of the source document.
for instance, the generated XSLT for the mapping would look like’
Note the “copy-of” instead of “value-of” in the above expresion. When you drag and drop nodes into the center pane, the mapper will generate “value-of” statements. Manually change it to “copy-of”.
l) Test the map [note that the graphical view of the mapper might complain stating that ""copy-of" is not supported. You can safely ignore this message, since this warning is only for limitations to graphical rendering of the construct.