XQuery/TEI Concordance

Motivation
You want to build a multi-lingual concordance from parallel texts already in the TEI format (see http://www.tei-c.org/ )

Architecture
There are three steps in this example:
 * 1) preprocessing the texts to enable easier indexing, which is done in XSLT 2.0
 * 2) querying the text to return a tei:entry (see http://www.tei-c.org/release/doc/tei-p5-doc/en/html/DI.html ) which is done in XQuery
 * 3) processing the tei:entry into HTML  which is done in XSLT 1.0 in the browser

In this particular example the languages in use are English and te reo Māori. It assumes that structural tags have 'n' attributes with urls pointing to the original source of the data.

Preprocessing the text
This stylesheet splits the text into words (tei:w see http://www.tei-c.org/release/doc/tei-p5-doc/en/html/ref-w.html ) and records on each a 'lemma' or normalised form of the word and the language it's in. These are re-calculated to allow indexes to be built of them.

Querying the text
The query builds a single  tag containing multiple , one for each hit. A processing instruction is used to associate the TEI with a stylesheet.

Transformation to HTML
The TEI is transformed into HTML in the browser following the processing instruction:

/Text Encoding Initiative