2005-12-05 13:26:03

EXSLT - Strings

Copyright 2005 Fourthought, Inc. (USA). Detailed license and copyright information: http://4suite.org/COPYRIGHT Project home, documentation, distributions: http://4suite.org/

The str:align function aligns a string within another string.

See http://exslt.org/str/functions/align/str.align.html for further explanation.

The str:concat function takes a node set and returns the concatenation of the string values of the nodes in that node set. If the node set is empty, it returns an empty string.

The str:decode-uri function decodes a percent-encoded string, such as one would find in a URI.

The str:encode-uri function percent-encodes a string for embedding in a URI. The second argument is a boolean indicating whether to escape reserved characters; if true, the given string can be a URI already, with just some of its characters needing to be escaped (not recommended, but users who don't understand the nuances of the URI syntax tend to prefer it over assembling a URI piece-by-piece).

The str:padding function creates a padding string of a certain length.

The second argument gives a string to be used to create the padding. This string is repeated as many times as is necessary to create a string of the length specified by the first argument; if the string is more than a character long, it may have to be truncated to produce the required length. If no second argument is specified, it defaults to a space (' ').

The str:replace function converts a string to a node-set, with each instance of a substring from a given list (obtained from the string-values of nodes in the second argument) replaced by the node at the corresponding position of the node-set given as the third argument. Unreplaced substrings become text nodes.

The second and third arguments can be any type of object; if either is not a node-set, it is treated as if it were a node-set of just one text node, formed from the object's string-value.

Attribute and namespace nodes in the replacement set are erroneous but are treated as empty text nodes.

All occurrences of the longest substrings are replaced first, and once a replacement is made, that span of the original string is no longer eligible for future replacements.

An empty search string matches between every character of the original string.

See http://exslt.org/str/functions/replace/str.replace.html for details.

The str:split function splits up a string and returns a node set of token elements, each containing one token from the string.

The first argument is the string to be split. The second argument is a pattern string (default=' '). The string given by the first argument is split at any occurrence of this pattern. An empty string pattern will result in a split on every character in the string.

The str:tokenize function splits up a string and returns a node set of 'token' elements, each containing one token from the string.

The first argument is the string to be tokenized. The second argument is a string consisting of a number of characters. Each character in this string is taken as a delimiting character. The string given by the first argument is split at any occurrence of any of these characters.

Supports str:replace(). s is a string. replmap is a list of tuples, where each tuple is a search string and a replacement node or None. This recursive function will cause the original string to have occurrences of the search strings replaced with the corresponding node or deleted. When a replacement is made, that portion of the original string is no longer available for further replacements. All replacements are made for each search string before moving on to the next. Empty search strings match in between every character of the original string.

'http://exslt.org/strings'
{}
{('http://exslt.org/strings', 'align'): <function Align>, ('http://exslt.org/strings', 'concat'): <function Concat>, ('http://exslt.org/strings', 'decode-uri'): <function DecodeUri>, ('http://exslt.org/strings', 'encode-uri'): <function EncodeUri>, ('http://exslt.org/strings', 'padding'): <function Padding>, ('http://exslt.org/strings', 'replace'): <function Replace>, ('http://exslt.org/strings', 'split'): <function Split>, ('http://exslt.org/strings', 'tokenize'): <function Tokenize>}
{'http://exslt.org/strings': 'str'}
13