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
4.96Mb size Format: txt, pdf, ePub
ads
  • 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.

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

Other books

Barsk by Lawrence M. Schoen
His Secret by Ann King
La pesadilla del lobo by Andrea Cremer
No Cure for Death by Max Allan Collins
Bigfoot Dreams by Francine Prose
Eve by Anna Carey
Fearless Curves by D. H. Cameron
Chameleon People by Hans Olav Lahlum