Review of the xpath specification



Download 51.99 Kb.
Date30.04.2018
Size51.99 Kb.
TypeReview

Web Data Management

  • XPath

In this lecture

  • Review of the XPath specification
    • data model
    • examples
    • syntax
  • Resources:
  • A formal semantics of patterns in XSLT by Phil Wadler.
  • XML Path Language (XPath) www.w3.org/TR/xpath

XPath

  • http://www.w3.org/TR/xpath (11/99)
  • Building block for other W3C standards:
    • XSL Transformations (XSLT)
    • XML Link (XLink)
    • XML Pointer (XPointer)
    • XML Query
  • Was originally part of XSL

XPath

  • An expression language to be used in another host language (e.g., XSLT, XQuery).
  • Allows the description of paths in an XML tree, and the retrieval of nodes that match these paths.
  • Can also be used for performing some (limited) operations on XML data.

Example for XPath Queries


  • Addison-Wesley
    Serge Abiteboul Rick Hull Victor Vianu <a href="/description-and-journal-selection-criteria-of-major-electronic.html">Foundations of Databases </a> 1995

    Freeman
    Jeffrey D. Ullman Principles of Database and Knowledge Base Systems 1998

Data Model for XPath

  • XPath expressions operate over XML trees, which consist of the following node types:

Data Model for XPath

  • bib
  • book
  • book
  • publisher
  • author
  • . . . .
  • Addison-Wesley
  • Serge Abiteboul
  • The root
  • The root element
  • Processing instruction
  • Comment
  • Attr= “1”
  • element
  • attribute
  • text

Data Model for XPath

  • The root node of an XML tree is the (unique) Document node;
  • The root element is the (unique) Element child of the root node;
  • A node has a name, or a value, or both
    • an Element node has a name, but no value;
    • a Text node has a value (a character string), but no name;
    • an Attribute node has both a name and a value.
  • Attributes are special! Attributes are not considered as first-class nodes in an XML tree. They must be addressed specifically, when needed.

XPath: Simple Expressions

  • /bib/book/year
  • Result: 1995
  • 1998
  • /bib/paper/year
  • Result: empty (there were no papers)

XPath Tree Nodes

  • Seven nodes types:
    • root, element, attribute, text, comment, processing instruction and namespace
  • Namespace and attribute nodes have parent nodes, but are not children of those parent nodes.
  • The relationship between a parent node and a child node is containment
  • Attribute nodes and namespace nodes describe their parent nodes

Xpath Tree Nodes





The database is protected by copyright ©sckool.org 2020
send message

    Main page