25.12.2013 Views

Tamino XQuery User Guide - Software AG Documentation

Tamino XQuery User Guide - Software AG Documentation

Tamino XQuery User Guide - Software AG Documentation

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Query Examples<br />

This section contains 9 examples.<br />

You can also reduce the output of <strong>Tamino</strong> to the bare query result. See the section Suppressing<br />

the Response Wrapper for details.<br />

Explanation<br />

Here, an element constructor creates the element fact. It contains the expression 3 + 6 that is enclosed<br />

by braces. The arithmetic expression is evaluated and the constructed element is embedded into<br />

the output document element returned by <strong>Tamino</strong>.<br />

There are other constructors that you can use to create other types of nodes such as attribute nodes.<br />

See AdditiveExpr and ElementConstructor in the <strong>Tamino</strong> <strong>XQuery</strong> Reference <strong>Guide</strong> for details.<br />

Basic FLWOR Expressions<br />

In this query we use the technique of constructing elements in a FLWOR expression:<br />

Query<br />

for $b in input()/bib/book<br />

return $b/title<br />

Result<br />

It returns a list of all book titles:<br />

TCP/IP Illustrated<br />

Advanced Programming in the Unix environment<br />

Data on the Web<br />

The Economics of Technology and Content for Digital TV<br />

Explanation<br />

The basic form of a FLWOR expression (pronounced: "flower") is used here. You could very roughly<br />

compare a FLWOR expression with the SQL expression SELECT - FROM - WHERE. The letters in FLWOR<br />

stand for the <strong>XQuery</strong> keywords for, let, where, order by and return, two of which are used here.<br />

Let us examine them more closely:<br />

<strong>XQuery</strong> <strong>User</strong> <strong>Guide</strong><br />

9

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!