XQuery Introduction


The best way to explain XQuery is this: XQuery's relationship to XML is the same as SQL's relationship to database tables.

XQuery is designed to query XML data - not only XML files, but also any data that can be presented in XML form, including databases.


Prerequisites:

Before you continue, you should have a basic understanding of the following:

  • HTML / XHTML
  • XML / XML Namespaces
  • XPath

If you wish to learn these topics first, please visit ourhomepageto access these tutorials.


What is XQuery?

XQuery
  • XQuery is a language for querying XML data
  • XQuery does for XML what SQL does for databases
  • XQuery is built on XPath expressions
  • XQuery is supported by all major database engines (IBM, Oracle, Microsoft, etc.)
  • XQuery is a W3C standard


XQuery and XML querying

XQuery is a language for finding and extracting elements and attributes from XML documents.

Here is an example of XQuery solving a real-world problem:

"Select all CD records with a price lower than $10 from the CD collection stored in an XML document named cd_catalog.xml."


XQuery and XPath

XQuery 1.0 and XPath 2.0 share the same data model and support the same functions and operators. If you have already studied XPath, you will have no problem learning XQuery.

You can read more about XPath in our "XPath Tutorial".


XQuery - Application Examples

XQuery can be used for:

  • Extracting information for use in web services
  • Generating summary reports
  • Converting XML data to XHTML
  • Searching web documents for relevant information

XQuery is a W3C Recommendation

XQuery is compatible with several W3C standards, such as XML, Namespaces, XSLT, XPath, and XML Schema.

XQuery 1.0 became a W3C Recommendation on January 23, 2007.

For more information about W3C's XQuery activities, please read our "W3C Tutorial》。

Other Extensions