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
11.17Mb 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

Prodigal Son by Dean Koontz
Son of the Black Stallion by Walter Farley
Son of a Gun by Wayne, Joanna
Comfort Object by Annabel Joseph
The Library at Mount Char by Scott Hawkins
Beauty and the Duke by Melody Thomas
Lady in Blue by Lynn Kerstan
Under Siege by Keith Douglass
Cuentos de Canterbury by Geoffrey Chaucer
Jackie Robinson by Arnold Rampersad