Sun Oct 31 21:28:04 2004
Abstract
Installing and Configuring AxKit
This guide presumes that you already have an
Apache Step 1 - Download and Install AxKit
First, visit the AxKit
download directory % perl Makefile.PL warns about missing modules, make a note of these
dependencies and install the corresponding Perl packages before proceeding with the AxKit
installation. AxKit will not be properly installed, otherwise.
Step 2 - Edit Your httpd.conf FileAdd the following lines to your httpd.conf: PerlModule AxKit SetHandler perl-script PerlHandler AxKit AxAddStyleMap application/x-xpathscript Apache::AxKit::Language::XPathScript AxAddStyleMap text/xsl Apache::AxKit::Language::LibXSLT # add the following only if you intend to install Sablotron AxAddStyleMap text/xsl Apache::AxKit::Language::Sablot
Don't worry that this looks like AxKit will deliver all of your files,
if it doesn't detect XML at the URL you give it, it will let the httpd
deliver it as normal. If you're still concerned, put all but the first
configuration directive in a Now, stop and restart your Apache server and assuming you've had no trouble with the steps above, you are now ready to begin publishing transformed XML with AxKit! Installing the Sablotron XSLT Processor (Optional)
This section assumes that you will be installing the Sablotron XSLT processor along with
AxKit. If you want to see AxKit in action but do not want to install Sablotron you may safely
skip to the next section Step 1 - Download and Install the Sablotron XSLT Processor
Next, fetch either the source or appropriate binary distribution of the
Sablotron XSLT Processor from
www.gingerall.com Installing Sablotron from the source: % Step 2 - Install the XML::Sablotron Perl LibraryNext, install XML::Sablotron. You can either install the package by hand or use the CPAN shell. To install using the CPAN shell type: % , cd to the
directory you downloaded the tarball to and type:
% Sample Document TransformationsNow, we're going to see how AxKit works by transforming an XML file containing data about Camelids (note the dubious Perl reference) into HTML. Step 1 - A Sample XML DocumentFirst, you will need a sample XML file. Open the text editor of your choice and type the following:
<?xml version="1.0"?>
<dromedaries>
<species name="Camel">
<humps>1 or 2</humps>
<disposition>Cranky</disposition>
</species>
<species name="Llama">
<humps>1 (sort of)</humps>
<disposition>Aloof</disposition>
</species>
<species name="Alpaca">
<humps>(see Llama)</humps>
<disposition>Friendly</disposition>
</species>
</dromedaries>
Step 2 - Create a Stylesheet
Now, create the stylesheet to transform your XML document. If you have chosen to install
Sablotron or one of the other XSLT processors that AxKit supports you may use either the XSLT
or XPathScript samples below . Using XSLTStart a new file and type the following:
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:template match="/">
<html>
<head><title>Know Your Dromedaries</title></head>
<body>
<table bgcolor="eeeeee" border="1">
<tr>
<th>Species</th>
<th>No of Humps</th>
<th>Disposition</th>
</tr>
<xsl:for-each select="dromedaries">
<xsl:apply-templates select="./species" />
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
<xsl:template match="species">
<tr>
<td><xsl:value-of select="@name" /></td>
<td><xsl:value-of select="./humps" /></td>
<td><xsl:value-of select="./disposition" /></td>
</tr>
</xsl:template>
</xsl:stylesheet>
Using XPathScriptCreate a new file and type:
<%
$t->{'humps'}{'pre'} = "<td>";
$t->{'humps'}{'post'} = "</td>";
$t->{'disposition'}{'pre'} = "<td>";
$t->{'disposition'}{'post'} = "</td>";
$t->{'species'}{testcode} = sub {
my $node = shift;
my $t = shift;
$t->{pre} = '<tr><td>' . findvalue('@name', $node) . '</td>';
$t->{post} = "</tr>";
return 1;
}
%>
<html>
<head>
<title>Know Your Dromedaries</title>
</head>
<body bgcolor="white">
<table bgcolor="eeeeee" border="1">
<tr><th>Species</th><th>No. of Humps</th><th>Disposition</th></tr>
<%= apply_templates('/dromedaries/species') %>
</table>
</body>
</html>
Step 3 - Associate the XML Document with your StylesheetNext, re-open the test.xml file and add the following just after the <?xml version="1.0"?> declaration. If you have selected the XSLT example, add: <?xml-stylesheet href="test.xsl" type="text/xsl"?> <?xml-stylesheet href="test.xps" type="application/x-xpathscript"?> Step 4 - Finishing UpYou are now ready to deliver your little zoological XML data file as formatted HTML! Just copy or move the XML and stylesheet files into the same directory under your httpd DocumentRoot. Then, point your browser to http://your-server.com/path/to/test.xml and you should see your data nicely formatted in an HTML table.
Congratulations, you are now well on the road to adding XML, XSLT, XPathScript and AxKit
to your developmental toolbelt. For more information about AxKit's advanced
features, please visit the AxKit homepage If Things Go Wrong
As I stated in the introduction, this document is designed to walk someone through the
AxKit instalation process, then, on to serving transformed documents as quickly and simply as
possible. Depending upon your setup, installing AxKit may require some special attention to
get it to sanely co-exist with some of the other tools that you may be using. If you've had
any trouble while following the steps outlined here, please consult the AxKit FAQ Other Resourcesmod_perl
XSLT
XPathScript
Edit This Page / Show Page History / |

Home
.