# Extension Module - XsltBuiltins

## Namespaces

The namespaces for extensions defined in this document are:

Prefix | Namespace
--- | ---
`date` | `http://exslt.org/dates-and-times`
`dyn` | `http://exslt.org/dynamic`
`exsl` | `http://exslt.org/common`
`f` | `http://xmlns.4suite.org/ext`
`func` | `http://exslt.org/functions`
`math` | `http://exslt.org/math`
`regexp` | `http://exslt.org/regular-expressions`
`set` | `http://exslt.org/sets`
`str` | `http://exslt.org/strings`

The prefixes are given for this document only. Any other prefix can be used within a particular stylesheet.

## Functions

Function | Syntax
--- | ---
date:add | unknown date:add(dateTime, duration)
date:add-duration | unknown date:add-duration(duration1, duration2)
date:date | unknown date:date(dateTime)
date:date-time | unknown date:date-time()
date:day-abbreviation | unknown date:day-abbreviation(dateTime)
date:day-in-month | unknown date:day-in-month(dateTime)
date:day-in-week | unknown date:day-in-week(dateTime)
date:day-in-year | unknown date:day-in-year(dateTime)
date:day-name | unknown date:day-name(dateTime)
date:day-of-week-in-month | unknown date:day-of-week-in-month(dateTime)
date:difference | unknown date:difference(start, end)
date:duration | unknown date:duration(seconds)
date:format-date | unknown date:format-date(dateTime, pattern)
date:hour-in-day | unknown date:hour-in-day(dateTime)
date:leap-year | unknown date:leap-year(dateTime)
date:minute-in-hour | unknown date:minute-in-hour(dateTime)
date:month-abbreviation | unknown date:month-abbreviation(dateTime)
date:month-in-year | unknown date:month-in-year(dateTime)
date:month-name | unknown date:month-name(dateTime)
date:second-in-minute | unknown date:second-in-minute(dateTime)
date:seconds | unknown date:seconds(string)
date:sum | unknown date:sum(nodeset)
date:time | unknown date:time(dateTime)
date:week-in-month | unknown date:week-in-month(dateTime)
date:week-in-year | unknown date:week-in-year(dateTime)
date:year | unknown date:year(dateTime)
dyn:closure | unknown dyn:closure(nodeset, string)
dyn:evaluate | unknown dyn:evaluate(string)
dyn:map | unknown dyn:map(nodeset, string)
dyn:max | unknown dyn:max(nodeset, string)
dyn:min | unknown dyn:min(nodeset, string)
dyn:sum | unknown dyn:sum(nodeset, string)
exsl:node-set | unknown exsl:node-set(obj)
exsl:object-type | unknown exsl:object-type(obj)
f:doc-as-string | unknown f:doc-as-string(obj, encoding)
f:key | unknown f:key(qname, keyList, realContextNode)
f:lookup | unknown f:lookup(name, key)
f:map | unknown f:map(funcname)
f:search-re | unknown f:search-re(pattern, arg)
f:serialize-xml | unknown f:serialize-xml(nodeset, method, omitxmldecl)
f:split | unknown f:split(arg, delim)
math:abs | unknown math:abs(num)
math:acos | unknown math:acos(num)
math:asin | unknown math:asin(num)
math:atan | unknown math:atan(num)
math:atan2 | unknown math:atan2(y, x)
math:constant | unknown math:constant(name, precision)
math:cos | unknown math:cos(num)
math:exp | unknown math:exp(num)
math:highest | unknown math:highest(nodeset)
math:log | unknown math:log(num)
math:lowest | unknown math:lowest(nodeset)
math:max | unknown math:max(nodeset)
math:min | unknown math:min(nodeset)
math:power | unknown math:power(base, exponent)
math:random | unknown math:random()
math:sin | unknown math:sin(num)
math:sqrt | unknown math:sqrt(num)
math:tan | unknown math:tan(num)
regexp:match | unknown regexp:match(source, pattern, flags)
regexp:replace | unknown regexp:replace(source, pattern, flags, repl)
regexp:test | unknown regexp:test(source, pattern, flags)
set:difference | unknown set:difference(nodes1, nodes2)
set:distinct | unknown set:distinct(nodeset)
set:has-same-node | unknown set:has-same-node(ns1, ns2)
set:intersection | unknown set:intersection(ns1, ns2)
set:leading | unknown set:leading(ns1, ns2)
set:trailing | unknown set:trailing(ns1, ns2)
str:align | unknown str:align(target, padding, alignment)
str:concat | unknown str:concat(nodeset)
str:decode-uri | unknown str:decode-uri(uri, encoding)
str:encode-uri | unknown str:encode-uri(uri, escapeReserved, encoding)
str:padding | unknown str:padding(length, chars)
str:replace | unknown str:replace(s, searchNodes, replNodes)
str:split | unknown str:split(string, pattern)
str:tokenize | unknown str:tokenize(string, delimiters)

