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.

Text Retrieval<br />

for $a in input()/reviews/entry<br />

let $ref := tf:createTextReference($a/review, "discussion")<br />

where $ref<br />

return tf:highlight($a, $ref, "REV_DISC")<br />

A <strong>Tamino</strong> client application could highlight the results as follows:<br />

<br />

Data on the Web<br />

34.95<br />

A very good discussion of semi-structured database systems and XML.<br />

<br />

<br />

Advanced Programming in the Unix environment<br />

65.95<br />

A clear and detailed discussion of UNIX programming.<br />

<br />

You can see from the query expression that there are two steps involved when highlighting retrieval<br />

results:<br />

1. Generate a reference description to the locations that should be highlighted.<br />

2. Apply highlighting to the document according to the locations.<br />

Generating Reference Descriptions<br />

A reference description is necessary for highlighting later on. It consists of at least the following<br />

global information:<br />

■ collection<br />

■ document type (“doctype”)<br />

■ document number<br />

■ node id<br />

References to text within a node further need to describe the locations of start and end points, the<br />

range. You can create reference descriptions by using the following functions:<br />

tf:createAdjacentTextReference, tf:createNearTextReference, and tf:createTextReference.<br />

These functions work exactly like their tf:containsXXXText counterparts, only that they return<br />

reference descriptions of text ranges instead of a Boolean value. There is another function<br />

tf:createNodeReference to create reference descriptions of nodes. Let us have a look at the reference<br />

descriptions that will be used in our example query:<br />

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

89

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

Saved successfully!

Ooh no, something went wrong!