Installing and Configuring AxKit
Your First AxKit Page
Dynamic Content
More XPathScript Details
XSLT
Putting Everything Together
More Reasons to Use AxKit
AxKit is an XML application server written using the mod_perl framework. At its core, AxKit provides the developer with many ways to set up server-side XML transformations. This allows you to rapidly develop sites that use XML, allowing delivery of the same content in different formats. It also allows you to change the layout of your site very easily, due to the forced separation of content from presentation.
This appendix gives an overview of the ways you can put AxKit to use on your mod_perl-enabled server. It is not a complete description of all the capabilities of AxKit. For more detailed information, please take a look at the documentation provided on the AxKit web site at http://axkit.org/. Commercial support and consultancy services for AxKit also are available at this site.
There are a number of benefits of using XML for content delivery:
Perhaps the most obvious benefit is the longevity of your data. XML is a format that is going to be around for a very long time, and if you use XML, your data (the content of your site) can be processed using standard tools for multiple platforms and languages for years to come.
If you use XSLT as a templating solution, you can pick from a number of different implementations. This allows you to easily switch between tools that best suit your task at hand.
XSLT takes a fundamentally different approach to templating than almost every other Perl templating solution. Rather than focusing on "sandwiching" the data into the template at various positions, XSLT transforms a tree representation of your data into another tree. This not only makes the output (in the case of HTML) less prone to mismatched tags, but it also makes chained processing, in which the output of one transformation becomes the input of another, a lot simpler and faster.
There are many configuration options that allow you to customize your AxKit installation, but in this section we aim to get you started as quickly and simply as possible. This appendix assumes you already have mod_perl and Apache installed and working. See Chapter 3 if this is not the case. This section does not cover installing AxKit on Win32 systems, for which there is an ActiveState package at ftp://theoryx5.uwinnipeg.ca/pub/other.
First download the latest version of AxKit, which you can get either from your local CPAN archive or from the AxKit download directory at http://axkit.org/. Then type the following:
panic% gunzip -c AxKit-x.xx.tar.gz | tar xvf - panic% cd AxKit-x.xx.tar.gz panic% perl Makefile.PL panic% make panic% make test panic% su panic# make install
If Perl's Makefile.PL warns you about missing modules, notably XML::XPath, make a note of the missing modules and install them from CPAN. AxKit will run without the missing modules, but without XML::XPath it will be impossible to run the examples in this appendix.[64]
[64]AxKit is very flexible in how it lets you transform the XML on the server, and there are many modules you can plug in to AxKit to allow you to do these transformations. For this reason, the AxKit installation does not mandate any particular modules to use. Instead, it will simply suggest modules that might help when you install AxKit.
Now we need to add some simple options to the very end of our httpd.conf file:
PerlModule AxKit SetHandler perl-script PerlHandler AxKit AxDebugLevel 10 PerlSetVar AxXPSInterpolate 1
This configuration makes it look as though AxKit will deliver all of your files, but don't worry: if it doesn't detect XML at the URL you supply, it will let httpd deliver the content. If you're still concerned, put all but the first configuration directive in a <Location> section. Note that the first line, PerlModule AxKit, must appear in httpd.conf outside of any runtime configuration blocks. Otherwise, Apache cannot see the AxKit configuration directives and you will get errors when you try to start httpd.
Now, assuming you have XML::XPath installed (try perl -MXML::XPath -e0 on the command line to check), restart Apache. You are now ready to begin publishing transformed XML with AxKit!
Copyright © 2003 O'Reilly & Associates. All rights reserved.