A RESTful browser for eXist Java-Based Function Modules


http://exist-db.org/xquery/text
A module for text searching extension functions.

text:kwic-display($text as text()*, $width as xs:positiveInteger, $callback-function as function, $parameters as item()*) node()*
Deprecated: kwic functionality is now provided by an XQuery module, see http://exist-org/kwic.html.This function takes a sequence of text nodes in $a, containing matches from a fulltext search. It highlights matching strings within those text nodes in the same way as the text:highlight-matches function. However, only a defined portion of the text surrounding the first match (and maybe following matches) is returned. If the text preceding the first match is larger than the width specified in the second argument $b, it will be truncated to fill no more than (width - keyword-length) / 2 characters. Likewise, the text following the match will be truncated in such a way that the whole string sequence fits into width characters. The third parameter $c is a callback function (defined with util:function). $d may contain an additional sequence of values that will be passed to the last parameter of the callback function. Any matching character sequence is reported to the callback function, and the result of the function call is inserted into the resulting node set where the matching sequence occurred. For example, you can use this to mark all matching terms with a <span class="highlight">abc</span>. The callback function should take 3 or 4 arguments: 1) the text sequence corresponding to the match as xs:string, 2) the text node to which this match belongs, 3) the sequence passed as last argument to kwic-display. If the callback function accepts 4 arguments, the last argument will contain additional information on the match as a sequence of 4 integers: a) the number of the match if there's more than one match in a text node - the first match will be numbered 1; b) the offset of the match into the original text node string; c) the length of the match as reported by the index.
$textThe text nodes
$widthThe width
$callback-functionThe callback function
$parametersThe parameters passed into the last argument of the callback function

Returns the results

Deprecated: Improved kwic functionality is now provided by a separate XQuery module, see http://exist-db.org/kwic.html. This function could be removed at anytime during the 1.5 development and will be removed in the 1.6 release.

text:kwic-display($text as text()*, $width as xs:positiveInteger, $callback-function as function, $result-callback as function, $parameters as item()*) node()*
This function takes a sequence of text nodes in $a, containing matches from a fulltext search. It highlights matching strings within those text nodes in the same way as the text:highlight-matches function. However, only a defined portion of the text surrounding the first match (and maybe following matches) is returned. If the text preceding the first match is larger than the width specified in the second argument $b, it will be truncated to fill no more than (width - keyword-length) / 2 characters. Likewise, the text following the match will be truncated in such a way that the whole string sequence fits into width characters. The third parameter $c is a callback function (defined with util:function). $d may contain an additional sequence of values that will be passed to the last parameter of the callback function. Any matching character sequence is reported to the callback function, and the result of the function call is inserted into the resulting node set where the matching sequence occurred. For example, you can use this to mark all matching terms with a <span class="highlight">abc</span>. The callback function should take 3 or 4 arguments: 1) the text sequence corresponding to the match as xs:string, 2) the text node to which this match belongs, 3) the sequence passed as last argument to kwic-display. If the callback function accepts 4 arguments, the last argument will contain additional information on the match as a sequence of 4 integers: a) the number of the match if there's more than one match in a text node - the first match will be numbered 1; b) the offset of the match into the original text node string; c) the length of the match as reported by the index.
$textThe text nodes
$widthThe width
$callback-functionThe callback function
$result-callbackThe result callback function
$parametersThe parameters passed into the last argument of the callback function

Returns the results

Deprecated: Improved kwic functionality is now provided by a separate XQuery module, see http://exist-db.org/kwic.html. This function could be removed at anytime during the 1.5 development and will be removed in the 1.6 release.
Return to list of all modules