Read XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition Online
Authors: Michael Kay
group-by=“position() mod (last() idiv $cols)”>
See Also
Collations
on page 459
current-group()
function on page 739
current-grouping-key()
function on page 740
distinct-values()
function on page 749
xsl:function
The
Changes in 2.0
This element is new in XSLT 2.0.
Format
name = qname
as? = sequence-type
override? = “yes” | “no”>
Position
Attributes
Name | Value | Meaning |
name mandatory | Lexical QName | The name of the function. |
as optional | SequenceType | The type of the value returned when this function is evaluated. A type error is reported if the result does not match this type. |
override optional | yes or no | Indicates whether this function overrides any vendor-supplied function of the same name. |
The construct
SequenceType
is described in Chapter 11.
Content
Zero or more
Effect
User-written stylesheet functions can be called from XPath expressions in the same way as system-provided functions. The function defined by this
arity
).
When a stylesheet function is called from an XPath expression, the parameters supplied in the function call are evaluated and bound to the variables defined in the
The name of the function is given as a lexical QName in the
name
attribute. This name must have a namespace prefix: This is to ensure that the name does not clash with the names of functions in the standard function library. The XSLT 2.0 specification defines several namespaces (all starting with
http://www.w3.org/
) that are reserved—that is, they cannot be used for the names of user-defined functions, variables, or other stylesheet objects.
The stylesheet is allowed to contain two functions of the same name if they have different arity.
It is an error to have two functions in the stylesheet with the same name, arity, and import precedence, unless there is another with higher import precedence. When a function call in an XPath expression is evaluated, the function with highest import precedence is chosen.
The parameters to a function (which are defined using
required
attribute to specify that a parameter is optional, or to specify a default value. The parameters are interpreted positionally: the first argument in the function call binds to the first
The values supplied as arguments to the function in the XPath function call are converted to the types defined by
as
attributes on the corresponding
as
attribute, then any value of any type is acceptable, and no checking or conversion takes place. This is equivalent to specifying
as=“item()*”
.