Xpath function key

Xpath is a powerfull tool but we use only small part of it(me the first). Everybody use string or count function but more function exist

Xpath query

Before introducing function, let’s talk about Xpath query.

To build Xpath query you need to respect this protocol :

Expression Description
nodename Selects all child nodes of the named node
/ Selects from the root node
// Selects nodes in the document from the current node that match the selection no matter where they are
. Selects the current node
.. Selects the parent of the current node
@ Selects attributes

You can find sample by openning a map. For getting your own query easily, open your schema in Visual Studio, select the choosen node. On the property Tab you’ve got a field Instance Xpath :

Here is a summary (you can found all function on the MSDN : http://msdn.microsoft.com/en-us/library/ms256138.aspx)

Node-Set Functions

Function Description
count Returns the number of nodes in the node-setargument.
id Selects elements by their unique ID.
last Returns a number equal to context size of the expression evaluation context.
local-name Returns the local part of the expanded name of the node in the node-setargument that is first in document order.
name Returns a string containing a QName representing the expanded name of the node in the node-set argument that is first in document order.
namespace-uri 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.
position Returns the index number of the node within the parent.

 

Note : Some function are unusable in an orchestration : id, last, position

String Functions

Function Description
concat Returns the concatenation of the arguments.
contains Returns true if the first argument string contains the second argument string; otherwise returns false.
normalize-space Returns the argument string with the white space stripped.
starts-with Returns true if the first argument string starts with the second argument string; otherwise returns false.
string Converts an object to a string.
string-length Returns the number of characters in the string.
substring Returns the substring of the first argument starting at the position specified in the second argument and the length specified in the third argument.
substring-after Returns the substring of the first argument string that follows the first occurrence of the second argument string in the first argument string.
substring-before Returns the substring of the first argument string that precedes the first occurrence of the second argument string in the first argument string.
translate 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

Function Description
boolean Converts the argument to a Boolean.
false Returns false.
lang Returns true if the xml:lang attribute of the context node is the same as the argument string.
not Returns true if the argument is false, otherwise, false.
true Returns true.

Number Functions

ceiling Returns the smallest integer that is not less than the argument.
floor Returns the largest integer that is not greater than the argument.
number Converts the argument to a number.
round Returns an integer closest in value to the argument.
sum Returns the sum of all nodes in the node-set. Each node is first converted to a number value before summing.

Microsoft XPath Extension Functions

XPath Extension Functions for XSD Support

Function Description
ms:type-is Compares the current node’s data type against the specified node type.
ms:type-local-name ([node-set]) Returns the nonqualified name of the XSD type of the current node or the first node (in document order) in the provided node-set.
ms:type-namespace-uri ([node-set]) Returns the namespace URI associated with the XSD type of a current node or the first node (in document order) in the provided node-set.
ms:schema-info-available Returns true if XSD information is available for a current node.

XPath Extension Functions of Miscellaneous Utilities

Function Description
ms:string-compare Performs lexicographical string comparison.
ms:utc Converts the prefixed date/time related values into Coordinated Universal Time and into a fixed (normalized) representation that can be sorted and compared lexicographically.
ms:namespace-uri Resolves the prefix part of a qualified name into a namespace URI.
ms:local-name Returns the local name part of a qualified name by stripping out the namespace prefix.
ms:number Takes a string argument in XSD format and converts it into an XPath number.
ms:format-date Converts standard XSD date formats to characters suitable for output.
ms:format-time Converts standard XSD time formats to characters suitable for output.

Laisser un commentaire

Choisissez une méthode de connexion pour poster votre commentaire:

Logo WordPress.com

Vous commentez à l'aide de votre compte WordPress.com. Déconnexion / Changer )

Image Twitter

Vous commentez à l'aide de votre compte Twitter. Déconnexion / Changer )

Photo Facebook

Vous commentez à l'aide de votre compte Facebook. Déconnexion / Changer )

Photo Google+

Vous commentez à l'aide de votre compte Google+. Déconnexion / Changer )

Connexion à %s