XQuery 1.0:XML查询语言 工作草案-1

TransWiki - W3CHINA.ORG开放翻译计划(OTP)

摘要_文档状态_目录 第1节 第2节 3.1~3.3节 3.4~3.6节 3.7节 3.8~3.13节 第4节 附录A 附录B,C,D 附录E,F,G,H,I


1 Introduction

As increasing amounts of information are stored, exchanged, and presented using XML, the ability to intelligently query XML data sources becomes increasingly important. One of the great strengths of XML is its flexibility in representing many different kinds of information from diverse sources. To exploit this flexibility, an XML query language must provide features for retrieving and interpreting information from these diverse sources.
随着越来越多的信息用XML存储、交换和表示,智能地查询XML数据源的能力变得越来越重要。XML的一个很大的优点就是它在表示各种不同信息源的多种信息时的灵活性。为了利用这种灵活性,一个XML查询语言应该提供检索和解释不同数据源信息的特性。
XQuery is designed to meet the requirements identified by the W3C XML Query Working Group [XML Query 1.0 Requirements (http://www.w3.org/TR/2004/WD-xquery-20040723/#Requirements)] and the use cases in [XML Query Use Cases (http://www.w3.org/TR/2004/WD-xquery-20040723/#UseCases)]. It is designed to be a language in which queries are concise and easily understood. It is also flexible enough to query a broad spectrum of XML information sources, including both databases and documents. The Query Working Group has identified a requirement for both a human-readable query syntax and an XML-based query syntax. XQuery is designed to meet the first of these requirements. XQuery is derived from an XML query language called Quilt [Quilt (http://www.w3.org/TR/2004/WD-xquery-20040723/#Quilt)], which in turn borrowed features from several other languages, including XPath 1.0 [XPath 1.0 (http://www.w3.org/TR/2004/WD-xquery-20040723/#XPath)], XQL [XQL (http://www.w3.org/TR/2004/WD-xquery-20040723/#XQL)], XML-QL [XML-QL (http://www.w3.org/TR/2004/WD-xquery-20040723/#XML-QL)], SQL [SQL (http://www.w3.org/TR/2004/WD-xquery-20040723/#SQL)], and OQL [ODMG (http://www.w3.org/TR/2004/WD-xquery-20040723/#ODMG)].
XQuery是为了满足W3C XML查询工作组定义的需求[XML Query 1.0 Requirements (http://www.w3.org/TR/2004/WD-xquery-20040723/#Requirements)]和[XML Query Use Cases (http://www.w3.org/TR/2004/WD-xquery-20040723/#UseCases)]里的用例的需要而设计的。它被设计为一种查询简洁而又易于理解的语言。它也足够灵活,能查询范围很广的XML信息源,包括数据库和文档。查询工作组已经为人读的(human-readable)查询语法和基于XML的(XML-based)查询语法分别制定了一个需求。XQuery是为了满足第一个需求。XQuery源于一种名为Quilt [Quilt (http://www.w3.org/TR/2004/WD-xquery-20040723/#Quilt)] 的XML查询语言,而Quilt本身又借鉴了很多其它语言的特征,包括XPath 1.0 [XPath 1.0 (http://www.w3.org/TR/2004/WD-xquery-20040723/#XPath)]、XQL [XML-QL (http://www.w3.org/TR/2004/WD-xquery-20040723/#XML-QL)]、XML-QL[XML-QL (http://www.w3.org/TR/2004/WD-xquery-20040723/#XML-QL)]、SQL [SQL (http://www.w3.org/TR/2004/WD-xquery-20040723/#SQL)]和OQL [ODMG (http://www.w3.org/TR/2004/WD-xquery-20040723/#ODMG)].
[Definition: XQuery operates on the abstract, logical structure of an XML document, rather than its surface syntax. This logical structure is known as the data model, which is defined in the [XQuery 1.0 and XPath 2.0 Data Model (http://www.w3.org/TR/2004/WD-xquery-20040723/#datamodel)] document.]
[定义:XQuery对一个XML文档的抽象、逻辑结构,而不是它的表面语法进行操作。这种逻辑结构又常被称为数据模型,它在[XQuery 1.0 and XPath 2.0 Data Model (http://www.w3.org/TR/2004/WD-xquery-20040723/#datamodel)] 文档中被定义。]
XQuery Version 1.0 is an extension of XPath Version 2.0. Any expression that is syntactically valid and executes successfully in both XPath 2.0 and XQuery 1.0 will return the same result in both languages. Since these languages are so closely related, their grammars and language descriptions are generated from a common source to ensure consistency, and the editors of these specifications work together closely.
XQuery版本1.0是对XPath版本2.0的一个扩充。任何表达式,只要它句法上正确而且在XPath 2.0和XQuery 1.0中都能顺利执行,则在两种语言中将返回相同的结果。鉴于这两种语言联系如此紧密,它们的语法和语言描述从同一个源头产生以保证一致性,这两个规范的编者也密切合作。
XQuery also depends on and is closely related to the following specifications:

  • [XQuery 1.0 and XPath 2.0 Data Model (http://www.w3.org/TR/2004/WD-xquery-20040723/#datamodel)] defines the data model that underlies all XQuery expressions.
  • [XQuery 1.0 and XPath 2.0 Formal Semantics (http://www.w3.org/TR/2004/WD-xquery-20040723/#XQueryFormalSemantics)] defines the static semantics of XQuery and also contains a formal but non-normative description of the dynamic semantics that may be useful for implementors and others who require a formal definition.
  • The type system of XQuery is based on [XML Schema (http://www.w3.org/TR/2004/WD-xquery-20040723/#XMLSchema)].
  • The default function library and the operators supported by XQuery are defined in [XQuery 1.0 and XPath 2.0 Functions and Operators (http://www.w3.org/TR/2004/WD-xquery-20040723/#FunctionsAndOperators)].
  • One requirement in [XML Query 1.0 Requirements (http://www.w3.org/TR/2004/WD-xquery-20040723/#Requirements)] is that an XML query language have both a human-readable syntax and an XML-based syntax. The XML-based syntax for XQuery is described in [XQueryX 1.0 (http://www.w3.org/TR/2004/WD-xquery-20040723/#XQueryX)].

XQuery也依赖于下列规范而且与它们紧密相关:

  • [XQuery 1.0 and XPath 2.0 Data Model (http://www.w3.org/TR/2004/WD-xquery-20040723/#datamodel)] 定义了作为XQuery表达式基础的数据模型。
  • [XQuery 1.0 and XPath 2.0 Formal Semantics (http://www.w3.org/TR/2004/WD-xquery-20040723/#XQueryFormalSemantics)] 定义了XQuery的静态语义,也包含了一个正式但是不规范(non-normative)的关于动态语义的描述,这些描述对实现者或其它需要正式描述的人可能会有用。
  • XQuery的类型系统基于 [XML Schema (http://www.w3.org/TR/2004/WD-xquery-20040723/#XMLSchema)]。
  • XQuery支持的缺省的函数库和操作符在 [XQuery 1.0 and XPath 2.0 Functions and Operators (http://www.w3.org/TR/2004/WD-xquery-20040723/#FunctionsAndOperators)] 中定义。
  • [XML Query 1.0 Requirements (http://www.w3.org/TR/2004/WD-xquery-20040723/#Requirements)] 中的需求之一就是一个XML查询语言应该既有人读(human-readable)语法,也有基于XML(XML-based)的语法。XQuery的基于XML的语法定义在 [XQueryX 1.0 (http://www.w3.org/TR/2004/WD-xquery-20040723/#XQueryX)] 中描述。

This document specifies a grammar for XQuery, using the same Basic EBNF notation used in [XML 1.0 (http://www.w3.org/TR/2004/WD-xquery-20040723/#XML)]. Unless otherwise noted (see A.2 Lexical structure), whitespace is not significant in the grammar. Grammar productions are introduced together with the features that they describe, and a complete grammar is also presented in the appendix [A XQuery Grammar]. The appendix is the normative version.
本文档用 [XML 1.0 (http://www.w3.org/TR/2004/WD-xquery-20040723/#XML)] 中用到的基本EBNF(Basic EBNF)表示法为XQuery规定了一个语法。除非另外指明(见A.2 词法结构),空白符在语法中是忽略不计的。语法产生式和它们描述的特征一起被介绍,一份完整的语法在附录 [A XQuery 语法] 里列出了。该附录是规范版本。
In the grammar productions in this document, nonterminal symbols are underlined and literal text is enclosed in double quotes. Certain productions (including the productions that define DecimalLiteral, DoubleLiteral, and StringLiteral) employ a regular-expression notation. The following example production describes the syntax of a function call:
在本文档的语法产生式中,非终结符(nonterminal symbols)带有下划线,字符文本(literal text)用双引号引了起来。某些产生式(包括定义DecimalLiteral、DoubleLiteral和StringLiteral的产生式)使用了正则表达式(regular-expression)的表示法。下面的示例产生式描述了一个函数调用的语法:
[83]   FunctionCall    ::=   QName (http://www.w3.org/TR/2004/WD-xquery-20040723/#prod-xquery-QName) "(" (ExprSingle (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-ExprSingle) ("," ExprSingle (http://www.w3.org/TR/2004/WD-xquery-20040723/#doc-xquery-ExprSingle))*)? ")"

The production should be read as follows: A function call consists of a QName followed by an open-parenthesis. The open-parenthesis is followed by an optional argument list. The argument list (if present) consists of one or more expressions, separated by commas. The optional argument list is followed by a close-parenthesis.
这个产生式应该这样读:一个函数调用由一个QName跟着一个开括号(open-parenthesis)组成。开括号后面跟着一个可选的参数列表。参数列表(如果存在)由一个或多个表达式组成,中间用逗号隔开。可选的参数(argument)列表后跟着一个闭括号(close-parenthesis)。
Certain aspects of language processing are described in this specification as implementation-defined or implementation-dependent.

  • [Definition: Implementation-defined indicates an aspect that may differ between implementations, but must be specified by the implementor for each particular implementation.]
  • [Definition: Implementation-dependent indicates an aspect that may differ between implementations, is not specified by this or any W3C specification, and is not required to be specified by the implementor for any particular implementation.]

语言处理的某些方面在本规范中描述为实现定义的或者依赖于实现的

  • [定义:实现定义的意味着一个方面可能在不同的实现中不同,但是实现者必须就每个特定的实现作出明确说明。]
  • [定义:依赖于实现的意味着一个方面可能在不同的实现中不同,它没有在本规范或任何W3C规范中明确说明,而且不要求实现者为任何特定实现作出明确说明。]

This document normatively defines the dynamic semantics of XQuery. The static semantics of XQuery are normatively defined in [XQuery 1.0 and XPath 2.0 Formal Semantics (http://www.w3.org/TR/2004/WD-xquery-20040723/#XQueryFormalSemantics)]. In this document, examples and material labeled as "Note" are provided for explanatory purposes and are not normative.
本文档规范地定义了XQuery的动态语义。XQuery的静态语义在 [XQuery 1.0 and XPath 2.0 Formal Semantics (http://www.w3.org/TR/2004/WD-xquery-20040723/#XQueryFormalSemantics)] 中被规范地定义了。在本文档中,标有“注意”字样的例子和资料是出于解释目的而不是规范的。

个人工具
其它语言
 
 Page execution time: 323.14 ms.
网上报警 苏ICP备05002329号