FeaturesPluginsDocs & SupportCommunityPartners

XPath Functions and Operations in the BPEL Mapper

The BPEL Mapper is a tool for visual work with XPath expressions. The BPEL Mapper allows you to work with expressions, copying variables, XSD elements, and XSD attributes. This tool enables you to work with predicates and use XPath functions.
The XPath expressions editor is used for work with some business process elements. The following allowed expressions are defined for each element: either copy expressions, condition expressions, or time functions usage.

Contents

Content on this page applies to NetBeans IDE 6.0

User Interface

The BPEL Mapper features an easy-to-use intuitive user interface. The BPEL Mapper window appears when you select a BPEL diagram element that can contain XPath expressions. The BPEL Mapper is used for the following business process elements: Assign, If, ElseIf element of If, ForEach, RepeatUntil, While, and Wait. Every element has allowable expressions, which include copy expressions, condition expressions, time function usage. Condition expressions are defined for the If, ElseIf element of If, While, and RepeatUntil elements. Copy expressions are defined for the Assign element. Duration expressions are defined for the Wait element. And condition expressions with parameters are defined for the ForEach element. Using the BPEL Mapper interface you can make calculations by assigning XPath operations and functions listed above to local and global variables, XSD elements and attributes, and parts.

Every business process element listed above has the Show BPEL Mapper item in the context menu in the Design view of the BPEL Designer. The context menu is available when you closed the BPEL Mapper window. You can also open the XPath expressions editor window by choosing Window > BPEL Mapper from the main menu.

You can edit XPath expressions in the source text of a BPEL file as shown in Figure 1. The BPEL Mapper displays the correct modifications as shown in Figure 2.

Figure 1: Source View of the BPEL file

Source View of the BPEL file
Click to enlarge

Figure 2: Addition Operation for Assign1

Addition Operation for Assign1

top

Functions and Operators Used in the BPEL Mapper

The BPEL Mapper supports version 1.0 of the XML Path language (XPath 1.0). The XPath language is a key part of the XML platform. The XPath language developed by the W3C consortium is a language that addresses the structural parts of an XML document. The language has functions for manipulating strings, numbers, and boolean values. The main syntactic construct of XPath is an expression. As a result of processing an expression, an object that falls into one of the following four fundamental types will appear:
  • node-set - unordered set of nodes without duplicates
  • boolean - true or false
  • number - number with a floating dot
  • string - sequence of UCS symbols
The XPath language supports number expressions, equality and comparison operations, and boolean expressions. The BPEL Mapper supports part of XPath operations and functions.

Numerical Expressions and Operations

The Operator menu of the BPEL Mapper appears as shown below.

Figure 3: The BPEL Mapper Operator Menu

The BPEL Mapper Operator Menu

Numerical Expressions

Numerical expressions are used for performing arithmetic operations over numbers. Equality operations are used to check the equality of two values. Any number in the XPath language has a representation with a floating point. A number can take on any value in the 64 bit format of IEEE 754 DP. This includes a special "Not-a-Number" (NaN) value, positive and negative infinities, and positive and negative nulls.

Table 1: Operators Used in Numerical Expressions

Operator Description Sample Result
+ Addition of two numbers 2 + 3 5
- Subtraction of a number from another one
5 - 2 3
* Multiplication of a number by another number
2 * 5 10
div Division of a number by another number
10 div 2 5
mod Remainder from division of a number by another number
11 mod 3 2
- Unary minus -2 -2

Equality Operations

Notice that length equal to 5.50 is initial data for the table below.

Table 2: Operators Used in Equality Operations

Operator Description Sample Result
= Equality operation length=5.50 true
!= Inequality operation length!=5.50 false

Comparison Operations

Notice that length equal to 5.50 is initial data for the table below.

Table 3: Operators Used in Comparison Operations

Operator Description Sample Result
< Less length<5.50 false
<= Less or equal length<=5.50 true
> Greater length>5.50 false
>= Greater or equal length>=5.50 true

Note: If none of the objects subject to comparison is a node-set, and if the operator is either <=, <, =>, or >, the compared objects are first converted into numbers and then compared.


top

Boolean Expressions and Functions

The Boolean menu of the BPEL Mapper is shown below.

Figure 4: The BPEL Mapper Boolean Menu

The BPEL Mapper Boolean Menu

Boolean Expressions

answer = true

Table 4: Operators Used in Boolean Expressions

Operator Description Sample Result
or Returns true if at least one of the Boolean operands is equal to true false() or answer true
and Returns true if both the Boolean operands are equal to true true() and answer true

Boolean Functions

Notice that answer equal to true and the language of the xml:lang="en" context node are initial data for the table below.


Table 5: Boolean Functions Usage

