Copyright © 2005 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C liability, trademark and document use rules apply.
This document specifies goals, requirements, and usage scenarios for the W3C XML Query (XQuery) data model and query language. It also includes, for each requirement, a corresponding status, indicating the current situation of the requirement in the XML Query family of specifications.
This section describes the status of this document at the time of its publication. Other documents may supersede this document. A list of current W3C publications and the latest revision of this technical report can be found in the W3C technical reports index at http://www.w3.org/TR/.
This document includes, for each requirement, a corresponding status, indicating the current situation of the requirement in the XML Query family of specifications at the time that they are being issued as Last Call Working Drafts in April, 2005.
This is a W3C Working Draft for review by W3C Members and other interested parties. Publication as a Working Draft does not imply endorsement by the W3C Membership. This is a draft document and may be updated, replaced or obsoleted by other documents at any time. It is inappropriate to cite this document as other than work in progress.
This document has been produced as part of the W3C XML Activity, following the procedures set out for the W3C Process. The document has been written by the XML Query Working Group. The goals of the XML Query working group are discussed in the XML Query Working Group charter ( W3C members only).
The XML Query Working Group feels that the contents of this Working Draft are relatively stable, and therefore encourages feedback on this version.
Comments on this document should be sent to the W3C mailing list public-qt-comments@w3.org (archived at http://lists.w3.org/Archives/Public/public-qt-comments/).
As of this publication, the Working Group expects to eventually publish this document as a Working Group Note. It is not expected to become a W3C Recommendation, and therefore it has no associated W3C Patent Policy licensing obligations.
1 Goals
2 Usage Scenarios
3 Requirements
3.1 Terminology
3.2 General Requirements
3.3 XML Query Data Model
3.4 XML Query Functionality
4 Relationship to Other Activities
5 References (non-normative)
A Glossary
The goal of the XML Query Working Group is to produce a data model for XML documents, a set of query operators on that data model, and a query language based on these query operators. The data model will be based on the W3C XML Infoset, and will include support for Namespaces.
Queries operate on single documents or fixed collections of documents. They can select whole documents or subtrees of documents that match conditions defined on document content and structure, and can construct new documents based on what is selected.
The following usage scenarios describe how XML queries may be used in various environments, and represent a wide range of activities and needs that are representative of the problem space to be addressed. They are intended to be used as design cases during the development of XML Query, and should be reviewed when critical decisions are made. These usage scenarios should also prove useful in helping non-members of the XML Query Working Group understand the intent and goals of the project.
Perform queries on structured documents and collections of documents, such as technical manuals, to retrieve individual documents, to generate tables of contents, to search for information in structures found within a document, or to generate new documents as the result of a query.
Perform queries on the XML representation of database data, object data, or other traditional data sources to extract data from these sources, to transform data into new XML representations, or to integrate data from multiple heterogeneous data sources. The XML representation of data sources may be either physical or virtual; that is, data may be physically encoded in XML, or an XML representation of the data may be produced.
Perform both document-oriented and data-oriented queries on documents with embedded data, such as catalogs, patient health records, employment records, or business analysis documents.
Perform queries on configuration files, user profiles, or administrative logs represented in XML.
Perform queries on streams of XML data to process the data in a manner analogous to UNIX filters. This might be used to process logs of email messages, network packets, stock market data, newswire feeds, EDI, or weather data to filter and route messages represented in XML, to extract data from XML streams, or to transform data in XML streams.
Perform queries on DOM structures to return sets of nodes that meet the specified criteria.
Perform queries on collections of documents managed by native XML repositories or web servers.
Perform queries to search catalogs that describe document servers, document types, XML schemas, or documents. Such catalogs may be combined to support search among multiple servers. A document-retrieval system could use queries to allow the user to select server catalogs, represented in XML, by the information provided by the servers, by access cost, or by authorization. Once a server is selected, a retrieval system could query the kinds of documents found on the server and allow the user to query those documents.
Queries may be used in many environments. For example, a query might be embedded in a URL, an XML page, or a JSP or ASP page; represented by a string in a program written in a general-purpose programming language; provided as an argument on the command-line or standard input; or supported by a protocol, such as DASL or Z39.50.
The following key words are used throughout the document to specify the extent to which an item is a requirement for the work of the XML Query Working Group:
This word means that the item is an absolute requirement.
This word means that there may exist valid reasons not to treat this item as a requirement, but the full implications should be understood and the case carefully weighed before discarding this item.
This word means that an item deserves attention, but further study is needed to determine whether the item should be treated as a requirement.
When the words MUST, SHOULD, or MAY are used in this technical sense, they occur as a hyperlink to these definitions. These words will also be used with their conventional English meaning, in which case there is no hyperlink. For instance, the phrase "the full implications should be understood" uses the word "should" in its conventional English sense, and therefore occurs without the hyperlink.
Each requirement also includes a status section, indicating its current situation in the XML-Query family of specifications. Three status levels are used:
This indicates that the requirement, according to its original formulation, has been completely met. Optional clarificatory text may follow.
This indicates that the requirement has been partially met according to its original formulation. When this happens, explanatory text is provided to better clarify the current scope of the requirement.
This indicates that the requirement, according to its original formulation, has not been met. If this is the case, explanatory text is provided.
The XML Query Language MAY have more than one syntax binding.
Status: this requirement has been met.
The XML Query Language MUST be convenient for humans to read and write.
Status: this requirement has been met.
One query language syntax MUST be expressed in XML in a way that reflects the underlying structure of the query.
Status: this requirement has been met.
The XML Query Language MUST be declarative. Notably, it MUST not enforce a particular evaluation strategy.
Status: this requirement has been met.
The XML Query Language MUST be defined independently of any protocols with which it is used. (Relationships to some specific protocols are discussed in 4 Relationship to Other Activities.)
Status: this requirement has been met.
The XML Query Language MUST define standard error conditions that can occur during the execution of a query, such as processing errors within expressions, unavailability of external functions to the query processor, or processing errors generated by external functions.
Status: this requirement has been met.
Version 1.0 of the XML Query Language MUST not preclude the ability to add update capabilities in future versions.
Status: this requirement has been met. The XML Query WG has begun work on update capabilities (see XQuery Update Facility Requirements).
The XML Query Language MUST be defined for finite instances of the data model.
Status: this requirement has been met.
It MAY be defined for infinite instances.
Status: this requirement has not been met. The XQuery Data Model defines only finite sequences.
The XML Query Data Model relies on information provided by XML Processors and Schema Processors, and it MUST ensure that it does not require information that is not made available by such processors.
Status: this requirement has been met.
For XML constructs found in XML 1.0 or the Namespaces Recommendation, the XML Query Data Model MUST show how the equivalent XML Query Data Model constructs are built from items in the XML Information Set.
Status: this requirement has been met.
The XML Query Data Model SHOULD represent all information items, or provide justification for any information items omitted.
Status: this requirement has been met. For each node type, the XQuery Data Model contains a section on how it can be constructed from an Infoset.
For information found in the XML Schema, such as datatypes, the XML Query Working Group MUST coordinate with the XML Schema Working Group to ensure that schema processors may be relied on to provide the information needed to construct the Data Model.
Status: this requirement has been met.
The XML Query Data Model MUST represent both XML 1.0 character data and the simple and complex types of the XML Schema specification.
Status: this requirement has been met.
The XML Query Data Model MUST represent collections of documents and collections of simple and complex values. (Note that collections are not part of the current XML Infoset.)
Status: this requirement has been met.
The XML Query Data Model MUST include support for references, including both references within an XML document and references from one XML document to another.
Status: this requirement has been partially met. Support for XPointer was considered, but was not provided. An explicit defererence operator was considered, but ultimately dropped (see issue 134, W3C members only).
Queries MUST be possible whether or not a schema is available (in this document, the term "schema" may refer to either an XML Schema or a DTD).
Status: this requirement has been met.
If a schema is available, the data model MUST represent any items that they define for their instances, such as default attributes, entity expansions, or data types. These items will not be present if a schema is not present.
Status: this requirement has been met. Note that not all XML Schema components are fully supported.
The XML Query Language and XML Query Language Data Model MUST be namespace aware.
Status: this requirement has been met.
The XML Query Language MUST support operations on all data types represented by the XML Query Data Model (see datatypes, collections, references).
Status: this requirement has been met.
Queries MUST be able to express simple conditions on text, including conditions on text that spans element boundaries.
Status: this requirement has been met. This requirement is satisfied by the ability of the string()
function to return the text content of an element, including text within sub-elements. This requirement will be even better supported in a future version of XQuery by Full-Text operations (see the XQuery and XPath Full-Text Requirements).
Operations on collections MUST include support for universal and existential quantifiers.
Status: this requirement has been met.
Queries MUST support operations on hierarchy and sequence of document structures.
Status: this requirement has been met.
The XML Query Language MUST be able to combine related information from different parts of a given document or from multiple documents.
Status: this requirement has been met.
The XML Query Language MUST be able to compute summary information from a group of related document elements (this operation is sometimes called "aggregation.")
Status: this requirement has been met.
The XML Query Language MUST be able to sort query results.
Status: this requirement has been met.
The XML Query Language MUST support expressions in which operations can be composed, including the use of queries as operands.
Status: this requirement has been met.
The XML Query Language MUST include support for NULL values. Therefore, all operators, including logical operators, MUST take NULL values into account.
Status: this requirement has been met. The closest analog for an SQL null value is XQuery's empty sequence. The xsi:nil='true'
attribute is also supported.
Queries MUST be able to preserve the relative hierarchy and sequence of input document structures in query results.
Status: this requirement has been met.
Queries MUST be able to transform XML structures and MUST be able to create new structures.
Status: this requirement has been met.
Queries MUST be able to traverse intra- and inter-document references.
Status: this requirement has been partially met. Support for XPointer was considered, but was not provided. An explicit defererence operator was considered, but ultimately dropped (see issue 134, W3C members only).
Queries MUST be able to preserve the identity of items in the XML Query Data Model.
Status: this requirement has been met.
Queries SHOULD be able operate on XML Query Data Model instances specified with the query ("literal" data).
Status: this requirement has been met.
Queries MUST be able to perform simple operations on names, such as tests for equality in element names, attribute names, and processing instruction targets, and to perform simple operations on combinations of names and data.
Status: this requirement has been met.
Queries MAY perform more powerful operations on names.
Status: this requirement has been met. Computed constructors give us this capability.
Queries SHOULD provide access to the XML schema or DTD for a document, if there is one.
Status: this requirement has not been met. Support for this requirement was felt to be too complex for XQuery 1.0. An XML Schema document can be queried independently by a user.
If the schema is represented as a DTD, a mapping to an appropriate XML Schema representation MAY be required.
Status: this requirement has not been met. This requirement was not supported because the previous requirement was not supported.
Queries MUST be able to operate on information items provided by the post-schema-validation information set defined by XML Schema.
Status: this requirement has been met. Data Model instances are constructed from the XML Schema PSVI.
The XML Query Language SHOULD support the use of externally defined functions on all datatypes of the XML Query Data Model. The interface to such functions SHOULD be defined by the Query Language, and SHOULD distinguish these functions from functions defined in the Query Language. The implementation of externally defined functions is not part of the Query Language.
Status: this requirement has been met.
The XML Query Language MUST provide access to information derived from the environment in which the query is executed, such as the current date, time, locale, time zone, or user.
Status: this requirement has been met. XQuery supports access to the current date, time, and timezone.
Queries MUST be closed with respect to the XML Query Data Model.
Status: this requirement has been met.
Both the input to a query and the output of a query MUST be defined purely in terms of the XML Query Data Model. Non-XML sources such as traditional databases or objects may be queried if they are given an XML Query Data Model representation. Similarly, query results are defined purely in terms of the XML Query Data Model. In software systems these results may be instantiated in any convenient representation such as DOM nodes, hyperlinks, XML text, or various data formats.
Status: this requirement has been met.
XML has become a strategic technology in W3C and in the global Web market. The deliverable of the XML Query Working Group MUST satisfy the dependencies from the following Working Groups before it can advance to Proposed Recommendation. Some dependencies to and from the following W3C Working Groups will require close cooperation during the development process; the requirements posed for the Query work by these Working Groups may change during the development process, which means the interdependency of the Query work with these Working Groups must be managed actively:
The XML Query Language must be able to return results in a form that can be used in DOM programs, such as DOM Nodes or the Iterators and TreeWalkers defined in the Traversal specification.
Both XSLT and XPointer use the XML Path Language ( XPath), which defines a location path syntax that can be used to search for matching parts of an XML document. The XML Query work will take into consideration the expressibility and search facilities of XPath when formulating its algebra and query syntax, and where desirable try to encompass those functionalities into its query language. The XML Query WG will also take into consideration the additional functionality in the XSLT and XPointer specifications.
It is a goal of the XML Query work to be compatible with the work of the XML Schema Working Group, including both Structures and Datatypes.
For example, it should be possible to base query predicates on the existing DTD or XSDL definition of the content of an XML document and on the new data types being defined as part of the XDTL.
The XML Query work will define a formal data model of XML documents. This model must be based on the model of the XML Infoset. In case incompatibilities arise, requirements must be posed to the W3C XML Core Working Group. In any case, the final model used by the XML Query working group will have to be based on, and totally compatible with, the model of the XML Infoset.
There are no requirements for co-development of features with the following Working Groups, but there are points of contact between their work and that of this Working Group, and thus logical dependency between their deliverables and those of this Working Group. Requirements from these Working Groups are expected to be well suited for communication via documents:
Reuse of common constructs greatly facilitates accessibility; the WAI PF Working Group will review work on the XML query facilities to be sure cost/benefit design decisions are informed of the benefits of accessibility.
The XML Query Working Group will solicit feedback from the Internationalization Working Group to ensure that it satisfies W3C goals for international access to the Web.
It may be necessary for the XML Query Working Group to reference the XML Fragment specification if a valid query return type is an XML fragment.
XML Query must strive for smooth interaction with the IETF DASL (DAV Searching & Locating) Working Group, in such a way that the XML query language can be easily incorporated into the DASL protocol.
Formal liaison between the XML Query Working Group and other W3C working groups, including the other XML working groups and the WAI (Web Accessibility Initiative) group, as well as organizations outside of the W3C, shall be accomplished by the exchange of documents (requirements, reviews, etc.) transmitted through the XML Coordination Group.
The following references are some of the works considered by the WG in deriving its requirements.
A quantifier is a term denoting a constraint on the number of objects in a collection that satisfy an accompanying condition. The existential quantifier denotes that at least one object satisfies the condition. The universal quantifier denotes that all objects satisfy the condition.
A document consists of the set of nodes and edges in the subtree descended from a Document node in the XML Query Data Model.
References that refer to nodes that do not reside in the same XML document as the reference itself.
References that reside in the same XML document as the nodes they reference.
Literal fragments of an XML document such as <name><first>Joe</first><last>Doe</last></name>, which may be used for comparison.