Extending Error Handling with Custom Xpath Function

In my last blog, I showed you how to create a custom XPath function to collect consistent error information and pass that information to an error handler service. Let’s extend the XPath function, from my previous blog, by adding customizable parameters to the call.

The additional parameters provide the ability to capture specific information by flow, such as error severity and payload message. Other parameters can be added as needed by your organization.

Now we need to extend our custom XPath function and populate the following CommonErrorHandler.xsd, so here are the steps required.

  • First you need to add the new elements to the xsd.
<?xml version="1.0" encoding="UTF-8" ?>
<xsd:schema xmlns:xsd=""

  <xsd:element name="CommonErrorHandler">
        <xsd:element name="interfaceName" type="xsd:string"/>
        <xsd:element name="instanceId" type="xsd:string"/>
        <xsd:element name="messageId" type="xsd:string"/>
        <xsd:element name="payload" type="xsd:string"/>
        <xsd:element name="severity" type="xsd:string"/>
  • Open up the java project in JDev called BlogXPathFunctions, as created in the previous blog
  • Extend the java class
    • Name: BlogFunctions
    • Package:
    • Add parameters to the call method.  All XPath parameters are passed to this method as a list of parameters, so each one must be extracted from the list in the appropriate order.  Then the parameters must be passed to the implementation class.

import java.util.List;


import oracle.fabric.common.xml.xpath.IXPathContext;
import oracle.fabric.common.xml.xpath.IXPathFunction;
import oracle.fabric.common.xml.xpath.XPathFunctionException;

import org.w3c.dom.Node;

public class BlogFunctions
    public static class PopulateErrorDataFunction implements IXPathFunction
        public Object call(IXPathContext iXPathContext,
                           List list) throws XPathFunctionException
                String messagePayload = (String)list.get(0);
                String errorSeverity = (String)list.get(1);
                return BlogFunctionsImpl.populateErrorData(messagePayload,
            catch (Exception e) 
               throw new XPathFunctionException(e.getMessage());
  • Extend the java class
    • Name: BlogFunctionsImpl
    • Package:
    • Add parameters to the populateErrorData method.  Then the parameters can be used to populate the CommonErrorHandler.xsd.
     public static Object populateErrorData(String pMessagePayload,
                                           String pErrorSeverity,
                                           IXPathContext pIXPathContext)
            throws XPathFunctionException, ParserConfigurationException
        Node rootNode = null;
        try {
            Map props = (Map)pIXPathContext.getVariableValue(null, null,

            ICubeContext cubeContext = (ICubeContext)props.get("ICubeContext");
            ICubeInstanceImpl cubeInstance = 

            Document document = Helpers.prepareDocument();
            rootNode = document.createElementNS(sERROR_DATA_NAME_SPACE,
                                    "payload", sERROR_DATA_NAME_SPACE,
                                    "severity", sERROR_DATA_NAME_SPACE,
                                    "interfaceName", sERROR_DATA_NAME_SPACE,
  • Deploy the project to a jar
    • Click on deploy
    • Click on New Deployment Profile
    • Click on Jar File
    • Name the deployment profile the same as the project
  • Update XPath functions in JDev
    • Click on Tools
    • Click on Preferences
    • Click on SOA
    • Click on existing jar and delete
    • Click on Add and search for newly created jar file
    • Recycle JDev to take effect

You can now utilize your extended XPath function and enhance your error handling.




Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top