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

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

Format

  name = qname

  select? = expression

  as? = sequence-type>

  


Position

The

element may appear either as a top-level declaration (that is, as a child of the

element), or as an instruction within a sequence constructor.

Attributes

Name
Value
Meaning
name
mandatory
Lexical QName
The name of the variable.
select
optional
Expression
An expression that is evaluated to give the value of the variable. If omitted, the value is determined from the contents of the

element.
as
optional
SequenceType
Declares the type of the variable. A type error occurs if the value of the expression cannot be converted to this type using the standard type conversions defined below (page 505). In addition, the presence of this attribute on an

element with nonempty content indicates that the result of evaluating the contained sequence constructor is to be used directly as the value of the variable, rather than being used to construct a temporary document.

The
SequenceType
construct is described in Chapter 11.

Content

An optional sequence constructor. If a
select
attribute is present, the

element must be empty.

Effect

An

element may appear either at the top level of the stylesheet (in which case it declares a global variable) or as an instruction within a sequence constructor (in which case it declares a local variable).

The Name of the Variable

The name of the variable is defined by a lexical QName. Normally, this will be a simple name such as
city
or
total-sales
, 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. Two variables,
my:value
and
your:value
, have matching names if the prefixes
my
and
your
refer to the same namespace URI. If the name has no prefix, it has a null namespace URI—it does not use the default namespace URI.

Other books

Necrocide by Jonathan Davison
Bleak Spring by Jon Cleary
Cowgirl Up by Ali Spooner
Samphire Song by Jill Hucklesby
MAXIM: A New Type of Human (Oddily Series #2) by Pohring, Linda, Dewberry, Anne
The Night I Got Lucky by Laura Caldwell