FACTOID # 175: Canadians drink more fruit juice than the citizens of any other nation - more than one litre each, every week.
 
 Home   Encyclopedia   Statistics   Countries A-Z   Flags   Maps   Education   Forum   FAQ   About 
 
WHAT'S NEW
RELATED ARTICLES
People who viewed "XQuery" also viewed:
RECENT ARTICLES
More Recent Articles »
 

SEARCH ALL

FACTS & STATISTICS    Advanced view

Search encyclopedia, statistics and forums:

 

 

(* = Graphable)

 

 


Encyclopedia > XQuery

XQuery is a query language (with some programming language features) that is designed to query collections of XML data. It is semantically similar to SQL. Query languages are computer languages used to make queries into databases and information systems. ... A programming language is an artificial language that can be used to control the behavior of a machine, particularly a computer. ... The Extensible Markup Language (XML) is a general-purpose markup language. ... Semantic similarity, variously also called semantic closeness/proximity/nearness, is a concept whereby a set of documents or terms within term lists are assigned a metric based on the likeness of their meaning / semantic content. ... SQL (IPA: or IPA: ), commonly expanded as Structured Query Language, is a computer language designed for the retrieval and management of data in relational database management systems, database schema creation and modification, and database object access control management. ...


XQuery 1.0 was developed by the XML Query working group of the W3C. The work was closely coordinated with the development of XSLT 2.0 by the XSL Working Group; the two groups shared responsibility for XPath 2.0, which is a subset of XQuery 1.0. XQuery 1.0 became a W3C Recommendation on January 23, 2007. Wikipedia does not have an article with this exact name. ... The World Wide Web Consortium (W3C) is a consortium that produces standards—recommendations, as they call them—for the World Wide Web. ... ... XPath 2. ... A W3C Recommendation is the final stage of a ratification process of the W3C working group concerning the standard. ... is the 23rd day of the year in the Gregorian calendar. ... Year 2007 (MMVII) is the current year, a common year starting on Monday of the Gregorian calendar and the AD/CE era. ...


"The mission of the XML Query project is to provide flexible query facilities to extract data from real and virtual documents on the World Wide Web, therefore finally providing the needed interaction between the Web world and the database world. Ultimately, collections of XML files will be accessed like databases".[1]

Contents

Features

XQuery provides the means to extract and manipulate data from XML documents or any data source that can be viewed as XML, such as relational databases or office documents.


XQuery uses XPath expression syntax to address specific parts of an XML document. It supplements this with a SQL-like "FLWOR expression" for performing joins. A FLWOR expression is constructed from the five clauses after which it is named: FOR, LET, WHERE, ORDER BY, RETURN. XPath (XML Path Language) is an expression language for addressing portions of an XML document, or for computing values (strings, numbers, or boolean values) based on the content of an XML document. ... SQL (IPA: or IPA: ), commonly expanded as Structured Query Language, is a computer language designed for the retrieval and management of data in relational database management systems, database schema creation and modification, and database object access control management. ... The programming language XQuery defines FLWOR (pronounced as flower) as an expression that supports iteration and binding of variables to intermediate results. ...


The language also provides syntax allowing new XML documents to be constructed. Where the element and attribute names are known in advance, an XML-like syntax can be used; in other cases, expressions referred to as dynamic node constructors are available. All these constructs are defined as expressions within the language, and can be arbitrarily nested.


The language is based on a tree-structured model of the information content of an XML document, containing seven kinds of node: document nodes, elements, attributes, text nodes, comments, processing instructions, and namespaces.


The type system of the language models all values as sequences (a singleton value is considered to be a sequence of length one). The items in a sequence can either be nodes or atomic values. Atomic values may be integers, strings, booleans, and so on: the full list of types is based on the primitive types defined in XML Schema. An XML schema is a description of a type of XML document, typically expressed in terms of constraints on the structure and content of documents of that type, above and beyond the basic syntax constraints imposed by XML itself. ...


