XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition (175 page)

BOOK: XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition
9.33Mb size Format: txt, pdf, ePub

On entry to the function, the context item, position, and size are undefined. It is therefore an error to use the expression
.
, or any relative path expression, or the functions
position()
and
last()
. Even a path expression beginning with
/
is not allowed, because such path expressions select from the root of the tree containing the context node. This means that all information needed by the function must either be passed explicitly as a parameter or be available in a global variable. Path expressions such as
$par/a/b/c
can be used to navigate from nodes that are supplied as parameters to other nodes in the same tree.

Other values in the dynamic context, such as the current template, current mode, current group, and current grouping key, are also either undefined or empty on entry to a stylesheet function.

The result of the function is obtained by evaluating the sequence constructor. This result may be a sequence consisting of nodes (either newly constructed nodes or references to existing nodes) or atomic values or both. If there is an
as
attribute on the

element, then the result of evaluating the sequence constructor is converted, if necessary, to the specified type. Once again, the standard conversion rules defined on page 505 are used. A type error is reported if this conversion fails. If the

element has no
as
attribute, then a result of any type may be returned, and no checking or conversion takes place.

The override Attribute

The
override
attribute controls what happens if a user-written function and a vendor-supplied function have the same name.

  • override=“yes”
    means that the user-written function wins. This is the default. This value maximizes portability: the same implementation of the function will be used on all XSLT processors.
  • override=“no”
    means that the vendor-supplied function wins. This setting is useful when the stylesheet function has been written as a fallback implementation of the function, for use in environments where no vendor-supplied implementation exists. For example, at
    http://www.exslt.org/
    there is a definition of a mathematical function library, including the function
    math:sqrt()
    , which evaluates the square root of its argument. This function is likely to be available with a number of XSLT processors, but not all. By supplying an XSLT implementation of this function, and specifying
    override=“no”
    , the stylesheet author can ensure that a call to
    math:sqrt()
    will execute on any XSLT processor, and will take advantage of the vendor's native implementation when available.

Other books

Order of Good Cheer by Bill Gaston
Signor Marconi's Magic Box by Gavin Weightman
Rex Stout - Nero Wolfe 17 by Three Doors to Death
Roses in the Sand by CS Patra
Behind the Seams by Betty Hechtman
Delirio by Laura Restrepo
The Rice Paper Diaries by Francesca Rhydderch