## Elements

Element | Syntax
--- | ---

exsl:document

<exsl:document
href = { uri-reference }
cdata-section-elements = { qnames }
doctype-public = { string }
doctype-system = { string }
encoding = { string }
f:overwrite-safeguard = { "yes" | "no" }
f:utfbom = { "yes" | "no" }
indent = { "yes" | "no" }
media-type = { string }
method = { qname }
omit-xml-declaration = { "yes" | "no" }
standalone = { "yes" | "no" }
version = { nmtoken }
<!-- Content: template -->
/>

f:apply-imports | <f:apply-imports <!-- Content: xsl:with-param* --> />
f:apply-templates | <f:apply-templates mode = { qname } select = expression <!-- Content: (xsl:sort | xsl:with-param)* --> />
f:assign | <f:assign name = qname body-as-ns = { "yes" | "no" } select = expression <!-- Content: template --> />
f:chain-to | <f:chain-to href = { uri-reference } <!-- Content: xsl:with-param* --> />
f:create-index | <f:create-index name = { string } select = expression use = expression <!-- Content: template --> />
f:dump-keys | <f:dump-keys force-update = { "yes" | "no" } raw = { "yes" | "no" } <!-- Content: template --> />
f:dump-vars | <f:dump-vars raw = { "yes" | "no" } <!-- Content: template --> />
f:gettext | <f:gettext <!-- Content: template --> />
f:message-control | <f:message-control suppress = { "yes" | "no" } <!-- Content: template --> />
f:output | <f:output cdata-section-elements = { qnames } doctype-public = { string } doctype-system = { string } encoding = { string } indent = { "yes" | "no" } media-type = { string } method = { qname } omit-xml-declaration = { "yes" | "no" } standalone = { "yes" | "no" } version = { nmtoken } <!-- Content: template --> />
f:raw-text-output | <f:raw-text-output select = expression <!-- Content: template --> />
f:replace | <f:replace substring = string-expression string = string-expression <!-- Content: template --> />
f:setup-translations | <f:setup-translations domain = { string } localedir = { string } <!-- Content: template --> />
f:uri-to-element | <f:uri-to-element default-name = { qname } uri = { uri-reference } default-namespace = { uri-reference } use-attribute-sets = qnames <!-- Content: template --> />
func:function | <func:function name = qname-but-not-ncname <!-- Content: (xsl:param*, template) --> />
func:result | <func:result select = expression <!-- Content: template --> />

## Functions

### Function - date:add

#### Function Syntax

unknown date:add(dateTime, duration)

The date:add function returns the result of adding a duration to a dateTime. Implements version 2.

### Function - date:add-duration

#### Function Syntax

unknown date:add-duration(duration1, duration2)

The date:add-duration function returns the duration resulting from adding two durations together. Implements version 2.

### Function - date:date

#### Function Syntax

unknown date:date(dateTime)

The date:date function returns the date portion of the dateTime argument if present, or of the current local date/time. The argument can be given in xs:dateTime or xs:date format. Implements version 2.

### Function - date:date-time

#### Function Syntax

unknown date:date-time()

The date:date-time function returns the current local date/time as an ISO 8601 formatted date/time string, with a time zone. Implements version 1.

### Function - date:day-abbreviation

#### Function Syntax

unknown date:day-abbreviation(dateTime)

The date:day-abbreviation function returns the English abbreviation for the day name of a given date. Implements version 2.

### Function - date:day-in-month

#### Function Syntax

unknown date:day-in-month(dateTime)

