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

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

The Default Value of the Parameter

In the case of stylesheet parameters and template parameters, if no value for the parameter is supplied by the caller, a default value is used. The default value of the parameter may be given either by the XPath expression in the
select
attribute, or by the contents of the contained sequence constructor. If there is a
select
attribute, the

element must be empty.

The value is calculated in exactly the same way as the value of a variable in

, and the rules are as given on page 503. Note that the default value need not be a constant; it can be computed in terms of the values of other parameters appearing earlier in the list and can also depend on information such as the context item and context size.

If there is no
select
attribute and the sequence constructor is empty, the default value of the parameter is a zero-length string, unless there is an
as
attribute, in which case the default value is an empty sequence. If the type given in the
as
attribute does not allow an empty sequence, then the parameter is mandatory.

If the
required
attribute has the value
yes
, then the parameter is mandatory. In this case, it makes no sense to supply a default value, so the
select
attribute must be omitted and the element must be empty. Failing to supply a value for a mandatory parameter is a compile-time error in the case of

, but a runtime error in all other cases.

The Name of the Parameter

The name of the parameter is defined by the QName given in the
name
attribute. Normally, this will be a simple name (such as
num
or
list-of-names
), but it may be a name qualified with a prefix; for example
my:value
. If it has a prefix, the prefix must correspond to a namespace that is in scope at that point in the stylesheet. As usual it is the namespace URI rather than the prefix that matters, so two variables
my:value
and
your:value
have the same name if the prefixes
my
and
your

Other books

The Queen by Kiera Cass
Cavanaugh Reunion by Marie Ferrarella
Beautiful Scars by Shiloh Walker
Skye's Trail by Jory Strong
Fire Time by Poul Anderson
Jackie's Wild Seattle by Will Hobbs
The Pale House by Luke McCallin
Jo Beverley by Forbidden Magic
Tide by Daniela Sacerdoti