Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 13 Next »

XPath

XPath is the XML Path Language which uses a "path like" syntax to browse through elements and attributes in an XML document.
It contains over 200 built-in functions for such as string values, numeric values, booleans, date and time comparison, node manipulation, sequence manipulation, and much more.

In XPath, there are seven kinds of nodes: element, attribute, text, namespace, processing-instruction, comment, and document nodes.
XML documents are treated as trees of nodes. The topmost element of the tree is called the root element.

For further information on XPath click here

XQuery

XQuery is a language that designed to query XML data. It is built on XPath expressions so one that wants to use XQuery must know how to use XPath. 

XQuery grounds on the five expressions whose acronym is FLWOR (pronounced "flower").

  • For - selects a sequence of nodes
  • Let - binds a sequence to a variable
  • Where - filters the nodes
  • Order by - sorts the nodes
  • Return - what to return (gets evaluated once for every node)

With these expressions (not necessarily with all of them) one can query any XML data.

The XQuery Update Facility is a relatively small extension of the XQuery language which provides convenient means of modifying XML documents or data. As of March 14, 2008, the XQuery Update Facility specification has become a "Candidate Recommendation", which means it is now pretty stable.

Why an update facility in XML Query ? The answer seems obvious, yet after all the XQuery language itself - or its cousin XSLT2 - is powerful enough to write any transformation of an XML tree. Therefore a simple "store" or "put" function, applied to the result of such transformation, could seem sufficient to achieve any kind of database update operation. Well, perhaps. In practice this would be neither very natural, convenient, nor very efficient (such an approach requires storing back the whole document and makes optimizing very difficult). So as we will see the little complexity added by XQuery Update seems quite worth the effort.

The Instructions below give a quick yet comprehensive practical introduction to the XQuery Update extension, while highlighting some of its peculiarities.

Prerequisites: the reader is presumed to have some acquaintance with XML Query and its Data Model (the abstract representation of XML data, involving nodes of six types: document, element, attribute, text, comment, processing-instruction).

  • No labels