Add the Function to a Mashup Script or Macro
Once you have added the function to the classpath, you can use it in mashup scripts or macros. First, you must declare a namespace for the custom function class using the java: protocol and the fully qualified Java class name. For example:
<?xml version="1.0"?>
<mashup name="SoundexSearch"
xmlns="http://www.openmashup.org/schemas/v1.0/EMML"
xsi:schemaLocation="http://www.openmashup.org/schemas/v1.0/EMML
../schema/EMMLPrestoSpec.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:myFunc="java:com.mycompany.mashups.CustomFunctions" >
...
Then use the function, with its namespace, in any XPath expression in the mashup script. This example uses the function in a filter expression:
...
<input name="param" type="document">
<data>
<item><name>test1</name></item>
<item><name>data2</name></item>
<item><name>test3</name></item>
<item><name>data4</name></item>
<item><name>data-5</name></item>
<item><name>data.6</name></item>
<item><name>data-6-6</name></item>
<item><name>5-6-data-6-6</name></item>
</data>
</input>
<output name="result" type="document"/>
<filter inputvariable="param"
filterexpr = "/data/item[myfunc:soundex(name, 'data')]"
outputvariable="result"/>
Notice that the first parameter for the function is passed with a relative XPath expression to the name node. You can use XPath expressions as function parameters as long as the expressions resolve to a single node with simple content.