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

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 />

Defining a Custom Output Handler<br />

You can define your own method of delivering the response document by using a server extension<br />

(SXS) as output handler. This output handler will then act in place of the internal <strong>Tamino</strong> <strong>XQuery</strong><br />

processor. In general you use:<br />

{?serialization method=""<br />

parameter=""?}<br />

For example, this allows using the XSLT server extension to transform query results on-the-fly:<br />

{?serialization method="XSLT.transform"<br />

parameter="stylesheets" parameter="stylesheets/patientRecords.xsl"?}<br />

<br />

{ for $a in collection('Hospital')/patient<br />

return { $a/name, $a/sex, $a/born, $a/address }<br />

}<br />

<br />

The method attribute identifies the output handler. The two parameters specify the XSL stylesheet<br />

to be used and the query. <strong>Tamino</strong> then passes the query result, the list of patients, to this output<br />

handler which transforms it using the stylesheet patientRecords.xsl.<br />

Please note that you can also use media-type in the serialization pragma for an output handler.<br />

Collations<br />

For certain operations on strings such as comparison or sort operations collations are used. They<br />

inherently determine the result of a comparison to accommodate for special regional purposes or<br />

linguistic needs. If a collation is not defined, <strong>Tamino</strong> uses Unicode codepoints for performing<br />

these operations. There are two ways to use collations: In the schema you can add collation information<br />

per element by using tsd:collation. In addition, you can assign a default collation in the<br />

query prolog such as:<br />

declare default collation "collation?language=fr"<br />

The string literal is the collation URI which is interpreted as relative URL with the base URI http://www.softwareag.com/tamino.<br />

In this example, the collation defined for the French language is<br />

used.<br />

You can use the <strong>Tamino</strong>-specific <strong>XQuery</strong> function tf:getCollation to deploy collations as in the<br />

following query:<br />

82<br />

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

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

Saved successfully!

Ooh no, something went wrong!