XQuery 1.0 does not include features for updating XML documents or databases; it also lacks full text search capability. These features are both under active development for a subsequent version of the language. In text retrieval, full text search (also called free search text ) refers to a technique for searching a computer-stored document or database; in a full text search, the search engine examines all of the words in every stored document as it tries to match search words supplied by the...


XQuery is a programming language that can express arbitrary XML to XML data transformations with the following features:

  1. Logical/physical data independence
  2. Declarative
  3. High level
  4. Side-effect free
  5. Strongly typed language

Examples

The sample XQuery code below lists the unique speakers in each act of Shakespeare's play Hamlet, encoded in hamlet.xml

 <html><head/><body> { for $act in doc("hamlet.xml")//ACT let $speakers := distinct-values($act//SPEAKER) return <span> <h1>{ $act/TITLE/text() }</h1> <ul> { for $speaker in $speakers return <li>{ $speaker }</li> } </ul> </span> } </body></html> 

XQuery is a functional language consisting entirely of expressions. There are no statements, even though some of the keywords appear to suggest statement-like behaviors. To execute a function, the expression within the body gets evaluated and its value returned. Thus to write a function to double an input value, you simply write: Functional programming is a programming paradigm that treats computation as the evaluation of mathematical functions. ... An expression in a programming language is a combination of values and functions or procedures, interpreted according to the particular rules of precedence and of association for a particular programming language, which computes and then returns another value. ... A statement is the minimal unit of structuring in imperative programming languages. ...

 declare function local:doubler($x) { $x * 2 } 

To write a full query that says Hello World you write the expression:

 "Hello World" 

Applications

Below are a few examples of how XQuery can be used:

  1. Extracting information from a database for a use in web service.
  2. Generating summary reports on data stored in an XML database.
  3. Searching textual documents on the Web for relevant information and compiling the results.
  4. Selecting and transforming XML data to XHTML to be published on the Web.
  5. Pulling data from databases to be used for the application integration.
  6. Splitting up an XML document that represents multiple transactions into multiple XML documents.

XQuery and XSLT compared

Scope

Although XQuery was initially conceived as a query language for large collections of XML documents, it is also capable of transforming individual documents. As such, its capabilities overlap with XSLT, which was designed expressly to allow input XML documents to be transformed into XML or other formats. ...


The XSLT 2.0 and XQuery standards were developed by separate working groups within W3C, working together to ensure a common approach where appropriate. They share the same data model, type system, and function library, and both include XPath 2.0 as a sublanguage. The World Wide Web Consortium (W3C) is a consortium that produces standards&#8212;recommendations, as they call them&#8212;for the World Wide Web. ... XPath (XML Path Language) is an expression language for addressing portions of an XML document, or for computing values (strings, numbers, or boolean values) based on the content of an XML document. ...


Origin

The two languages, however, are rooted in different traditions and serve the needs of different communities. XSLT was primarily conceived as a stylesheet language whose primary goal was to render XML for the human reader on screen, on the web (as web template language), or on paper. XQuery was primarily conceived as a database query language in the tradition of SQL. Graphic representation of the world wide web around Wikipedia The World Wide Web (WWW, or simply Web) is an information space in which the items of interest, referred to as resources, are identified by global identifiers called Uniform Resource Identifiers (URI). ... A web template is an element of a web template system that is used to rapidly generate and mass-produce web pages through a pre-defined schematic, layout, or finite number of programming language instructions. ... Database query languages are like programming languages. ... SQL (IPA: or IPA: ), commonly expanded as Structured Query Language, is a computer language designed for the retrieval and management of data in relational database management systems, database schema creation and modification, and database object access control management. ...


Because the two languages originate in different communities, XSLT is stronger in its handling of narrative documents with more flexible structure, while XQuery is stronger in its data handling, for example when performing relational joins.


Versions

XSLT 1.0 appeared as a Recommendation in 1999, whereas XQuery 1.0 only became a Recommendation in early 2007; as a result, XSLT is at present much more widely used. Both languages have similar expressive power, though XSLT 2.0 has many features that are missing from XQuery 1.0, such as grouping, number and date formatting, and greater control over XML namespaces.[2][3][4]. Many of these features are planned for XQuery 1.1. [5]


Any comparison must take into account the fact that XSLT 1.0 and XSLT 2.0 are very different languages. XSLT 2.0, in particular, has been heavily influenced by XQuery in its move to strong typing and schema-awareness.


Strengths and weaknesses

Usability studies have shown that XQuery is easier to learn, especially for users with previous experience of database languages such as SQL.[6] This can be attributed to the fact that XQuery is a smaller language with fewer concepts to learn, and to the fact that programs are more concise. It is also true that XQuery is more orthogonal, in that any expression can be used in any syntactic context. By contrast, XSLT is a two-language system in which XPath expressions can be nested in XSLT instructions but not vice versa.


XSLT is currently stronger than XQuery for applications that involve making small changes to a document (for example, deleting all the NOTE elements). Such applications are generally handled in XSLT by use of a coding pattern that involves an identity template that copies all nodes unchanged, modified by specific templates that modify selected nodes. XQuery has no equivalent to this coding pattern, though in future versions it will be possible to tackle such problems using the update facilities in the language that are under development. [7]


Another facility lacking from XQuery is any kind of mechanism for dynamic binding or polymorphism. The absence of this capability starts to become noticeable when writing large applications, or when writing code that is designed to be reusable in different environments. XSLT offers two complementary mechanisms in this area: the dynamic matching of template rules, and the ability to override rules using xsl:import, that make it possible to write applications with multiple customization layers.


The absence of these facilities from XQuery is a deliberate design decision: it has the consequence that XQuery is very amenable to static analysis, which is essential to achieve the level of optimization needed in database query languages. This also makes it easier to detect errors in XQuery code at compile time.


The fact that XSLT 2.0 uses XML syntax makes it rather verbose in comparison to XQuery 1.0. However, many large applications take advantage of this capability by using XSLT to read, write, or modify stylesheets dynamically as part of a processing pipeline. The use of XML syntax also enables the use of XML-based tools for managing XSLT code. By contrast, XQuery syntax is more suitable for embedding in traditional programming languages such as Java or C#. If necessary, XQuery code can also be expressed in an XML syntax called XQueryX. The XQueryX representation of XQuery code is rather verbose and not convenient for humans, but can easily be processed with XML tools, for example transformed with XSLT stylesheets. [8] [9]


Future work

Currently, two major extensions to the XQuery are under development by W3C:

  • XQuery 1.0 and XPath 2.0 Full-Text [1]
  • XQuery Update Facility

Work has started on XQuery 1.1. Planned new features are listed in a new requirements document: [2] XQuery Update Facility is an extension to the XML Query language, XQuery. ...


Scripting (procedural) extension for XQuery is also being designed: [3]


Further information

  • Querying XML: XQuery, XPath, and SQL/XML in context. Jim Melton and Stephen Buxton. Morgan Kaufmann, 2006. ISBN 1558607110.
  • XQuery. Priscilla Walmsley. O'Reilly Media, 2007. ISBN 0596006349.
  • XQuery: The XML Query Language. Michael Brundage. Addison-Wesley Professional, 2004. ISBN 0321165810.
  • XQuery from the Experts: A Guide to the W3C XML Query Language. Howard Katz (ed). Addison-Wesley, 2004. ISBN 0-321-18060-7
  • An Introduction to the XQuery FLWOR Expression. Dr. Michael Kay (W3C XQuery Committee), 2005.

Michael Kay, (11 October 1951) is the editor of the W3C specification of the XSLT 2. ...

Implementations

See also: :Category:XQuery processors

VTD-XML (http://vtd-xml. ... Open source refers to projects that are open to the public and which draw on other projects that are freely available to the general public. ... In computer science, binding refers to the creation of a simple reference to something which is larger and more complicated and used frequently. ... C is a general-purpose, block structured, procedural, imperative computer programming language developed in 1972 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system. ... The title given to this article is incorrect due to technical limitations. ... “Java language” redirects here. ... Michael Kay, (11 October 1951) is the editor of the W3C specification of the XSLT 2. ... Open source refers to projects that are open to the public and which draw on other projects that are freely available to the general public. ... “Java language” redirects here. ... The title given to this article is incorrect due to technical limitations. ... Open source refers to projects that are open to the public and which draw on other projects that are freely available to the general public. ... Objective Caml (OCaml) is a general-purpose programming language descended from the ML family, created by Xavier Leroy, Jérôme Vouillon, Damien Doligez, Didier Rémy and others in 1996. ... Open source refers to projects that are open to the public and which draw on other projects that are freely available to the general public. ... “Java language” redirects here. ... The Kawa language framework is a computer software written in Java that implements the programming language Scheme. ... Mark Logic is a software company located in San Mateo, California, USA. It is the creator of a new category of enterprise software known as an XML content server. ... The current version of the article or section reads like an advertisement. ... AquaLogic is a software product family from BEA Systems that facilitates service-oriented architecture. ... XQuery Update Facility is an extension to the XML Query language, XQuery. ...

References

  1. ^ W3C (2003-10-25). cited by J.Robie.
  2. ^ Kay, Michael (2001-02-03). Comparing XSLT and XQuery.
  3. ^ Eisenberg, J. David (2005-03-09). Comparing XSLT and XQuery.
  4. ^ Smith, Michael (2001-02-23). XQuery, XSLT "overlap" debated.
  5. ^ XQuery 1.1 requirements.
  6. ^ Usability of XML Query Languages. Joris Graaumans. SIKS Dissertation Series No 2005-16, ISBN 90-393-4065-X
  7. ^ XQuery Update Facility.
  8. ^ XML Syntax for XQuery (XQueryX).
  9. ^ Michael Kay. Saxon diaries: How not to fold constants.

Year 2003 (MMIII) was a common year starting on Wednesday of the Gregorian calendar. ... is the 298th day of the year (299th in leap years) in the Gregorian calendar. ... Year 2001 (MMI) was a common year starting on Monday (link displays the 2001 Gregorian calendar). ... is the 34th day of the year in the Gregorian calendar. ... Year 2005 (MMV) was a common year starting on Saturday (link displays full calendar) of the Gregorian calendar. ... is the 68th day of the year (69th in leap years) in the Gregorian calendar. ... Year 2001 (MMI) was a common year starting on Monday (link displays the 2001 Gregorian calendar). ... is the 54th day of the year in the Gregorian calendar. ...

External links

Portions borrowed with permission from the books "XML Hacks" (O'Reilly Media) and "XQuery" (O'Reilly Media). The Java Community Process or JCP, established in 1995, is a formalized process which allows interested parties to be involved in the definition of future versions and features of the Java platform. ... Open source refers to projects that are open to the public and which draw on other projects that are freely available to the general public. ... Programming Perl is a classic OReilly book. ... Programming Perl is a classic OReilly book. ...


Previous version based on an article at the French language Wikipedia


  Results from FactBites:
 
XQuery - Wikipedia, the free encyclopedia (619 words)
XQuery is a query language (with some programming language features) that is designed to query collections of XML data.
XQuery 1.0 is being developed by the XML Query working group of the W3C.
XQuery is a functional language consisting entirely of expressions.
An introduction to XQuery (3914 words)
XQuery had its origins in a W3C-sponsored query language workshop held way back in 1998, in which representatives from industry, academia, and the research community gathered in Boston to present their views on the features and requirements they considered important in a query language for XML.
XQuery 1.0: An XML Query Language is the linchpin document of the set, but the other documents all contribute toward what is an astonishingly well-specified and comprehensively backstopped language.
XQuery Update Facility Requirements: The features that XQuery requires to be able to write new data into existing documents, as well as query against them.
  More results at FactBites »


 

COMMENTARY     


Share your thoughts, questions and commentary here
Your name
Your comments
Please enter the 5-letter protection code

Want to know more?
Search encyclopedia, statistics and forums:

 


Lesson Plans | Student Area | Student FAQ | Reviews | Press Releases |  Feeds | Contact
The Wikipedia article included on this page is licensed under the GFDL.
Images may be subject to relevant owners' copyright.
All other elements are (c) copyright NationMaster.com 2003-5. All Rights Reserved.
Usage implies agreement with terms.