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%22%3E fn:non-matchThese are a </fn:non-match> fn:matchbunch</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%22%3E fn:matchspecial</fn:match> </fn:analyze-string-result> <fn:analyze-string-result xmlns:fn="http://www.w3.org/2005/xpath-functions%22%3E fn:non-matchwords.</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
On 23.04.2020 15:40, Graydon Saunders wrote:
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-matchThese are a </fn:non-match> fn:matchbunch</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:matchspecial</fn:match> </fn:analyze-string-result> fn:analyze-string-result xmlns:fn="http://www.w3.org/2005/xpath-functions" fn:non-matchwords.</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?
Isn't your use of normalize-space in the function causing this? Why do you need that?
basex-talk@mailman.uni-konstanz.de