The date:day-in-month function returns the numerical date, i.e. 27 for the 27th of March. Implements version 2.

### Function - date:day-in-week

#### Function Syntax

unknown date:day-in-week(dateTime)

The date:day-in-week function returns a number representing the weekday of a given date. Sunday is 1, Saturday is 7. Implements version 2.

### Function - date:day-in-year

#### Function Syntax

unknown date:day-in-year(dateTime)

The date:day-in-year function returns a number representing the position of a date in the year. Implements version 2.

### Function - date:day-name

#### Function Syntax

unknown date:day-name(dateTime)

The date:day-name function returns the full English day name of a given date. Implements version 2.

### Function - date:day-of-week-in-month

#### Function Syntax

unknown date:day-of-week-in-month(dateTime)

The date:day-of-week-in-month function returns the day-of-the-week in a month of a date as a number (e.g. 3 for the 3rd Tuesday in May). Implements version 2.

### Function - date:difference

#### Function Syntax

unknown date:difference(start, end)

The date:difference function returns the difference between the first date and the second date as a duration in string form. Implements version 1.

### Function - date:duration

#### Function Syntax

unknown date:duration(seconds)

The date:duration function returns a duration string representing the number of seconds specified by the argument string. If no argument is given, then the result of calling date:seconds without any arguments is used as a default argument. Implements version 1.

### Function - date:format-date

#### Function Syntax

unknown date:format-date(dateTime, pattern)

The date:format-date function formats a date/time according to a pattern. The first argument to date:format-date specifies the date/time to be formatted. It must be right or left-truncated date/time strings in one of the formats defined in XML Schema Part 2: Datatypes. The permitted formats are as follows: xs:dateTime, xs:date, xs:time, xs:gYearMonth, xs:gYear, xs:gMonthDay, xs:gMonth and xs:gDay. The second argument is a string that gives the format pattern used to format the date. The format pattern must be in the syntax specified by the JDK 1.1 SimpleDateFormat class. The format pattern string is interpreted as described for the JDK 1.1 SimpleDateFormat class. Implements version 2.

### Function - date:hour-in-day

#### Function Syntax

unknown date:hour-in-day(dateTime)

The date:hour-in-date function returns the hour portion of a date- time string as an integer. Implements version 2.

### Function - date:leap-year

#### Function Syntax

unknown date:leap-year(dateTime)

The date:leap-year function returns true if the year argument (defaults to current year) is a leap year, false otherwise. Implements version 1.

### Function - date:minute-in-hour

#### Function Syntax

unknown date:minute-in-hour(dateTime)

The date:minute-in-hour function returns the minute portion of a date-time string as an integer. Implements version 2.

### Function - date:month-abbreviation

#### Function Syntax

unknown date:month-abbreviation(dateTime)

The date:month-abbreviation function returns the abbreviation of the month of a date. Implements version 2.

### Function - date:month-in-year

#### Function Syntax

unknown date:month-in-year(dateTime)

The date:month-in-year function returns the month portion of the dateTime argument (defaults to current month) as an integer. Implements version 2.

### Function - date:month-name

#### Function Syntax

unknown date:month-name(dateTime)

The date:month-name function returns the full English name of the month portion of a date. Implements version 2.

### Function - date:second-in-minute

#### Function Syntax

unknown date:second-in-minute(dateTime)

The date:second-in-minute function returns the seconds portion of a date-time string as an integer. Implements version 2.

### Function - date:seconds

#### Function Syntax

unknown date:seconds(string)

The date:seconds function returns the number of seconds specified by the argument string. If no argument is given, then the current local date/time, as returned by date:date-time is used as a default argument. Implements version 1.

### Function - date:sum

#### Function Syntax

unknown date:sum(nodeset)

The date:sum function adds a set of durations together. The string values of the nodes in the node set passed as an argument are interpreted as durations and added together as if using the date:add-duration function. Implements version 1.

### Function - date:time

#### Function Syntax

unknown date:time(dateTime)

The date:time function returns the time portion of the dateTime argument if present, or of the current local date/time. The argument can be given in xs:dateTime or xs:time format. Implements version 2.

### Function - date:week-in-month

#### Function Syntax

unknown date:week-in-month(dateTime)

