XML Queries

Another aspect of database access is the ability to formulate queries or questions that can be posed to the database engine to generate a result, which is then presented to the requestor. An XML Query Language (XQL) would make it easy to process a large number of documents or document fragments and extract appropriate elements for return to the requestor. XML queries are loosely defined as the ability to query an XML document or documents using a standard query language, much like SQL 92, and return DOM documents or XML snippets that define the result. One of the key benefits of an XML Query Language would be the ability to take advantage of the document's structure, improving the precision of the query. Such a language would be a great improvement over current approaches, which search the entire text of a document without regard to markup.

Note

As of this writing there was significant work in progress to define the requirements of an XML Query Language. The World Wide Web Consortium (W3C) has been working on a set of requirements for an XML query language and has released, in draft format, the XML Query Requirements specification. See the http://www.w3.org/wd-xmlquery-req-20000131.html for the complete text of this specification.


Requirements for an XML Query Language

Although there is no current W3C-sanctioned XML Query Language, there are a number of features such a language would need to have:

  • The language must be able to perform queries on XML documents, XML document fragments, and repositories of XML documents and produce results that are the aggregate of the original set.

  • Queries must not implicitly alter and must make available the original document sequence and hierarchy. However, queries should be able to specify the result order in a fashion similar to an SQL sort by modifier.

  • Queries must take into account NULL values and must be able to represent NULL values in a query as well as identify NULL values in a result.

  • Queries must be able to make structural changes to the resulting data—that is take input data and reformat it much like XSL does. Queries must also be able to generate new structure.

  • Queries must be environment independent—that is such a query must not require or prevent the use of a given operating system.

  • Queries must be language independent. All queries must be expressed as XML and be able to be embedded in C, C++, Java, or any other language developed in the future.

  • Queries must be protocol independent.

  • Queries must be based on the information provided by an XML document whether represented as a DOM tree or a text file. No outside information may be required.

Properties of Relational Database Queries

To better understand what is provided by some of the currently available XML query languages, it would be helpful to understand what database query languages provide today. Database query languages typically have the following features:

  • Queries consist of three distinct parts: a pattern, which represents what we want to select based on; a filter which removes unwanted results from the original query; and a construction clause which defines how the end result is created from the result of the query.

  • Additionally, a construction clause can have ordering subclauses that change the presentation order of the resulting data. Such ordering functions can be used to index, reorder, or perform nested queries on the results of the original query.

  • Database queries have the ability to perform joins across multiple input sets. Such a join results in a new set of data that is aggregated from the original input data.

  • Database queries have the ability to generate intermediate variables or path expressions to uniquely identify portions of the result making the construction of the result, easier.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.136.22.50