[ You are here:
XTF ->
Programming -> crossQuery ]
crossQuery Programming
crossQuery Specific Programming:
Common to
crossQuery and
dynaXML:
Introduction
The
crossQuery servlet previously shown in the XTF overview allows users to search the document library for particular words or phrases. If we look more closely at the
crossQuery portion of the
XTF Overview Diagram, we'll see something like this:

Once again, the basic flow of information in this diagram is left to right. A document search begins with a the user specifying some text to search for on a web page. The query is assembled into a URL of the form:
- http://yourserver:8080/xtf/search?text=TextToFind
This query URL is then passed on to the
crossQuery servlet for processing. The first thing the servlet does is translate the query URL into an XML query that the
crossQuery search engine can actually understand. This translation is accomplished by the XSLT based
Query Parser (
queryParser.xsl).
The
crossQuery search engine then uses the XML query to look for occurrences of the specified text in the document index. Any matches that are found in the index are assembled into a list of XML tags, and passed on to
Result Formatter stylesheet (
resultFormatter.xsl). The
Result Formatter stylesheet then converts the list of matches into HTML for review by the user.
Thus,
XTF allows you to configure, through stylesheets, exactly how queries will be interpreted and how the results will be formatted. For advanced users, there is one more level of configurability: you can actually implement several independent query interfaces, each with their own
Query Parser. How does the
crossQuery servlet decide which parser to run? By calling another stylesheet you can optionally configure, the
Query Router. Note that routing is an advanced feature, and most first-time XTF implementors should stick with the default router and focus on the
Query Parser.
Here's a diagram showing the path of decision making in
crossQuery.

A great way to get a hands-on feel for how
crossQuery works is to use the built-in "Debug Step" mode. Simply add
;debugStep=1 to any search URL. The generated web page will let you step through the entire process, with detailed explanations and real data. The first step looks like this:

The remaining two subsections describe in detail how to write
Query Parser and
Result Formatter XSLT code to carry out the necessary translations.