The date:week-in-month function returns the week in a month of a date as a number. If no argument is given, then the current local date/time, as returned by date:date-time is used the default argument. For the purposes of numbering, the first day of the month is in week 1 and new weeks begin on a Monday (so the first and last weeks in a month will often have less than 7 days in them). Implements version 3.

### Function - date:week-in-year

#### Function Syntax

unknown date:week-in-year(dateTime)

The date:week-in-year function returns a number representing the week of the year a date is in. Implements version 3.

### Function - date:year

#### Function Syntax

unknown date:year(dateTime)

The date:year function returns the year portion of the dateTime supplied, or of the current year, as an integer. Implements version 2.

### Function - dyn:closure

#### Function Syntax

unknown dyn:closure(nodeset, string)

The dyn:closure function creates a node set resulting from transitive closure of evaluating the expression passed as the second argument on each of the nodes passed as the first argument, then on the node set resulting from that and so on until no more nodes are found. http://www.exslt.org/dyn/functions/closure/index.html

### Function - dyn:evaluate

#### Function Syntax

unknown dyn:evaluate(string)

The dyn:evaluate function evaluates a string as an XPath expression and returns the resulting value, which might be a boolean, number, string, node set, result tree fragment or external object. The sole argument is the string to be evaluated. If the string is an invalid XPath expression, an empty node-set is returned. http://www.exslt.org/dyn/functions/evaluate/index.html

### Function - dyn:map

#### Function Syntax

unknown dyn:map(nodeset, string)

The dyn:map function evaluates the expression passed as the second argument for each of the nodes passed as the first argument, and returns a node set of those values. http://www.exslt.org/dyn/functions/map/index.html

### Function - dyn:max

#### Function Syntax

unknown dyn:max(nodeset, string)

The dyn:max function calculates the maximum value for the nodes passed as the first argument, where the value of each node is calculated dynamically using an XPath expression passed as a string as the second argument. http://www.exslt.org/dyn/functions/max/index.html

### Function - dyn:min

#### Function Syntax

unknown dyn:min(nodeset, string)

The dyn:min function calculates the minimum value for the nodes passed as the first argument, where the value of each node is calculated dynamically using an XPath expression passed as a string as the second argument. http://www.exslt.org/dyn/functions/min/index.html

### Function - dyn:sum

#### Function Syntax

unknown dyn:sum(nodeset, string)

The dyn:sum function calculates the sum for the nodes passed as the first argument, where the value of each node is calculated dynamically using an XPath expression passed as a string as the second argument. http://www.exslt.org/dyn/functions/sum/index.html

### Function - exsl:node-set

#### Function Syntax

unknown exsl:node-set(obj)

The purpose of the exsl:node-set function is to return a node-set from a result tree fragment. If the argument is a node-set already, it is simply returned as is. If the argument to exsl:node-set is not a node-set or a result tree fragment, then it is converted to a string as by the string() function, and the function returns a node-set consisting of a single text node with that string value. The exsl:node-set function does not have side-effects: the result tree fragment used as an argument is still available as a result tree fragment after it is passed as an argument to exsl:node-set.

### Function - exsl:object-type

#### Function Syntax

unknown exsl:object-type(obj)

The exsl:object-type function returns a string giving the type of the object passed as the argument. The possible object types are: 'string', 'number', 'boolean', 'node-set', 'RTF' or 'external'.

### Function - f:doc-as-string

#### Function Syntax

unknown f:doc-as-string(obj, encoding)

Retrieves a document, similar to the document() function, but returns the document as an XPath string object rather than as a node-set. Security note: if the associated URI resolver allows file: URLs, this extension could be used to read arbitrary system files

### Function - f:key

#### Function Syntax

unknown f:key(qname, keyList, realContextNode)

Query an XSLT key, but allow the user to override the context node for purposes of determining which source document to check. realContextNode is a node set from which the first node is extracted And used as the context node

### Function - f:lookup

#### Function Syntax

unknown f:lookup(name, key)

f:lookup() queries an index as defined by f:create-index.

### Function - f:map

#### Function Syntax

unknown f:map(funcname)

