












Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Resources for a university course on xquery and xml querying taught by farnoush banaei-kashani at the university of southern california (usc) in spring 2008. References to xquery specifications, tutorials, parsers, and examples. It explains the need for a new query language for xml data and introduces the concepts of xquery 1.0, including its functional nature, basic building blocks, and various expressions.
Typology: Study notes
1 / 20
This page cannot be seen from the preview
Don't miss anything!













USC - CSCI585 - Spring 2008 - Farnoush Banaei-Kashani
USC - CSCI585 - Spring 2008 - Farnoush Banaei-Kashani
USC - CSCI585 - Spring 2008 - Farnoush Banaei-Kashani
USC - CSCI585 - Spring 2008 - Farnoush Banaei-Kashani
Basic definitions:
It is a functional language and strongly typed
Basic building block:
(^) expression
The value of an expression is always a
(^) sequence
: a collection of zero or
more
(^) items
An item is either an
(^) atomic value
(^) or a
(^) node
A node conforms to one of
(^) 7 node types:
(root) nodeElement, attribute, namespace, text, comment, processing-instruction, and document
USC - CSCI585 - Spring 2008 - Farnoush Banaei-Kashani
USC - CSCI585 - Spring 2008 - Farnoush Banaei-Kashani
return
for $author in distinct(/BOOKS/BOOK/AUTHOR) return
USC - CSCI585 - Spring 2008 - Farnoush Banaei-Kashani
doc("recipes.xml") The initial context for the path expression is given by
// means any child node (not just the immediate child node)
recipe collectionThe result is all simple ingredients used to prepare Ricotta Pie in the
(^) (http://www.brics.dk/~amoeller/XML/xml/recipes.xml)
ingredient The result is given as a list of XML fragments, each rooted with an
(^) element
The
(^) order
(^) of the fragments respects the document order (order matters!
Only return ingredients with
amount
attribute
USC - CSCI585 - Spring 2008 - Farnoush Banaei-Kashani
<big-dept> { $d,
</big-dept>
USC - CSCI585 - Spring 2008 - Farnoush Banaei-Kashani
USC - CSCI585 - Spring 2008 - Farnoush Banaei-Kashani
for $dot1 in $root/BOOKS return $dot1/BOOK/AUTHOR
USC - CSCI585 - Spring 2008 - Farnoush Banaei-Kashani
/BOOKS/BOOK[TITLE = "Data on the Web"]
/BOOKS/BOOK[TITLE = "Data on the Web"]/REVIEW
USC - CSCI585 - Spring 2008 - Farnoush Banaei-Kashani
returnwhere $book/@YEAR < 2000for $book in /BOOKS/BOOK
USC - CSCI585 - Spring 2008 - Farnoush Banaei-Kashani
$fat in $fatbrain/BOOKS/BOOK
where $am/ISBN = $fat/ISBN and $am/PRICE > $fat/PRICE
return
USC - CSCI585 - Spring 2008 - Farnoush Banaei-Kashani
All
(^) author
elements, regardless of how deep they occur in the data:
<xsl:template>
<xsl:apply-templates/>
</xsl:template>
<xsl:template
match="author">
<xsl:value-of/>
</xsl:template>