Name Description Sample Result
boolean Converts a argument to a boolean type boolean(2) true
false Returns false false() or answer true
true Returns false true() or answer true
not Returns negation not(false()) true
lang
Returns true or false depending on whether the context node language defined in xml:lang attributes is the same language (or sublanguage) as the one defined in the attribute string lang('en') true

top

Numerical Functions

The Number menu of the BPEL Mapper is shown below.

Figure 5: The BPEL Mapper Number Menu

The BPEL Mapper Number Menu

Table 6: Numerical Functions Usage

Name Description Sample Result
round Rounds off to the nearest integer round (3.14) 3
ceiling Function returns the smallest integer that is greater or equal to the argument ceiling (3.14) 4
floor Function returns the biggest integer that is less than or equal to the argument floor (3.14) 3
number Converts an argument to a number number(length) Numerical value of the length element
sum Function converts every node from a node-set to a number and sums them up sum(/apple/count) Sum of all count nodes
Number Literal Number ( in XPath a number has a representation with a floating point) 1.2 1.2

top

String Functions

The String menu of the BPEL Mapper is shown below.

Figure 6: The BPEL Mapper String Menu

The BPEL Mapper String Menu

Table 7: String Functions Usage

Name Description Sample Result
string Converts an argument into a string string(3.14) '3.14'
string-length Returns the string length string-lenght('MyString') 8
substring Returns the part of the first argument string that starts with the position set by the second argument and has the length set in the third argument substring('1234',2,3) '234'
substring-after Returns the part of the first argument string that follows the first occurrence of the second argument string substring-after('20-30','-') '30'
substring-before Returns the part of the first argument string that precedes the first occurrence of the second argument string substring-before('14-30','-') '14'
contains Returns true if the first string contains the second one

contains('XPath','X')

true
starts-with Returns true if the first string starts with the second one starts-with('XPath','X') true
concat Returns concatenation of two strings concat('String1 ','String2') 'String1 String2'
normalize-space Returns the argument string with normalization of space symbols normalize-space('  1     2    ') '1 2'
translate Returns the first argument string where symbols set in the second argument string are replaced by the symbols of the third argument string in a corresponding position translate('black','kcalb','etihw') 'white'
String Literal String constant; strings are formed by a sequence of null and more symbols defined in XML reference 'String' 'String'

top

Node-Sets Functions

The Nodes menu of the BPEL Mapper is shown below.

Figure 7: The BPEL Mapper Nodes Menu

The BPEL Mapper Nodes Menu

The following code is a sample of a SOAP message.

Code Example 1: SOAP Message Sample
<soapenv:Envelope
xsi:schemaLocation="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:syn="http://xml.netbeans.org/schema/SynchronousSample">

  <soapenv:Body>
    <syn:typeA>
      <syn:paramA>String1</syn:paramA>
      <syn:paramA>String2</syn:paramA>
      <syn:paramA>String3</syn:paramA>
      </syn:typeA>
  </soapenv:Body>
</soapenv:Envelope>


Table 8: Node-Set Functions Usage

Name Description Sample Result
count Returns the number of nodes set in the argument count($inputVar.inputType/xs:paramA) 3
last Returns the number of the last element in a multitude $inputVar.inputType/paramA[last()] String3
position Returns the position of an element in a multitude
local-name
Returns the name of the first tag in a multitude without namespace local-name($inputVar.inputType/xs:paramA) paramA
name Returns the full name of the first tag in a multitude  name($inputVar.inputType/xs:paramA) syn:paramA
namespace-uri Returns a reference to the url that defines the namespace namespace-uri($inputVar.inputType/xs:paramA) http://xml.netbeans.org/schema/SynchronousSample

top

Functions for Working with Date and Time

The BPEL Mapper allows you to set constants and use time functions with the help of a graphical interface.

The Datetime menu of the BPEL Mapper is shown below.

Figure 8: The BPEL Mapper Datetime Menu

The BPEL Mapper Datetime Menu

Table 9: Functions for Working with Date and Time Usage

Name Description
current-time Returns current time
current-date Returns current date
current-dateTime Returns current date and time
Duration Literal String; allows for setting the time interval in the 'P1Y2M3DT4H5M6S' format.

top

Summary

Graphical representation offers easy analysis and seeing of XPath expressions. The BPEL Mapper is a tool that allows you to create and edit XPath expressions in a visual mode. The BPEL Mapper graphical interface allows you to set constants, use time functions, and work with predicates. The BPEL Mapper interface enables you to perform calculations using XPath operations and functions that are listed in this article over local and global variables, XSD elements and attributes, and parts.


top

See Also



top


This page was last modified: April 17, 2008

top

Bookmark this page

del.icio.us furl simpy slashdot technorati digg
Companion
Projects:
MySQL Database Server   Open JDK: an Open SourceJDK   GlassFish Community: an Open Source Application Server    Mobile & Embedded Community    Open Solaris   java.net - The Source for Java Technology Collaboration   Open ESB - The Open Enterprise Service Bus Powered by