Apply the function serially over the given node sets. In iteration i, the function is passed N parameters where N is the number of argument node sets. Each parameter is a node set of size 1, whose node is the ith node of the corresponding argument node set. The return value is a node set consisting of a series of result-tree nodes, each of which is a text node whose value is the string value of the result of the ith function invocation. Warning: this function uses the implied ordering of the node set Based on its implementation as a Python list. But in reality There is no reliable ordering of XPath node sets. Therefore this function is not recommended for use with more than one node set parameter.

### Function - f:search-re

#### Function Syntax

unknown f:search-re(pattern, arg)

Do a regular expression search against the argument (i.e. get all matches)

### Function - f:serialize-xml

#### Function Syntax

unknown f:serialize-xml(nodeset, method, omitxmldecl)

f:serialize-xml() takes a node set and turns it into a string representing the serialization of the node set, obtained by concatenating the serialization of each node in the node set in document order. See also: XPath (not XSLT) extension function f:parse-xml()

### Function - f:split

#### Function Syntax

unknown f:split(arg, delim)

DEPRECATED. Equivalent to EXSLT's str:split(). Splits a string according to a sub-string and return a node set of elements nodes, each of which is named "Split" and contains the split text For example f:split('A,B,C,') returns a node set of "Split" nodes having text nodes with values "A", "B" and "C" arg - converted to a string, is the string to split up delim - the delimiter upon which to split, defaults to " "

### Function - math:abs

#### Function Syntax

unknown math:abs(num)

The math:abs function returns the absolute value of a number.

### Function - math:acos

#### Function Syntax

unknown math:acos(num)

The math:acos function returns the arccosine value of a number.

### Function - math:asin

#### Function Syntax

unknown math:asin(num)

The math:asin function returns the arcsine value of a number.

### Function - math:atan

#### Function Syntax

unknown math:atan(num)

The math:atan function returns the arctangent value of a number.

### Function - math:atan2

#### Function Syntax

unknown math:atan2(y, x)

The math:atan2 function returns the angle ( in radians ) from the X axis to a point (y,x).

### Function - math:constant

#### Function Syntax

unknown math:constant(name, precision)

The math:constant function returns the specified constant to a set precision.

### Function - math:cos

#### Function Syntax

unknown math:cos(num)

The math:cos function returns cosine of the passed argument.

### Function - math:exp

#### Function Syntax

unknown math:exp(num)

The math:exp function returns e (the base of natural logarithms) raised to a power.

### Function - math:highest

#### Function Syntax

unknown math:highest(nodeset)

The math:highest function returns the nodes in the node set whose value is the maximum value for the node set. The maximum value for the node set is the same as the value as calculated by math:max. A node has this maximum value if the result of converting its string value to a number as if by the number function is equal to the maximum value, where the equality comparison is defined as a numerical comparison using the = operator.

### Function - math:log

#### Function Syntax

unknown math:log(num)

The math:log function returns the natural logarithm of a number.

### Function - math:lowest

#### Function Syntax

unknown math:lowest(nodeset)

The math:lowest function returns the nodes in the node set whose value is the minimum value for the node set. The minimum value for the node set is the same as the value as calculated by math:min. A node has this minimum value if the result of converting its string value to a number as if by the number function is equal to the minimum value, where the equality comparison is defined as a numerical comparison using the = operator.

### Function - math:max

#### Function Syntax

unknown math:max(nodeset)

The math:max function returns the maximum value of the nodes passed as the argument.

### Function - math:min

#### Function Syntax

unknown math:min(nodeset)

The math:min function returns the minimum value of the nodes passed as the argument.

### Function - math:power

#### Function Syntax

unknown math:power(base, exponent)

The math:power function returns the value of a base expression taken to a specified power.

### Function - math:random

#### Function Syntax

unknown math:random()

The math:random function returns a random number from 0 to 1.

### Function - math:sin

#### Function Syntax

unknown math:sin(num)

The math:sin function returns the sine of the number.

### Function - math:sqrt

#### Function Syntax

unknown math:sqrt(num)

The math:sqrt function returns the square root of a number.

### Function - math:tan

#### Function Syntax

unknown math:tan(num)

The math:tan function returns the tangent of the number passed as an argument.

### Function - regexp:match

#### Function Syntax

