Using Schematron within BPEL

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"?>
<extension-functions>
  <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"/>
     </function> 
  </functions>
</extension-functions>.

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.

Comments:

Post a Comment:
  • HTML Syntax: NOT allowed
About

Principal Product Manager

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today