XPath helpers
In the Document pane of the Development Studio XPath transform editor, XPath helpers are used to create XPress expressions.
To facilitate the creation of XPath expressions, the common functions have been provided in drop-down menus. With the selection of the functions from these menus, the proper syntax for the function inserts in the Expression field.
All of the number functions return values in floating point format. If the description of the function says it returns an integer, the function actually returns the value in floating point format that is equivalent to the integer.
Tokens are inserted in an XPath expression to use context items for the transform.
Group | Function | Description | Syntax |
---|---|---|---|
String | String | Returns the value as a string | string(.) |
String | Concat | Concatenates a comma separated list of values into a single string Concatenating secure data with a string is not supported for use with basic and advanced XPATH or XSLT transforms. | concat(., 'text') |
String | Starts with | Returns a value of 'true' or 'false' indicating whether the sting begins with the specified text | starts-with(., 'text') |
String | Contains | Returns a value of 'true' or 'false' indicating whether the sting contains the specified text | contains(., 'text') |
String | Substring before | Returns the portion of the string that precedes the specified text | substring-before(., 'text') |
String | Substring after | Returns the portion of the string that succeeds the specified text | substring-after(., 'text') |
String | Substring | Returns a portion of the string, beginning at the numeric position specified | substring(., number) |
String | String length | Returns the number of characters in the string | string-length(.) |
String | Normalize space | Removes leading and trailing spaces from the string | normalize-space(.) |
String | Translate | Converts a string by replacing the characters in 'from' with the characters in 'to' | translate(.,'from','to') |
Boolean | Boolean | Returns a Boolean value | boolean(.) |
Boolean | Not | Returns the opposite Boolean value | not(.) |
Boolean | True | Returns the Boolean value 'true' | true() |
Boolean | False | Returns the Boolean value 'false' | false() |
Number | Number | Returns the value as a number | number(.) |
Number | Sum | Returns the sum of numeric values for the specified element | sum(.) |
Number | Floor | Returns, in floating point format, the largest integer that is not greater than the specified number. For example, floor(3.4) = 3.0 | floor(.) |
Number | Ceiling | Returns, in floating point format, the smallest integer that is greater than the specified number. For example, ceiling(3.4) = 4.0 | ceiling(.) |
Number | Round | Rounds the specified number to the nearest integer in floating point format. For example, round(3.4) = 3.0 | round(.) |
Operators | Less than or equal | Inserts the appropriate syntax for the function | <= |
Operators | Less than | Inserts the appropriate syntax for the function | < |
Operators | Greater than or equal | Inserts the appropriate syntax for the function | >= |
Operators | Greater than | Inserts the appropriate syntax for the function | > |
Operators | Equal | Inserts the appropriate syntax for the function | = |
Operators | Not equal | Inserts the appropriate syntax for the function | != |
Operators | Multiply | Inserts the appropriate syntax for the function | * |
Operators | Divide | Inserts the appropriate syntax for the function | div |
Operators | Modulus | Inserts the appropriate syntax for the function | mod |
Operators | Add | Inserts the appropriate syntax for the function | + |
Operators | Subtract | Inserts the appropriate syntax for the function | - |
Operators | And | Inserts the appropriate syntax for the function | and |
Operators | Or | Inserts the appropriate syntax for the function | or |
Position | Last | Returns the index of the last child node | last() |
Position | Position | Returns the position of the current node, relative to the parent node | position() |
Position | Count | Counts the number of nodes | count(.) |
Position | Name | Returns the element name | name(.) |
To insert the function syntax for an XPath Helper
In the Document pane, use the Group menu to select the group.
Use the Functions menu to select the function.
Click the Insert button.
Tip
Use these steps to insert additional function syntax. The syntax inserts at the cursor.
To insert tokens in an XPath expression
Position the cursor in the Expression field at the point of token insertion. To replace text in the current expression with the token, highlight the text to be replaced.
Use the Token Selector drop-down menu and select the token.
There are two choices in the drop-down menu for each token in the Tokens pane, one with the token name and one with -esc appended to the token name.
If a token represents a sequence of characters that are classified as XML special characters, choosing the token-esc option causes the XML special characters to be escaped.
For example:
< is converted to <
> is converted to >
The <token> choice is displayed with curly brackets ${tokenName}. The <token-esc> choice is displayed with square brackets $[tokenName].
Click the Preview button in the Document pane toolbar to execute the expression and display the Preview Drawer.
Comments
Log in or register to comment.