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

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

This XSLT instruction outputs the values of the child elements

,

, and

(not necessarily exactly one of each), in that order, space-separated.

Numeric Ranges: The
to
Operator

A range expression has the syntax:

Expression
Syntax
RangeExpr
AdditiveExpr (
to
AdditiveExpr )?

The effect is to return a sequence of consecutive integers in ascending order. For example, the expression
1 to 5
returns the sequence
1,2,3,4,5
.

The operands do not have to be constants, of course. A common idiom is to use an expression such as
1 to count($seq)
to return the position number of each item in the sequence
$seq
. If the second operand is less than the first (which it will be in this example if
$seq
is an empty sequence), then the range expression returns an empty sequence. If the second operand is equal to the first, the expression returns a single integer, equal to the value of the first operand.

The two operands must both evaluate to single integers. You can use an untyped value provided it is capable of being converted to an integer; for example, you can write
1 to @width
if
width
is an attribute in a schema-less document containing the value
34
. However, you can't use a decimal or a double value without converting it explicitly to an integer. If you write
1 to @width + 1
, you will get a type error, because the value of
@width + 1
is the double value
35.0e0
. Instead, write
1 to xs:integer(@width) + 1
or
1 to 1 + @width idiv 1
.

Other books

Deal with the Devil by Stacia Stone
Lady Brittany's Love by Lindsay Downs
Pieces of My Heart by Robert J. Wagner
How I Found You by Gabriella Lepore
Mixed Blessings by Danielle Steel
Mia by Kelly, Marie
Poison Dance Proofreading Epub by Livia Blackburne
Chasing Glory by Galbraith, DeeAnna
Circus of Thieves on the Rampage by William Sutcliffe and David Tazzyman