Defining and importing the user-defined functions
In this recipe, we will illustrate how to define the custom functions in Java and how to import them into JDeveloper for the XSLT mapper.
How to do it…
The following text will cover the steps needed to define the custom functions and import them into JDeveloper:
We start by opening an empty Java project in JDeveloper.
In the Java project, we create the Java class (
ValueWithUnit.java
) that is used as a placeholder for the function logic. What we do is concatenate the value of the field with its corresponding unit as follows:public class ValueWithUnit { public static String formatValueWithUnit(String value, String unit) { return value + " " + unit; } }
Next, we prepare the configuration file. We create a new directory named
xml
in the project and prepare the XML file namedext-mapper-xpath-functions-config.xml
.In the configuration file, we define the function name, class name, and input and output parameters. We also add the description...