Oracle Technologies Primer

August 3, 2011

Schematron Validation in Oracle BPEL using Custom XPath Function

In one of my earlier post i had shown how we can use the Schematron feature to validate XML content in the Mediator component of Oracle SOA Suite 11g.

The article can be found at the link below

However the mechanism to validate an XML content inside a BPEL or BPMN component is not available as of now. In this blog entry I would like to show how we can achieve it in either a BPEL or a BPM process using a Custom Xpath Function.

I have found these blogs most informative and wonderful on how to create your own Custom XPath function in Oracle SOA Suite.

I would try to show how we can use the custom XPath (link to the Jar) function from within a BPEL process that invokes the behind the scene Java classes to provide a validation output. Preview the screenshot below as how the custom XPath will appear in JDeveloper.


  • Download the SchematronXpath.jar from the location in this link.
  • Open JDeveloper and Click on Tools->Preferences->SOA.
  • Add the SchematronXpath.jar and click OK. We will need to restart JDeveloper in order for this change to take effect.
  • Upon restarting we can see that the custom XPath function is available in the Functions pallette under User Defined Extension Functions


The validateSchematron function accepts the xml source and the corresponding Schematron file against which the xml content should be validated.

The output of the function contains a Static XML describing the validation status and validation messages (consisting of validation errors or warnings if any).

See a sample of the validation Output.

<ValidationMessage>(1).The value of the sum attribute should be the sum of all the values in the item child elements.</ValidationMessage>

The next thing to get this custom function executing at runtime in SOA Suite we need to add it to the SOA suite extension libraries.

  • Copy the SchematronXpath.jar jar file to the <MIDDLEWARE_HOME>/Oracle_SOA1/soa/modules/oracle.soa.ext_11.1.1 directory on the SOA Suite installation.
  • Run ant in that directory (setting JAVA_HOME if necessary) by executing <MIDDLEWARE_HOME>/modules/org.apache.ant_1.7.1/bin/ant.

Another option is to add the jar file in the BPEL runtime manually using the following steps.

  • Go to <Middleware Home>\Oracle_SOA1\soa\modules\oracle.soa.bpel_11.1.1 directory of your Oracle SOA Suite installation.
  • Copy the SchematronXpath.jar in the above directory
  • Unjar the oracle.soa.bpel.jar and edit the MANIFEST.MF to add an entry of the above jar in the classpath.
  • We then need to restart the SOA Suite to get it to recognize the jar in its classpath.

I then created a BPEL process that would invoke the custom XPath function to validate the content of its input. Also placed the schematron file inside a custom folder inside the BPEL project so that we can refer to it using the ora:doc(‘validationFiles/ValidateItemSum.sch’) function using an Assign activity.


The val:validateSchematron(Element xmlSource, Element schemaSource) takes any xml input converted as Node/Element and the validation schema.

I then used a variable called validationResult of type xsd:anyType to get the validation response from the XPath


We can then get the validation status flag and validation messages by applying simple XPath expressions on the validaitonResult variable.


Once we deploy out BPEL process to a running SOA server we can also test it with a few input and see the results.

We first test the Happy test case where we pass two Items with values that add up to the sum attribute. As defined in the schematron file this should pass the validation and it does as is seen in the response.


Test the composite again but this time with Items values which doesn’t add up to the value of the sum attribute.

This time the validation returns a false flag along with the Assert message defined in the schematron file.


If you have any questions and concerns for this particular approach please use the comment section below.

Also let me know in case if you are interested in the source code for the Custom XPath Java code that is demonstrated in this article.

The BPEL process used in this demo can be downloaded from this link.

