Querying XML

From Suhrid.net Wiki
Revision as of 06:56, 5 February 2014 by Suhridk (talk | contribs) (→‎XPath)
Jump to navigationJump to search

Intro

  • Not as mature as querying relational databases
  • No underlying algebra
  • XPath : Path expressions and conditions
  • XSLT : XPath + Transformations, output processing
  • XQuery : XPath + full featured query language
  • XLink, XPointer : Use XPath as a component

XPath

  • Think of XML as a tree
  • Expressions in XPath as navigations down/across the tree with conditions
  • / - root element + separator, Element name, * is wildcard, @ for attribute
  • // - any descendant of the current element including self
  • condition in square bracket. [price < 50]. Also [] used as array access.
  • Many built-in functions : e.g. contains(s1, s2) : true/false. name() : returns element tag name
  • Navigation axes : e.g. parent, following-sibling, descendants
  • XPath queries operate on and return sequence of elements for XML document & XML stream
  • Sometimes result of XPath query can be expressed in XML, but not always