AxKit.org [logo curtesy of http://xml.com]
--sep--
Start Navigation
About AxKit
Index
xml.apache.org
Features
Live Sites
Installation
Documentation
Daily Churn
Getting AxKit
License
Download
Mailing List
Contribute
CVS
Support
Bugs
End Navigation
Prev Top Next

Putting Everything Together

The last key peice to AxKit is how everything is tied together. We have a clean separation of logic, presentation and content, but we've only briefly introduced using processing instructions for setting up the way a file gets processed through the AxKit engine. A generally better and more scalable way to work is to use the AxKit configuration directives to specify how to process files through the system.

Before introducing the configuration directives in detail, it is worth looking at how the W3C sees the evolving web of new media types. The HTML 4.0 specification defined 8 media types:

  • screen - the default media type, for normal web browsers.

  • tty - a media type for tty based devices (e.g. the lynx web browser).

  • printer

  • handheld

  • braille - for braille interpreters

  • tv - for devices such as Microsoft's WebTV and Sony's Playstation2 that have a TV based browser.

  • projection - for projectors

  • aural - for devices that can convert the output to spoken words

AxKit allows you to plug in modules that can detect these different media types, allowing you to deliver the same content in different ways. For finer grained control, you can use named stylesheets (where you might have a printable page output to the screen media type, as seen on many magazine sites such as http://take23.org/ for displaying multi-page articles).

For example, to map all files with extension .dkb to a DocBook stylesheet, you would use the following directives:

<Files *.dkb>
AxAddProcessor text/xsl /stylesheet/docbook.xsl
</Files>

Now if you wanted to display those DocBook files on WebTV as well as ordinary web browsers, but you wanted to use a different stylesheet for WebTV, you would use:

<Files *.dkb>
  <AxMediaType tv>
    AxAddProcessor text/xsl /stylesheets/docbook_tv.xsl
  </AxMediaType>
  <AxMediaType screen>
    AxAddProcessor text/xsl /stylesheets/docbook_screen.xsl
  </AxMediaType>
</Files>

Now let's extend that to chained transformations. Lets say you wanted to build up a table of contents the same way in both views. One way you could do it is to modularize the stylesheet. However it's also possible to chain transformations in AxKit, simply by defining more than one processor for a particular resource:

<Files *.dkb>
  AxAddProcessor text/xsl /stylesheets/docbook_toc.xsl
  <AxMediaType tv>
    AxAddProcessor text/xsl /stylesheets/docbook_tv.xsl
  </AxMediaType>
  <AxMediaType screen>
    AxAddProcessor text/xsl /stylesheets/docbook_screen.xsl
  </AxMediaType>
</Files>

Now the TV based browsers will see DocBook first tranformed by docbook_toc.xsl, then the output of that transformation would be processed by docbook_tv.xsl.

This is exactly how we would build up an application using XSP:

<Files *.xsp>
  AxAddProcessor application/x-xsp .
  <AxMediaType tv>
    AxAddProcessor text/xsl /stylesheets/page2tv.xsp
  </AxMediaType>
  <AxMediaType screen>
    AxAddProcessor text/xsl /stylesheets/page2html.xsp
  </AxMediaType>
</Files>

This resolves the earlier issue we had where the XSP did not output HTML - instead it output something entirely different. Now we can see why - because this way we can build dynamic web applications that work easily on different devices!

There are 4 other config directives similar to AxAddProcessor, which take an additional parameter specifying a particular way to examine the file being processed. These each take an additional parameter to facilitate the match.

  • AxAddRootProcessor

    takes a root element name to match the first (root) element in the XML document. For example:

    AxAddRootProcessor text/xsl article.xsl article
    

    Would process all XML files with a root element of <article> with the article.xsl stylesheet.

  • AxAddDocTypeProcessor

    processes XML documents with the given XML public identifier.

  • AxAddDTDProcessor

    processes all XML documents that use the DTD given as the third option.

  • AxAddURIProcessor

    processes all resources at the matching URI (which is a Perl regexp).

    This option was added for two reasons - firstly that the <LocationMatch> directive is not allowed in a .htaccess file, and secondly that the built in Apache regular expressions are not terribly powerful (for example they cannot do negative matches).

Finally, the <AxStyleName> block allows you to specify named stylesheets. An example that implements printable/default views of a document might be:

<AxMediaType screen>
  <AxStyleName #default>
    AxAddProcessor text/xsl /styles/article_html.xsl
  </AxStyleName>
  <AxStyleName printable>
    AxAddProcessor text/xsl /styles/article_html_print.xsl
  </AxStyleName>
</AxMediaType>

By mixing the various embedded tags, it is possible to build up a very feature rich sitemap of how your files get processed.


Prev Top Next

Printer Friendly
Raw XML