Thanks for the information, that's good to know. I think I'll file an enhancement request then: For text-oriented applications (e.g., TEI documents), it would be extremely useful if ft:mark would work with descendant elements; typically you have lots of mixed content, with elements containing rendering information or annotations, such as <hi>, <orig>, <corr>, <persName>, <placeName>, <handShift>, etc.: These elements don't interrupt the logical text flow.
While I concede this may be useful in numerous use cases (and may even seem obvious), it would take quite some time to get implemented, so... please don't expect too much magic for the moment. There will also be some conceptual issues that need to be resolved. As an example, which result would you expect for the following query?
ft:mark(<a>X <b>Y</b> Z</a>[. contains text 'X Y'])
If you don't need the inner elements, you may as well remove them from your document before applying ft:mark(). This is demonstrated by the following example:
copy $x := document { <p>This is a <i>simple</i> test.</p> } modify for $t in $x//*[*][text()] return replace value of node $t with data($t) return ft:mark($x//*[text() contains text 'test'])
If speed is a top priority, you may as well create a new database from all updated source files and build a full text index for the new database...
for $i in collection('...') return copy $x := $i modify for $t in $x//*[*][text()] return replace value of node $t with data($t) return db:add(...)
Christian