O'Reilly logo

XML Publishing with AxKit by Kip Hampton

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required