Chemistry Reference and  Research
           
 
Periodic Table
- standard table
- large table
 
Chemical Elements
- by name
- by symbol
- by atomic number
 
Chemical Properties
 
Chemical Reactions
 
Organic Chemistry
 
Branches of Chemistry
Analytical chemistry
Biochemistry
Computational Chemistry
Electrochemistry
Environmental chemistry
Geochemistry
Inorganic chemistry
Materials science
Medicinal chemistry
Nuclear chemistry
Organic chemistry
Pharmacology
Physical chemistry
Polymer chemistry
Supramolecular Chemistry
Thermochemistry

XML query language

(Redirected from XQuery)

XQuery is a programming language under development by the W3C that's designed to query collections of XML data. XQuery provides a mechanism 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. It is semantically similar to SQL. XQuery uses XPath syntax to address specific parts of an XML document. XSLT 2.0 and XQuery are being jointly developed by the XML Query working group.

XQuery provides a mechanism to pull XML content from multiple sources and dynamically generate new content using a declarative language.

XML is a native data type of XQuery and can be used in queries directly without quoted strings or object calls. You separate XML elements from enclosed expressions using curly braces.

Examples

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

<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 imply 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:

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

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

"Hello World"

External links

Portions borrowed with permission from the book "XML Hacks" (O'Reilly).

Previous version based on an article at the French language Wikipedia.

01-04-2007 01:16:19
The contents of this article are licensed from Wikipedia.org under the GNU Free Documentation License. How to see transparent copy