BizTalk Working With XPath – XPath 1.0 Function Library Quick Reference

Posted: August 29, 2009 in BizTalk
Tags: ,

You can use XML Path Language (Xpath) functions to refine XPath queries and enhance the programming power and flexibility of XPath.

The functions are divided into the following groups: Node Set, String, Boolean and Number

Node Set Functions

Node-set functions take a node-set argument. They return a node-set, or information about a particular node within a node-set.

Function: [number] last() – Returns a number equal to context size of the expression evaluation context.

Function: [number] position() – Returns the position, or index number, of the node, relative to all the selected nodes in the node list.

Function: [number] count(node-set) – Returns the number of nodes in the node-set argument.

Function: [node-set] id(object) – Selects elements by their unique ID.

Function: [string] local-name(node-set?) – Returns the local part of the expanded name of the node in the node-set argument that is first in document order.

Function: [string] namespace-uri(node-set?) – Returns the namespace Uniform Resource Identifier (URI) of the expanded name of the node in the node-set argument that is first in document order.

Function: [string] name(node-set?) – Returns a string containing a QName representing the expanded name of the node in the node-set argument that is first in document order.

String Functions

String functions are used to evaluate, format, and manipulate string arguments, or to convert an object to a string.

Function: [string] string(object?) – Converts an object to a string.

Function: [string] concat(string, string, string*) – Returns the concatenation of the arguments.

Function: [boolean] starts-with(string, string) – Returns true if the first argument string starts with the second argument string; otherwise returns false.

Function: [boolean] contains(string, string) – Checks whether the first argument string contains the second argument string.

Function: [string] substring-before(string, string) – Returns the substring of the first argument string that precedes the first occurrence of the second argument string in the first argument string, or the empty string if the first argument string does not contain the second argument string.

Function: [string] substring-after(string, string) – Returns the substring of the first argument string that follows the first occurrence of the second argument string in the first argument string, or the empty string if the first argument string does not contain the second argument string.

Function: [string] substring(string, number, number?) – Returns the substring of the first argument starting at the position specified in the second argument and the length specified in the third argument.

Function: [number] string-length(string?) – Returns the number of characters in the string.

Function: [string] normalize-space(string?) – Returns the argument string with the leading, trailing, and repeating white spaces stripped.

Function: [string] translate(string, string, string) – Returns the first argument string with occurrences of characters in the second argument string replaced by the character at the corresponding position in the third argument string.

  • Example: translate(’12:30′,’30’,’45’) Result: ’12:45′
  • Example: translate(’12:30′,’03’,’54’) Result: ’12:45′
  • Example: translate(’12:30′,’0123′,’abcd’) Result: ‘bc:da’
  • Ref: http://msdn.microsoft.com/en-us/library/ms256119.aspx

Boolean Functions

The XML Path Language (XPath) syntax supports Boolean functions that return strings or numbers, and can be used with comparison operators in filter patterns.

Function: [boolean] boolean(object) – Converts the argument to a Boolean.

Function: [boolean] not(object) – Returns true if the argument is false; otherwise false.

Function: [boolean] true() – Returns true.

Function: [boolean] false() – Returns false.

Function: [boolean] lang(string) – Returns true if the xml:lang attribute of the context node is the same as a sublanguage of the language specified by the argument string.

Number Functions

The XML Path Language (XPath) syntax supports Number functions that return strings or numbers and can be used with comparison operators in filter patterns.

Function: [number] number(object?) – Converts the argument to a number.

Function: [number] sum(node-set) – Returns the sum of all nodes in the node-set. Each node is first converted to a number value before summing.

Function: [number] floor(number) – Returns the largest integer that is not greater than the argument.

Function: [number] ceiling(number) – Returns the smallest integer that is not less than the argument.

Function: [number] round(number) – Returns an integer closest in value to the argument.

Tags: BizTalk | XPath

Comments
  1. […] BizTalk Working With XPath – XPath 1.0 Function Library Quick Reference  […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s