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

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

The actual string that is checked against the pattern facet is as follows:

  • When converting from
    xs:string
    or
    xs:untypedAtomic
    , the value being converted.
  • In other cases, a lexical representation of the result of converting the value to the primitive base type of the target type, where the primitive types are considered to include
    xs:integer
    ,
    xs:dayTimeDuration
    , and
    xs:yearMonthDuration
    . The lexical representation chosen is generally the same as the result of casting the value to
    xs:string
    using the rules in this chapter, except in cases where XML Schema defines a canonical lexical representation that is different from the result of XPath casting. This affects the following cases:
    • For
      xs:decimal
      , a whole number is represented as (say)
      12.0
      rather than
      12
      .
    • For
      xs:double
      and
      xs:float
      , the value is always in exponential notation with a single non-zero digit before the decimal point; for example,
      1.2E1
      rather than
      12
      .
    • For
      xs:time
      and
      xs:dateTime
      , the value (if it has a timezone) is adjusted to UTC, so
      12:00:00-05:00
      is represented as
      17:00:00Z
      .
    • For
      xs:date
      , the timezone is adjusted to be in the range −11:59 to +12:00, adding or subtracting a day as necessary.

Suppose, for example, that the schema defines a
my:utcTime
type as a restriction of
xs:time
, with

. This constrains the value to end with
Z
. The cast
my:utcTime(“12:00:00+01:00”)
will therefore fail. However,
my:utcTime(xs:time(“12:00:00+01:00”))
will succeed. The cast to
xs:time
succeeds because the value is a valid time, and the cast to
my:utcTime
succeeds because the canonical lexical representation of the value is
11:00:00Z
, which matches the pattern, despite the fact that the actual value is not in UTC. As I said before, the best advice one can give is to avoid this area.

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

Other books

Hunted by Sophie McKenzie
Samantha James by Every Wish Fulfilled
Red Shadows by Mitchel Scanlon
Rexanne Becnel by Dove at Midnight
Double Coverage by Meghan Quinn
Off the Chart by James W. Hall
A Curse Dark as Gold by Elizabeth C. Bunce
The Familiars #3: Circle of Heroes by Epstein, Adam Jay, Jacobson, Andrew