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

Chapter 4. Points of Style

Style is an important concept in the AxKit world. Much of the value that AxKit adds as an XML publishing and application server lies in the flexibility and ease with which documents can be associated with one or more sets of transformations that can be selected dynamically in response to a condition. From more common web-publishing tasks, such as vendor co-branding and user customization, to more advanced dynamic data-oriented applications, the key to developing clean, manageable sites with AxKit lies in learning how to apply the appropriate styles to the content to meet the specific need. In this chapter, I introduce AxKit’s basic styling configuration options and show how these options can be combined to create sophisticated, responsive sites.

Adding Transformation Language Modules

Before you can begin associating documents with the stylesheets that will be used to transform them, you must tell AxKit which lower-level processors to use to perform those transformations. In AxKit, access to various transformative processors is provided by its Language modules. Many of these modules create a bridge between AxKit and an existing XML processing tool. For example, the Apache::AxKit::Language::LibXSLT module allows AxKit access to Perl’s XML::LibXSLT interface and, hence, to the Gnome project’s XSLT processing library, libxslt. Other Language modules, such as AxKit’s implementation of eXtensible Server Pages, ApacheAxKit::Language::XSP, are unique to AxKit and implement both the interface that allows it to be added to the AxKit processing chain and the code that actually processes the XML content. The core AxKit distribution contains several such Language modules:


Adds support for the Gnome Project’s libxslt processor; used to transform documents with XSLT


An alternate XSLT transformer using the Sablotron XSLT processor from The Ginger Alliance


Adds support for a more Perlish alternative to XSLT, XPathScript


Provides an interface to AxKit’s implementation of the eXtensible Server Pages (XSP)


Provides an AxKit interface to Barrie Slaymaker’s popular XML::SAX::Machines Perl module, which offers an easy way to set up chains of SAX Filters to transform XML content


Offers XSL-FO (XSL Formatting Objects) support for generating PDF documents from FO sources via PassiveTeX suite’s pdfxmltex utility


Converts XHTML documents to PDF, also using PassiveTeX

Several other Language modules come with AxKit, and still others are available via the Comprehensive Perl Archive Network (CPAN). For example, many of Perl’s more popular templating packages (the Template Toolkit, Petal, etc.) are also available as AxKit Language processors. However, while AxKit or an individual CPAN distribution may provide the Language modules needed to allow AxKit to access a given type of processor, they do not usually install any lower-level tools with which the modules may interface. For example, if you intend to use the Apache::AxKit::LibXSLT module for XSLT processing, you must be sure to first install the XML::LibXML and XML::LibXSLT Perl modules as well as the libxml2 and libxslt C libraries that it requires.

Once you decide which kinds of transformations to use for your site, the Language module is added to AxKit via the AxAddStyleMap directive. This directive expects two arguments: a MIME type that uniquely identifies the language, and the Perl package name of the module that implements that language’s processor:

<AxAddStyleMap text/xsl Apache::AxKit::Language::LibXSLT

This associates the MIME type text/xsl with the Perl package name of the LibXSLT Language module, Apache::AxKit::Language::LibXSLT. This mapping is important since the MIME type assigned here is used as the identifier to associate the site’s stylesheets with the appropriate language processor that will be used to apply those stylesheets to the source content. So, given the above example, all style definitions that declare the type text/xsl will be applied to the source XML using the Apache::AxKit::Language::LibXSLT language module.

Although AxAddStyleMap directives may appear anywhere in a site’s configuration files, these type-to-module mappings are typically meant to apply to a whole site and, therefore, usually appear together at the top level of the host’s AxKit configuration:

<Directory "/www/sites/myaxkitsite">
  AddHandler axkit .xml .xsp. .xsp .dbk]]>
  <emphasis role="bold">AxAddStyleMap text/xsl Apache::AxKit::Language::LibXSLT
  AxAddStyleMap application/x-xpathscript Apache::AxKit::Language::XPathScript
  AxAddStyleMap application/x-xsp Apache::AxKit::Language::XSP</emphasis>

Once the language processors are set up, the style definitions that will control the transformations that AxKit will apply to the content can be added.

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