Using Schematron within BPEL

Ramkumar Menon
Director, Product Strategy

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"?>
  <functions xmlns:sch="http://www.oracle.com/XSL/Transform/java/com.oracle.xsl.xpath.sch.SchematronValidator">

    <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’

<xsl:copy-of select="sch:validateDocument('file:///localhost:7777/validations/po-validations.sch',/tns:po)"/>

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.

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.