IBM BPM, V8.0.1, All platforms > Authoring services in Integration Designer > Developing monitor models > Create monitor models
Authoring XPath functions
XML Path Language (XPath) expressions are widely used in monitor model programming to define maps, trigger conditions, filters, correlation predicates, and default values. User-defined XPath functions can be implemented as specially annotated Javaâ„¢ methods. You can use these XPath functions in the same way you would use any built-in XPath function within an expression. You can develop user-defined XPath functions through a Java project in Rational Application Developer or Integration Designer.
Business Monitor supports using user-defined XPath functions in XPath expressions in the same way as built-in XPath functions. User-defined XPath functions provide alternatives to inbound events for accessing information. While inbound events transfer information in a source-initiated manner, you can use user-defined XPath functions to initiate information retrieval.
For example, a user-defined XPath function can be implemented as a web service call to retrieve corporate data from an overseas branch. It can also involve updating some records in a database. You can define metrics whose values are set based on an algorithm that you define and implement as a user-defined XPath function. An example would be a function that takes a product or catalog number and returns a product description or price.
In the following example, the return value of a user-defined XPath function named usr:get-cost-estimate is used as an argument in the built-in XPath function fn:concat, which concatenates two string values.
fn:concat("The estimated cost is: ", usr:get-cost-estimate(projectDuration, projectStart, costOfMaterial))
- Business Monitor does not support all of XPath 2.0. See Expression support for details.
- The user-defined functions that you use in a Business Monitor monitor model are defined in a Java project.
- Java version 1.5 annotations (see Java Specification Request 175) are used to mark methods for use as user-defined XPath functions.
Additional information on this topic is covered in Manage user-defined functions.
- Create an XPath function JAR
To add the Java function that you plan to use in your XPath expressions, create an XPath function Java archive (JAR) file in Rational Application Developer or Integration Designer.- XPathFunction and XPathType annotations
The XPathFunction annotation contains the information necessary to mark a method as a user-defined XPath function. The XPathType annotation can be used on a method to clarify the return value of the method, or on the parameters of a method to clarify the type of the parameter.- Examples of XPath functions
The Business Monitor code generator and expression evaluator support XPath functions. XPath functions described serve only as examples. Options available to you in defining your own XPath functions are far too broad for an exhaustive description.