unknown regexp:match(source, pattern, flags)

The regexp:match function lets you get hold of the substrings of the string passed as the first argument that match the captured parts of the regular expression passed as the second argument. The second argument is a regular expression that follows the Javascript regular expression syntax. The third argument is a string consisting of character flags to be used by the match. If a character is present then that flag is true. The flags are: g: global match - the submatches from all the matches in the string are returned. If this character is not present, then only the submatches from the first match in the string are returned. i: case insensitive - the regular expression is treated as case insensitive. If this character is not present, then the regular expression is case sensitive. The regexp:match function returns a node set of 'match' elements, each of whose string value is equal to a portion of the first argument string that was captured by the regular expression. If the match is not global, the first match element has a value equal to the portion of the string matched by the entire regular expression.

### Function - regexp:replace

#### Function Syntax

unknown regexp:replace(source, pattern, flags, repl)

The regexp:replace function replaces the parts of a string that match a regular expression with another string. The first argument is the string to be matched and replaced. The second argument is a regular expression that follows the Javascript regular expression syntax. The fourth argument is the string to replace the matched parts of the string. The third argument is a string consisting of character flags to be used by the match. If a character is present then that flag is true. The flags are: g: global replace - all occurrences of the regular expression in the string are replaced. If this character is not present, then only the first occurrence of the regular expression is replaced. i: case insensitive - the regular expression is treated as case insensitive. If this character is not present, then the regular expression is case sensitive.

### Function - regexp:test

#### Function Syntax

unknown regexp:test(source, pattern, flags)

The regexp:test function returns true if the string given as the first argument matches the regular expression given as the second argument. The second argument is a regular expression that follows the Javascript regular expression syntax. The third argument is a string consisting of flags to be used by the test. If a character is present then that flag is true. The flags are: g: global test - has no effect on this function, but is retained for consistency with regexp:match and regexp:replace. i: case insensitive - the regular expression is treated as case insensitive. If this character is not present, then the regular expression is case sensitive.

### Function - set:difference

#### Function Syntax

unknown set:difference(nodes1, nodes2)

The set:difference function returns the difference between two node sets - those nodes that are in the node set passed as the first argument that are not in the node set passed as the second argument.

### Function - set:distinct

#### Function Syntax

unknown set:distinct(nodeset)

The set:distinct function returns a subset of the nodes contained in the node-set NS passed as the first argument. Specifically, it selects a node N if there is no node in NS that has the same string value as N, and that precedes N in document order.

### Function - set:has-same-node

#### Function Syntax

unknown set:has-same-node(ns1, ns2)

The set:has-same-node function returns true if the node set passed as the first argument shares any nodes with the node set passed as the second argument. If there are no nodes that are in both node sets, then it returns false.

### Function - set:intersection

#### Function Syntax

unknown set:intersection(ns1, ns2)

The set:intersection function returns a node set comprising the nodes that are within both the node sets passed as arguments to it.

### Function - set:leading

#### Function Syntax

unknown set:leading(ns1, ns2)

The set:leading function returns the nodes in the node set passed as the first argument that precede, in document order, the first node in the node set passed as the second argument. If the first node in the second node set is not contained in the first node set, then an empty node set is returned. If the second node set is empty, then the first node set is returned.

### Function - set:trailing

#### Function Syntax

unknown set:trailing(ns1, ns2)

The set:trailing function returns the nodes in the node set passed as the first argument that follow, in document order, the first node in the node set passed as the second argument. If the first node in the second node set is not contained in the first node set, then an empty node set is returned. If the second node set is empty, then the first node set is returned.

### Function - str:align

#### Function Syntax

unknown str:align(target, padding, alignment)

The str:align function aligns a string within another string. See http://exslt.org/str/functions/align/str.align.html for further explanation.

### Function - str:concat

#### Function Syntax

unknown str:concat(nodeset)

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.

### Function - str:decode-uri

#### Function Syntax

unknown str:decode-uri(uri, encoding)

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

### Function - str:encode-uri

#### Function Syntax

unknown str:encode-uri(uri, escapeReserved, encoding)

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).

### Function - str:padding

#### Function Syntax

unknown str:padding(length, chars)

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 (' ').

### Function - str:replace

#### Function Syntax

