Create reference descriptions for text locations.
The following construct(s) refer to this construct:
tf:createTextReference(node* $input, string $searchString) => node*
The function tf:createTextReference
is specific to Tamino.
It takes a node sequence and a search string as arguments. Similar to the
function tf:containsText
it searches a string, consisting of one
or more words, in a node. However, it does not return a Boolean value, but a
sequence of reference descriptions for each node found.
You can use reference descriptions for subsequent highlighting of these
nodes, see tf:highlight
.
With tf:createTextReference
you can create reference
descriptions based on a search using wildcard characters. The section
Pattern
Matching in the XQuery 4 User Guide
explains this in detail.
$input |
node |
---|---|
$searchString |
string value |
Create reference descriptions to remarks for those patients who respond to current treatment:
for $a in input()/patient return tf:createTextReference($a/remarks, "responding to treatment")
This query returns reference descriptions to the locations of all word tokens found:
Create reference descriptions to books for which the review text uses the word "discussion":
for $a in input()/reviews let $b := $a/entry/review return tf:createTextReference($b, "discussion")
This query returns reference descriptions to the locations of all word tokens found; here in two different nodes:
Create reference descriptions for the occurrences of "Kansas City" and "New York City":
let $x := <p>This is Kansas City and this is New York City</p> for $d in $x//text() let $a := (let $ref1 := tf:createTextReference($d, "Kansas City") for $refeach in $ref1 return $refeach) let $b := (let $ref2 := tf:createTextReference($d, "New York City") for $refeach in $ref2 return $refeach) return <output>{$a}{$b}</output>
Note that reference descriptions are generated for every token that the search term consists of. This is why there are five references in the output and not just two: