Database Reference
In-Depth Information
<p> eXist is a native XML <exist:match
xmlns:exist= "http://exist.sourceforge.net/NS/exist" >
database </exist:match> . </p>
By default, util:expand will also expand any XIncludes ( xi:include elements; see
“XInclude” on page 243 ) in the search result. If you don't want XInclude expansion,
you can specify an optional second argument to the function, which accepts serializa‐
tion parameters (as defined in “Serialization Options” on page 119 ) that you can use
to control this.
Using Keywords in Context
As we saw in the previous section, eXist remembers where the matches were for full-
text (and NGram) queries. This allows you to use a feature called “keywords in con‐
text,” or KWIC, that can show these matches to the user, surrounded by limited parts
of the text. If you followed the example explained in “Full-Text Index and KWIC
Example” on page 285 , you've seen this in action already.
You can generate KWIC output using the kwic extension module. This is an XQuery
module, and thus (as fully explained in Chapter 7 ) you'll have to import it explicitly
in your query's prolog:
import module namespace kwic = "http://exist-db.org/xquery/kwic" ;
If you look at the documentation for the kwic module, you'll see lots of functions;
most of these, however, are internal.
The easiest way to use the kwic module is by calling kwic:summarize on a search
result. This will return the matches, surrounded with customizable chunks of text, in
HTML, ready for display. To find out where these matches are, it uses the match
locating functionality as explained in “Locating Matches” on page 296 . We've already
seen this in action, in the example at the beginning of this chapter.
The full definition of the kwic:summarize function is:
kwic:summarize ( $ search-result , $ options )
The $options parameter accepts a small XML fragment that allows you to customize
the function's behavior:
<config width = integer
table? = "yes" | "no"
link? = string />
width (mandatory) tells KWIC how much text (expressed in characters) to keep
before and after the match.
• Omitting table or setting it to "no" causes the output to be wrapped in a p
element:
Search WWH ::




Custom Search