unknown str:replace(s, searchNodes, replNodes)

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.

### Function - str:split

#### Function Syntax

unknown str:split(string, pattern)

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.

### Function - str:tokenize

#### Function Syntax

unknown str:tokenize(string, delimiters)

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.

## Elements

### Element - exsl:document

#### Element Syntax

<exsl:document
href = { uri-reference }
cdata-section-elements = { qnames }
doctype-public = { string }
doctype-system = { string }
encoding = { string }
f:overwrite-safeguard = { "yes" | "no" }
f:utfbom = { "yes" | "no" }
indent = { "yes" | "no" }
media-type = { string }
method = { qname }
omit-xml-declaration = { "yes" | "no" }
standalone = { "yes" | "no" }
version = { nmtoken }
<!-- Content: template -->
/>

For the basic specification, see: http://www.exslt.org/exsl/elements/document/index.html The only URI scheme supported by 4Suite currently is 'file:' Security note: As a precaution, if you try to overwrite an existing file, it will be saved to a temporary file (there will be a warning with the file name). If this this precaution fails, the instruction will abort. You can override this precaution, always allowing the function to overwrite a document by using the f:overwrite-okay extension attribute.

### Element - f:apply-imports

#### Element Syntax

<f:apply-imports
<!-- Content: xsl:with-param* -->
/>

The f:apply-imports element is an extension of the xsl:apply-imports element. It differs from xsl:apply-imports in the following way: The element accepts xsl:with-param children that designate parameters that will be passed to the applied templates.

### Element - f:apply-templates

#### Element Syntax

<f:apply-templates
mode = { qname }
select = expression
<!-- Content: (xsl:sort | xsl:with-param)* -->
/>

The f:apply-templates element is an extension of the xsl:apply-templates element. It differs from xsl:apply-templates in the following way: The value of the mode attribute is an attribute value template rather than a static string. Thus, the mode can be computed at run time.

### Element - f:assign

#### Element Syntax

<f:assign
name = qname
body-as-ns = { "yes" | "no" }
select = expression
<!-- Content: template -->
/>

The f:assign element works like xsl:variable, but forces both a local and a global variable binding, replacing any other in-scope bindings having the same expanded-name. Thus, it can be used to circumvent XSLT's restriction on variables not being reassignable. However, its use is not recommended, for reasons explained below. As with xsl:variable, the name of the variable is given in the mandatory name attribute, and the new value may be given either by an expression in the select attribute, or by instantiating the content of the element. If no select attribute is given, then a body-as-ns attribute may be used to indicate whether to assign the variable to the contents as a node-set (value 'yes') or as a result tree fragment (default, or value 'no'). In either case, be aware that the node-set or result tree fragment will have a root node. Note that reassignment of variables is generally never actually needed. Before using f:assign, read the XSL FAQ or ask on xsl-list if there is a better, more portable way to solve your problem. XSLT is designed as a language that is free of side-effects, which is why assignment is not allowed and variables have very specific scope. When variable assignment is allowed, certain optimizations in the XSLT processor become impossible. Also, there are some circumstances in which the order of execution may not be quite what you expect, in which case f:assign may show anomalous behavior. It does not work predictably when called from within a tail-recursive template, for example. That said, f:assign can be a convenient way to create a node-set from a result tree fragment in XSLT 1.0. The proper way to do this is with EXSLT: <xsl:variable name="rtf"><foo/></xsl:variable> <xsl:variable name="ns" select="exsl:node-set($rtf)" xmlns:exsl="http://exslt.org/common"/> but f:assign can do it in one step: <f:assign name="ns" body-as-ns="yes"><foo/></f:assign>

### Element - f:chain-to

#### Element Syntax

<f:chain-to
href = { uri-reference }
<!-- Content: xsl:with-param* -->
/>

f:chain-to tells the processor to apply the output of the current stylsheet as the input of another stylesheet, establishing a chain of transforms. The next stylesheet in the chain is specified using an AVT, which allows for dynamically constructed chains. Children can be xsl:with-param elements, in which case the specified values are passed on to the next stylesheet as top-level parameters Warning: if the href attribute is blank, it will chain back to this same stylesheet and could lead to an infinite loop. FIXME: Trap this condition

