tf:highlight()

Hi!

I would like to use the highlight-function in a XQuery.

Example-Query:

declare namespace tf='http://namespaces.softwareag.com/tamino/TaminoFunction'
for $b in input()/a
where (tf:containsText($b/xy, 'Peter') or
       tf:containsText($b/xyz, 'Auto') or
       tf:containsText($b/abc, 'Hans') and
       tf:containsText($b/cde, 'IT') and
       $b/asdf="Unfall"
return $b



I would like to highlight “Peter, Auto, Hans and IT” in the query-result.

How does it work?

Bj

Hello,

I would have a look at the documentation for specific details, but essentially you need to create text references for the portions for highlighting with the tf:createTextReference() and then use the tf:highlight() function to produce a result with the ‘highlighting’. So your query becomes something like:-

  
declare namespace tf='http://namespaces.softwareag.com/tamino/TaminoFunction'
for $b in input()/a
let $ref1 := (tf:createTextReference($b/xy, 'Peter'), 
              tf:createTextReference($b/abc, 'Hans'),
              tf:createTextReference($b/xyz, 'Auto'),
              tf:createTextReference($b/cde, 'IT'))
where (
       tf:containsText($b/xy, 'Peter') or
       tf:containsText($b/xyz, 'Auto') or
       tf:containsText($b/abc, 'Hans') and
       tf:containsText($b/cde, 'IT') and
       $b/asdf="Unfall"
)
return tf:highlight($b, $ref1, "REV")



Hope this helps.

Stuart Fyffe-Collins
Software AG (UK) Ltd.

Hi!

Thanks for your answer. It works.

Bj