Tamino XQuery User Guide - Software AG Documentation
Tamino XQuery User Guide - Software AG Documentation
Tamino XQuery User Guide - Software AG Documentation
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Advanced Usage<br />
declare default element namespace "http://company.dot.com/namespaces/corporate"<br />
for $a in input()/bib/book<br />
return<br />
<br />
{ $a }<br />
<br />
The default element namespace applies to all unqualified element names, in both expressions and<br />
constructors, unless a different default namespace is defined in an inner scope, as shown in the<br />
following example:<br />
declare default element namespace "X"<br />
declare namespace y="Y"<br />
let $x := {element x2{{element x4{}}}}<br />
return $x/x2/y:x3/y:x4<br />
In this example, the default element namespace applies to all occurrences of x1 and x2; however,<br />
it does not apply to x3 and x4, because their default namespace is defined by the inner specification<br />
xmlns="Y".<br />
The default element namespace does not apply to attribute names.<br />
There is no default attribute namespace.<br />
There is a default function namespace. It applies to function names in function definitions and<br />
function calls.<br />
Tip: You need not declare a namespace in the prolog if you use one of the predeclared<br />
namespaces. You can find the list of predeclared namespaces in the description of<br />
NamespaceDecl in the <strong>XQuery</strong> Reference <strong>Guide</strong><br />
<strong>User</strong>-Defined Functions<br />
In addition to the large set of <strong>XQuery</strong> functions as defined by the W3C and those that are specific<br />
to <strong>Tamino</strong>, you can write your own functions. <strong>User</strong>-defined functions consist of a function header<br />
representing its signature and the function body containing an <strong>XQuery</strong> expression. The header<br />
consists of an identifier, a list of parameters and corresponding type information, and the type of<br />
the return value. Type information is optional: if you omit it, item* will be assumed. Note that<br />
the set of allowed types is restricted to all simple types and some common <strong>XQuery</strong> types (the<br />
reference description of FunctionDecl contains a complete list).<br />
The function identifier must be a QName together with a non-empty namespace prefix. To avoid<br />
introducing a new namespace for locally used functions, that is functions used in the current<br />
module, <strong>XQuery</strong> provides an implicit namespace to which the prefix local is bound. This is an<br />
example for a function that uses this local namespace:<br />
<strong>XQuery</strong> <strong>User</strong> <strong>Guide</strong><br />
77