### Element - f:create-index

#### Element Syntax

<f:create-index
name = { string }
select = expression
use = expression
<!-- Content: template -->
/>

f:create-index allows one to create an arbitrary key at run time using any node data. It is similar to xsl:key, except that it is computed on demand at run-time, and uses an XPath selection rather than an XSLT match, which gives more flexibility over what is indexed. These keys can be accessed using the extension function f:lookup(). Avoid making a dynamic index have the same name as a proper xsl:key. In particular this will confuse tools such as the <f:dump-keys/> diagnostic extension.

### Element - f:dump-keys

#### Element Syntax

<f:dump-keys
force-update = { "yes" | "no" }
raw = { "yes" | "no" }
<!-- Content: template -->
/>

### Element - f:dump-vars

#### Element Syntax

<f:dump-vars
raw = { "yes" | "no" }
<!-- Content: template -->
/>

### Element - f:gettext

#### Element Syntax

<f:gettext
<!-- Content: template -->
/>

### Element - f:message-control

#### Element Syntax

<f:message-control
suppress = { "yes" | "no" }
<!-- Content: template -->
/>

f:msg-control provides, as a side effect, context-sensitive control over whether messages (i.e., those produced by xsl:message) and warnings are output by the processor.

### Element - f:output

#### Element Syntax

<f:output
cdata-section-elements = { qnames }
doctype-public = { string }
doctype-system = { string }
encoding = { string }
indent = { "yes" | "no" }
media-type = { string }
method = { qname }
omit-xml-declaration = { "yes" | "no" }
standalone = { "yes" | "no" }
version = { nmtoken }
<!-- Content: template -->
/>

f:output is similar to xsl:output, but it allows you to compute the output parameters dynamically (as attribute value templates). Unlike xsl:output, this element is not expected to be empty; the output parameters apply only to the serialization of the element's content.

### Element - f:raw-text-output

#### Element Syntax

<f:raw-text-output
select = expression
<!-- Content: template -->
/>

Given a foreign XPath object, f:raw-text-output creates a text node based on the object, just like xsl:value-of with disable-output-escaping="yes". Unlike xsl:value-of, however, this element does not use the string-value of the object; it instead feeds the object directly to the current output writer. Therefore, unless a custom output writer is used, the object must be a Python Unicode string. The intent is to provide a way to serialize a Unicode string that may contain characters that are not permitted in an XPath string object. For example, another extension can convert raw binary data to a Unicode string, and then this extension can reserialize that string through the XSLT output stream, without risk of losing any data due to XPath's restrictions on string content.

### Element - f:replace

#### Element Syntax

<f:replace
substring = string-expression
string = string-expression
<!-- Content: template -->
/>

f:replace performs a search and replace on a string, placing the results in the output. The content is treated as a template. The string value of the output from this template is the replacement string. All instances of the string given by the 'substring' attribute are replaced with the replacement string.

### Element - f:setup-translations

#### Element Syntax

<f:setup-translations
domain = { string }
localedir = { string }
<!-- Content: template -->
/>

### Element - f:uri-to-element

#### Element Syntax

<f:uri-to-element
default-name = { qname }
uri = { uri-reference }
default-namespace = { uri-reference }
use-attribute-sets = qnames
<!-- Content: template -->
/>

Extends xsl:element by deriving the constructed element's QName and namespace from the supplied URI reference. The URI reference is first resolved to absolute form. Then, if the resulting URI begins with an in-scope namespace, that namespace will be used as if it had been supplied as the 'namespace' attribute to xsl:element, and the remainder of the URI will be combined with a prefix from the in-scope namespace bindings and used as if supplied as the 'name' attribute to xsl:element. Otherwise, the supplied default-name and default-namespace will be used, effecting the same result as calling xsl:element with these values. The intent is to allow an RDF resource, as identified by a URI with a fragment component, to be easily converted into an element.

### Element - func:function

#### Element Syntax

<func:function
name = qname-but-not-ncname
<!-- Content: (xsl:param*, template) -->
/>

### Element - func:result

#### Element Syntax

<func:result
select = expression
<!-- Content: template -->
/>

When an func:result element is instantiated, during the instantiation of a func:function element, the function returns with its value.