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.

About this task

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))
Note:
  • 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 Managing user-defined functions.