|-
| '''Summary'''
|Puts a marker element around the resulting {{Code|$nodes}} of a full-text index request.<br />The default tag name of the marker element is {{Code|mark}}. An alternative tag name can be chosen via the optional {{Code|$tag}} argument.<br />Note Please note that :* the XML node to be transformed must be an internal "database" node. The {{Code|transform}} expression can be used to apply the method to a main-memory fragment , as shown in Example 2.* the fulltext expression, which computes the token positions, must be specified within <code>ft:mark(see example)</code> function, as all position information is lost in subsequent processing steps. You may need to specify more than one fulltext expression if you want to use the function in a FLWOR expression, as shown in Example 3.
|-
| '''Examples'''
|* '''Example 1''': The following query returns {{Code|<XML><mark>hello</mark> world</XML>}}, if one text node of the database {{Code|DB}} has the value "hello world":
<pre class="brush:xquery">
ft:mark(db:open('DB')//*[text() contains text 'hello'])
</pre>
* '''Example 2''': The following expression returns {{Code|<p><b>word</b></p>}}:
<pre class="brush:xquery">
copy $p := <p>word</p>
modify ()
return ft:mark($p[text() contains text 'word'], 'b')</pre>
'''Example 3''': The following expression loops through the first ten fulltext results and marks the results in a second expression:
<pre class="brush:xquery">
let $start := 1
let $end := 10
let $term := 'welcome'
for $ft in (db:open('DB')//*[text() contains text { $term }])[position() = $start to $end]
return element hit {
ft:mark($ft[text() contains text { $term }])
}
</pre>
|}