This work is licensed under a CC |
XQuery has been built on top of XPath 2.0, which means it uses the same foundation as XSLT 2.0. Both languages have a large overlap, and according to personal preferences and the XML task, one language may be preferred over the other. Features such as user-defined functions and schema-awareness bring XQuery even closer to XSLT 2.0, making the decision to choose one over the other mostly a question of personal preference.
<a>123</a>, <b>456</b>
doc("books.xml")//author, doc("books.xml")//titlefor $b in doc("books.xml")//book return $b/title, $b/authorfor $b in doc("books.xml")//book return ( $b/title, $b/author )declare boundary-space strip;
let $a := "Bob Glushko"
return
<book>
<title>Document Engineering</title>
<author> { $a } </author>
</book><book> <title>Document Engineering</title> <author>Bob Glushko</author> <price currency="USD">29.99</price> </book>
element "book" {
element "title" { "Document Engineering" },
element "author" { "Bob Glushko" },
element "price" {
attribute "currency" { "USD" },
29.99
}
}declare function local:onetwothree() as xs:integer+ { (1, 2, 3) };