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

BOOK: XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition
7.07Mb size Format: txt, pdf, ePub
  • The unary minus operator
    -
    .
  • The multiplicative operators
    *
    ,
    div
    , and
    mod
    .
  • The additive operators
    +
    and
    -
    .
  • The
    number()
    function, which can convert from any value to a number.
  • The
    string()
    function, which converts a number to a string.
  • The
    boolean()
    function, which converts a number to a Boolean.
  • The
    abs()
    function returns the absolute value of a number.
  • The functions
    round()
    ,
    ceiling()
    ,
    floor()
    , and
    round-half-to-even()
    , which convert a number to an integer.
  • The aggregate functions
    sum()
    ,
    avg()
    ,
    max()
    , and
    min()
    , which produce a single
    xs:double
    value when applied to a sequence of
    xs:double
    values.

Operators on numbers behave exactly as specified by IEEE 754. XPath is not as strict as Java in defining exactly what rounding algorithms should be used for inexact results, and in what sequence operations should be performed. In fact XPath 2.0 is more liberal than XPath 1.0, in that it allows any of the options permitted by IEEE 754 to be chosen. These include, for example, producing an error on overflow rather than returning positive or negative infinity.

Many implementations, however, are likely to follow the Java rules. In this case, numeric operators and functions never produce an error. An operation that overflows produces positive or negative infinity, an operation that underflows produces positive or negative zero, and an operation that has no other sensible result produces NaN. All numeric operations and functions with NaN as an operand produce NaN as a result. For example, if you apply the
sum()
function to a sequence, then if the sequence contains a NaN value, the result of the
sum()
function will be NaN.

xs:integer

The
xs:integer
type supports the positive and negative natural numbers. Neither XML Schema nor XPath 2.0 dictate what the maximum value of an integer is. XML Schema has a rule that implementations must support at least 18 decimal digits. But one of the subtypes of
xs:integer
, namely
xs:unsignedLong
, supports values in the range 0 to 18,446,744,073,709,551,615. This requires 20 digits, so an implementation that stops at 18 is going to struggle to pass some of the conformance tests.

Other books

The Faraway Drums by Jon Cleary
Above by Isla Morley
Destroying Angel by Sam Hastings
In Other Rooms, Other Wonders by Daniyal Mueenuddin
And Yesterday Is Gone by Dolores Durando
A Surprise for Lily by Mary Ann Kinsinger