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.
Advanced Usage<br />
This chapter covers some advanced <strong>XQuery</strong> usage. This functionality is partly tied to using <strong>Tamino</strong><br />
query pragmas that affect the processing of the query. With <strong>Tamino</strong> query pragmas you can import<br />
modules and add declarations for namespaces and collations as well as functions and external<br />
variables. They have the syntactic form {?piname?}, which is why they were previously called<br />
<strong>XQuery</strong> processing instructions. This chapter discusses some of these concepts:<br />
Another important area of advanced <strong>XQuery</strong> usage is related to performance questions and optimizing<br />
your <strong>Tamino</strong> <strong>XQuery</strong> programs. You can find more information about this topic in the<br />
Performance <strong>Guide</strong>.<br />
Namespaces<br />
A namespace declaration defines a namespace prefix and associates it with a valid namespace<br />
URI. This namespace declaration is valid throughout the query expression. For example, you can<br />
define your own namespace:<br />
declare namespace dotcom="http://company.dot.com/namespaces/corporate"<br />
for $a in input()/bib/book<br />
return<br />
<br />
{ $a }<br />
<br />
It is an error (INOXQE 6356) to redefine a namespace:<br />
declare namespace dotcom="http://company.dot.com/namespaces/corporate"<br />
declare namespace dotcom="http://company.dot.com/new-namespaces/corporate"<br />
for $a in input()/bib/book<br />
return<br />
<br />
{ $a }<br />
<br />
But you can use two different namespaces at the same time:<br />
declare namespace dotcom="http://company.dot.com/namespaces/corporate"<br />
declare namespace tf="http://namespaces.softwareag.com/tamino/<strong>Tamino</strong>Function"<br />
for $a in input()/bib/book<br />
where tf:containsText($a/title, "UNIX")<br />
return<br />
<br />
{ $a }<br />
<br />
You can also declare default namespaces that can be applied to elements or attributes alike.<br />
76<br />
<strong>XQuery</strong> <strong>User</strong> <strong>Guide</strong>