Tamino XQuery User Guide - Software AG Documentation
Tamino XQuery User Guide - Software AG Documentation
Tamino XQuery User Guide - Software AG Documentation
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
The Nuts and Bolts of <strong>XQuery</strong><br />
(1, 2, "a", "b", "c", 3, 4)<br />
■ Sequences may contain duplicates.<br />
(input()/bib/book/author/first, input()/bib/book/author/last, ↩<br />
input()/bib/book/author/first)<br />
(1, 2, 3, 4, 3, 2, 1)<br />
Now that there is an order on a sequence, sequence items may occur more than once in a sequence.<br />
These duplicates can have the same value or the same node identity.<br />
Note: In XPath 1.0, a node could only appear once in a node set.<br />
Remember that every expression in <strong>XQuery</strong> evaluates to a sequence. Even if we have an <strong>XQuery</strong><br />
expression such as<br />
let $x := 5<br />
return $x * 30<br />
that defines a local variable $x and returns its value multiplied by 30, the <strong>XQuery</strong> expression,<br />
strictly speaking, returns a sequence with the single integer value 150.<br />
In contrast to the let variable the type of the sequence for other expressions is constrained to be<br />
a special sequence. For example, a for variable is always an item (identical to a singleton sequence):<br />
for $bib in input()/bib<br />
return $bib<br />
Note: In <strong>XQuery</strong>, all keywords are written in lower case. It results in a parsing error if you<br />
use mixed or upper case.<br />
Retrieving Data<br />
In <strong>Tamino</strong> <strong>XQuery</strong>, there are two functions that provide access to data stored in a <strong>Tamino</strong> database.<br />
The function input() takes no parameters and is an implementation-defined method to assign<br />
nodes from a source to the input sequence which is evaluated in a query expression. In <strong>Tamino</strong>, it<br />
is always the current collection of a <strong>Tamino</strong> database that input() provides access to. The input<br />
sequence then consists of all document nodes of the current collection. Similarly, you can use the<br />
function collection() to access nodes from a collection that may be different from the default<br />
collection. The collection is specified as parameter.<br />
<strong>XQuery</strong> <strong>User</strong> <strong>Guide</strong><br />
25