[ You are here: XTF -> Programming -> dynaXML -> Document Formatter ]

Document Formatter Programming

The Document Formatter stylesheet receives as its input the requested XML document. For its output it should produce an HTML based document web-page that can be viewed in the user's browser.

The XML document passed by the dynaXML servlet to the Document Formatter stylesheet consists of the original XML source document with the following additions:
The <snippets> summary tag will have the following form:
<xtf:snippets>
  Snippet
  Snippet
    …
</xtf:snippets>
where each Snippet is a dynaXML snippet tag that summarizes one query match in the requested document.

The additional tags and attributes added by the textIndexer and the dynaXML servlet are prefixed with an xtf: namespace to clearly differentiate them from other tags in the XML document.

It should be noted that, unlike the Result Formatter in crossQuery, the Document Formatter does not receive the <parameters> block from the URL request. But if it needs access to the URL parameters, they are always available through global <xsl:param> declarations.

Sometimes it is helpful to view the raw XML that dynaXML passes to the Document Formatter. To do this, add ;raw=1 to the URL, and the servlet will bypass the formatter completely and display the raw XML directly in your browser. Beware however that large documents may take quite some time to process and transmit.

Writing the Document Formatter can be quite challenging, as many options are possible and the output is very dependent on the structure of the input XML document. In addition, if your collection includes several types of documents, you may need several formatters. Writing XSLT is beyond the scope of this tutorial, but you may get some ideas by examining the sample Document Formatter stylesheets included with the XTF distribution which work on TEI, EAD, and NLM data.

As with everything in XTF, it is advisable (and fun) to start with something simple and then progressively refine the stylesheets over time.