BizTalk Working With XPath – XPath 1.0 Function Library Quick Reference

Posted: August 29, 2009  |  Categories: BizTalk

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.

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.

Author: Sandro Pereira

Sandro Pereira lives in Portugal and works as a consultant at DevScope. In the past years, he has been working on implementing Integration scenarios both on-premises and cloud for various clients, each with different scenarios from a technical point of view, size, and criticality, using Microsoft Azure, Microsoft BizTalk Server and different technologies like AS2, EDI, RosettaNet, SAP, TIBCO etc. He is a regular blogger, international speaker, and technical reviewer of several BizTalk books all focused on Integration. He is also the author of the book “BizTalk Mapping Patterns & Best Practices”. He has been awarded MVP since 2011 for his contributions to the integration community.

2 thoughts on “BizTalk Working With XPath – XPath 1.0 Function Library Quick Reference”

Leave a Reply

Your email address will not be published. Required fields are marked *

BizTalk360
BizTalk Server

Over 500+ customers across
30+ countries depend on BizTalk360

Learn More
Serverless360
Azure

Manage and monitor serverless
components effortlessly

Learn More
Atomicscope
Business Users

Monitor your Business Activity in iPaaS
or Hybrid integration solutions

Learn More

Back to Top