graphic with four colored squares
Cover page image (keys)

XPath 1.0 and 2.0

Presentation for SML Working Group

C. M. Sperberg-McQueen

29 August 2007

Overview

  • data model changes
  • type system
  • function library
  • operators, expression, quantification
  • spec

Data model

  • node sets sequences
  • four types all the XML Schema built-ins
  • new node types: item(), document-node(), document-node(ElementTest)

Type system

1.0:
  • nodes
  • strings
  • numbers
  • booleans
2.0
  • atomic values with XML Schema simple types
  • nodes can have XML Schema complex types
  • instance of, treat as, cast as, castable as
  • matching on type
  • type errors

Function library

Larger. Much larger.
  • String and numeric functions
  • Date and time functions
  • Sequence manipulation functions
  • Casting and type-related functions

Operators

  • Constructors
    (1 to 10)[. mode 2 = 1](1, 3, 5, 7, 9)
  • Union
    (1, 2, 3, 4) union (1, 5)(1, 2, 3, 4, 5)
  • Intersection
    (1, 2, 3, 4) intersect (1, 3)(1, 3)
  • Exception
    (1, 2, 3, 4) except (1, 3)(2, 4)
    Quantified expressions (some and every)

The for and if expressions

XPath 2.0 adds a “for” expression:
for $bib in blist/bibl
   [contains($bib/orgname, 'W3C')]
   return $bib
N.B. This is in XPath, not the host language (XSLT or XQuery).
Simiilarly, an if / then / else expression:
if ($part/@discounted)
   then $part/wholesale
   else $part/retail

The spec itself

  • larger
  • more formal
  • more explicit about requirements for host language