So if I create a query in the BaseX 9.3.2 GUI, thus: declare function local:processMatch($in as text(),$matchPattern as xs:string) as item()+ { let $search as element() := analyze-string(normalize-space($in),$matchPattern) return $search };
let $example := <para>These are a bunch of words, and some of the words are <em>special</em> words.</para> for $text in $example//text() return local:processMatch($text,'bunch|special') I get: <fn:analyze-string-result xmlns:fn="http://www.w3.org/2005/xpath-functions"> <fn:non-match>These are a </fn:non-match> <fn:match>bunch</fn:match> <fn:non-match> of words, and some of the words *are*</fn:non-match> </fn:analyze-string-result> <fn:analyze-string-result xmlns:fn="http://www.w3.org/2005/xpath-functions"> <fn:match>special</fn:match> </fn:analyze-string-result> <fn:analyze-string-result xmlns:fn="http://www.w3.org/2005/xpath-functions"> <fn:non-match>words.</fn:non-match> </fn:analyze-string-result> The trailing space after the *are* in the second fn:non-match element is gone. Should that happen? Can I make it stop happening by invoking the function differently? Thanks! Graydon