Professional Documents
Culture Documents
Custom XPATH
Function in SOA
11g
This post will explain how to create a custom function and configure in SOA 11g
1. Create a JAVA Class which we need to use it as a custom function.
2. The XSLT processor needs the custom Xpath function to be implemented as Static Java Method with a
particular signature as mentioned below.
public class SOAConstants
{
public static classSOAConstantsXPathFunction
implements IXPathFunction
{
public Objectcall(IXPathContext paramIXPathContext, List paramList)
throws XPathFunctionException
{
if ((paramList.size() == 2) && ((paramList.get(0) instanceof String)) && ((paramList.get(1) instanceof
String))) {
try
{
String str = getPropertyValue(paramList);
return str;
}
catch (Exception localException)
{
System.out.println("The Exception : " + localException);
}
}
throw new XPathFunctionException("Pass Only the Service name and Constant name to look up");
}
private static String getPropertyValue(List paramList)
throws XPathFunctionException
{
System.out.println("Inside getPropertyValue");
String str1 = null;
try
{
Document localDocument = SOAConstantsReader.getInstance().getConstantsAsDoc();
String str2 = paramList.get(0).toString();
String str3 = paramList.get(1).toString();
System.out.println("-- payload :" + str2 + " - " + str3);
NodeList localNodeList1 = localDocument.getElementsByTagName(str2);
System.out.println("Got Service NodeList");
http://soavijaya.blogspot.in/2014/04/custom-xpath-function-in-soa-11g.html
1/3
8/22/2014
2/3
8/22/2014
<className>com.vha.util.action.SOAConstants$SOAConstantsXPathFunction</className>
<return type="string"/>
<params>
<param name="parentTagName" type="string"/>
<param name="childTagName" type="string"/>
</params>
<desc resourceKey="GET_PROPERTY VALUE"/>
<detail>
<![CDATA[This function will get the value of element from SOAConstants.xml file]]>
</detail>
</function>
10. The namespace for the function must be http://www.oracle.com/XSL/Transform/java/ followed by the
full classname of the impementing class. This is required by the XSLT processor. The namespace prefix
can be anything
11. The function name can be anything but it must have a namespace prefix.
12. Before using the custom function in JDeveloper it needs to be registered. To do this in JDeveloper we
go to the SOA section in Preferences and add the newly created jar file. To make JDeveloper see the
file we then need to restart JDeveloper. After doing this we will see the XPath function appears in the User
Defined Extension Functions in the expression builder.
http://soavijaya.blogspot.in/2014/04/custom-xpath-function-in-soa-11g.html
3/3