3.4 Associating the Documents with the Stylesheet


AxKit offers a variety of configuration options for associating documents with its various language processors. Chapter 4 covers each in detail. In Example 3-5, you create an .htaccess file in the same directory as your XML documents. It defines a default style for AxKit to use when processing documents in this directory.

Example 3-5. A simple .htaccess file
 <AxStyleName "#default">   AxAddProcessor text/xsl stylesheets/cryptozoo.xsl </AxStyleName> 

Pay attention to the arguments passed to the AxAddProcessor directive. The first is the MIME type that AxKit examines to decide which language processor modules to use, and the second is the DocumentRoot-relative path to the stylesheet that will be passed to that language processor to transform your XML documents. If you want to use your XPathScript stylesheet rather than the XSLT, you would use AxAddProcessor application/x-xpathscript stylesheets/cryptozoo.xps instead. This processor definition is wrapped in an AxStyleName block. This directive block, in turn , combines the processor definitions it contains into a single "named style" that a StyleChooser or other plug-in can select at runtime. By giving this style the special name #default , you are configuring AxKit to use this style as a fallback if no other style is explicitly selected.

It's time to fire up a web browser and check the results of your work. A request to http://myhost.tld/cryptozoo.xml yields what is shown in Figure 3-1.

Figure 3-1. cryptozoo.xml rendered as HTML

Clicking on the Sightings link reveals what is shown in Figure 3-2.

Figure 3-2. cryptid_sightings.xml rendered as HTML

XML Publishing with AxKit
XML Publishing with Axkit
ISBN: 0596002165
EAN: 2147483647
Year: 2003
Pages: 109
Authors: Kip Hampton

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net