# Extension Module - Ft.Xml.Xslt.Exslt

## 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`
`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: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(dateTime1, dateTime2)
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(dateOrDuration)
date:time | unknown date:time(dateTime)
date:week-in-year | unknown date:week-in-year(dateTime)
date:year | unknown date:year(dateTime)
dyn:evaluate | unknown dyn:evaluate(string)
exsl:node-set | unknown exsl:node-set(obj)
exsl:object-type | unknown exsl:object-type(obj)
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 } indent = { "yes" | "no" } media-type = { string } method = { qname } omit-xml-declaration = { "yes" | "no" } standalone = { "yes" | "no" } version = { nmtoken } <!-- 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.

### 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. Non-conformance issues: The dateTime argument must be given in ISO 8601 date/time or date format, so an xs:date format with a time zone is not supported. Also, EXSLT requires that the result must include a time zone unless there was an argument given and it did not have a time zone. If a date/time argument is given, this implementation returns the date with no time zone info.

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

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

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

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

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

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

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

### Function - date:difference

#### Function Syntax

unknown date:difference(dateTime1, dateTime2)

The date:difference function returns the difference between dt1 and dt2 as a duration in string form. According to the spec (http://exslt.org/date/functions/difference/index.html) "If the date/time string with the least specific format is in either xs:gYearMonth or xs:gYear format, then the number of days, hours, minutes and seconds in the duration string must be equal to zero. (The format of the string will be PnYnM.) The number of months specified in the duration must be less than 12." "Otherwise, the number of years and months in the duration string must be equal to zero. (The format of the string will be PnDTnHnMnS.) The number of seconds specified in the duration string must be less than 60; the number of minutes must be less than 60; the number of hours must be less than 24." This method does not account for leap seconds, so you should not expect precise results over long time spans.

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

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

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

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

### 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 year) as an integer.

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

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

### Function - date:seconds

#### Function Syntax

unknown date:seconds(dateOrDuration)

### 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. Non-conformance issue: EXSLT requires that the result must include a time zone unless there was an argument given and it did not have a time zone. If an argument is given, this implementation returns the result with time zone info, always.

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

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

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

### 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 - 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 }
indent = { "yes" | "no" }
media-type = { string }
method = { qname }
omit-xml-declaration = { "yes" | "no" }
standalone = { "yes" | "no" }
version = { nmtoken }
<!-- Content: template -->
/>

For full specification, see: http://www.exslt.org/exsl/elements/document/index.html

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