IBM BPM, V8.0.1, All platforms > Authoring services in Integration Designer > Developing monitor models > Create monitor models > Authoring XPath functions > Examples of XPath functions

Example of a string function

String functions are one of several XPath 2.0 functions supported in model expressions in IBM Business Monitor. Define string XPath functions for use in monitor model XPath expressions.

The following code exemplifies the use of the string user-defined XPath function:

import com.ibm.wbimonitor.xml.expression.udf.XPathFunction;

public class Examples {
public static final String NAMESPACE = "http://www.jimbo.org/beverages/functions";

@XPathFunction(
namespaceName = NAMESPACE, localName = "findAndReplace", description = "(source, find, replace) Return the source string with all occurrences of find replaced with replace.", 
isSelfContained = true, isDeterministic = true
)
public static String findAndReplace(final String source, final String find, final String replace) {
return source.replace(find, replace);} } 

Examples of XPath functions