Xml Query Language

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 Wikipedia.

 

<< PreviousWord BrowserNext >>
national center for biotechnology information
celera genomics
polyrhythm
waldensians
imagine
xpm
tolkien society of sweden
phylogenetic tree
end to end connectivity
bharatiya janata party
odenwald
indian national congress
aaa
sandhi
shivaji
sisak
kurt tucholsky
kopacki rit
fuggerei
drave
mikoyan
lneburg (district)
dortmund
lneburg
dorothea dix
paik nam june
lchow dannenberg
saphire
woodhaven
chris waddle
lightning rod
saint joseph, missouri
queer studies
dave williams
ceske budejovice
dell
country pubs in hampshire
country pub
jean andr deluc
hubert howe bancroft
jack radcliffe
bregenz
flag of sierra leone
bear community