Jar file for the CustomXpath function.



  1. […] I have also discussed how you can use the Schematron feature from a BPEL process by using a custom Xpath function. See the example at the below link. […]

    Pingback by Using Schematron in Oracle SOA Suite 11g for Validating XML « Oracle Technologies Premier — August 11, 2011 @ 1:25 pm

  2. The link for the jar doesn’t appear to be valid anymore… Is there anyway it could be re-posted or sent to me?


    Comment by Kevin King — September 15, 2011 @ 8:08 pm

  3. Hi Kevin,

    Here is the new link to the download location

    I apologize but i dont know why google docs always messes up with my links.

    Comment by Arun Pareek — September 16, 2011 @ 4:08 pm

  4. Great Post and a very useful approach when considering the use with BPEL.

    However the links to the examples seem to be broken. The customer xPath jar file is OK (as per the commented above), however the BPEL sample link is broken. Would it be possibe to facilitate uploading this or sending via email?

    Many Thanks

    Comment by Dave Gaskell — March 12, 2012 @ 12:04 pm

    • Hi Dave,

      Thanks for your valuable comments. I did upload the project and the jar in Google Docs but i guess it messed up the downloadable links. I have uploaded the projects elsewhere now. See if you can download them. Otherwise i would be happy to email it.

      Comment by Arun Pareek — March 12, 2012 @ 3:01 pm

      • Thanks for uploading those, I now have both files.

        However are these pertinent to a specific SOA Version? (mainly the custom xpath jar)? I am using SOA

        The reason I ask is when I run your sample out of the box, I receive an internal xpath error with the SOA Log files at runtime. This is the same error as I receive in an example I created previously (using your xpath jar file). When looking through the stack trace it mentions errors such as “oracle.xml.xpath.XPathException: Expected Node-set in Path Expression.”

        Hence if you have had this example working previously, it may be something with my environment or versions. FYI I have included the xpath jar in the oracle.soa.ext_11.1.1 library

        Comment by Dave Gaskell — March 12, 2012 @ 4:00 pm

        • Well, I havent tried this example with PS4 ( Let me try with this and see if I also get the same error as you. I will update my observations here.

          Comment by Arun Pareek — March 12, 2012 @ 5:07 pm

          • That would be great if you can try it

            Comment by Dave Gaskell — March 12, 2012 @ 7:18 pm

          • Hi Arun,

            Thanks, that would be great if you could try this and let me know your observations

            Many Thanks

            Comment by Dave Gaskell — March 15, 2012 @ 9:25 am

          • Hello,

            I am also trying it in and I’m having an error:
            XML-22900: (Fatal Error) An internal error condition occurred

            Comment by T.E. — March 20, 2012 @ 4:16 pm

            • I am also getting same error ORAMED-01304:[Payload schematron validation error]Schematron validation failure.Possible Fix:Fix payload or schematron definition and resubmit. Cause:XML-22900: (Fatal Error) An internal error condition occurred.

              Comment by Karthik Krishnamurthy — July 2, 2012 @ 6:59 am

  5. Great Post. Thanks so much for sharing this.
    Tell me, what were the advantages for you of executing the Schematron validation from within BPEL as opposed to using the native Oracle Mediator Schematron validation ? In which cases could this be beneficial?

    Comment by switzerlandchris — April 9, 2012 @ 9:03 am

    • Thanks Chris,
      As such there are no advantages or disadvantages of using/not using Schematron in Oracle BPEL. Normally you will go with validations in the Mediator component if it is being done when the input message is being received or an output message is being sent. In cases where you would require validations in between a process, this is done in BPEL.

      Hope it helps

      Comment by Arun Pareek — April 10, 2012 @ 7:01 am

  6. Great Post. Thanks so much for sharing this.
    Tell me, what were the advantages for you of executing the Schematron validation from within BPEL as opposed to using the native Oracle Mediator Schematron validation ? In which cases could this be beneficial?

    Comment by SchematronStudent — April 9, 2012 @ 9:06 am

RSS feed for comments on this post. TrackBack URI

Post your comments and suggestions here

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at

Caminao's Ways

Do systems know how symbolic they are ?

Adam Deane

Business Process and Workflow

Oracle Technologies Primer

Technical posts on OSB/WLS/AIA, Oracle SOA Suite, BPM and Fusion Middleware

SOA Community Blog

by Jürgen Kress

Technical posts on OSB/WLS/AIA, Oracle SOA Suite, BPM and Fusion Middleware

DevOps for Oracle Middleware

Technical posts on OSB/WLS/AIA, Oracle SOA Suite, BPM and Fusion Middleware

J@n van Zoggel

mumblings of a middleware minion

Oracle .. Java .. OpenSource .. SOA

Just another weblog

Nitin's Oracle Fusion Middleware and SOA World

SOA FMW BPM BPEL OSB Governance J2EE and all the Geeky stuff


Musings on Integration with Oracle Fusion Middleware

%d bloggers like this: