[thelist] XSLT Server-side

S.tygian B.lacksmith S.tudios studio at zero.zero.xs2.net
Sun Jul 21 18:27:03 CDT 2002


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

J> "So what I need is some kind of solution that can apply
the transformation on the fly as the requests are received,
then send them to the client. My hosting service uses
Apache on a UNIX system."

Joel,

There are a couple of ways that you could go with this,
based on my own experience. A lot of it will depend on
whether or not you have access to compile apps on your
account and whether or not you run mod_perl. All of the
following advice assumes that you'd go with a perl based
solution and you have that type of access. It's the only
variety that I've used so far.

At base you'll need to have expat installed (see
expat.sourceforge.net). This is required for XML::Parser
and both of the XSLT parsers listed below. After installing
expat you will need to install the XML::Parser and
XML::XSLT perl modules. You can usually do that from the
cpan shell.

After getting expat installed you may want to install
either Sablotron (www.gingerall.com) and/or LibXSLT
(xmlsoft.org) and the corresponding perl modules from cpan.
The reason for this is that if your Apache has the expat
libraries compiled in, you'll get segfaults when trying to
use XML::XSLT under mod_perl. And most of the good XSLT
packages that I know of run under mod_perl. :)

After getting these things installed I'd recommend checking
into one of the following two packages:

1. Apache::ASP (www.apache-asp.org). This is perl-based
port of ASP with XSLT capabilities. It's good to use if you
also want to use ASP-style application control, sessions,
etc.

2. AxKit (axkit.org). This is the one I'd recommend. There
are XSP (extensible server pages) packages for it on cpan,
and they provide a great deal of flexibility, flow control,
etc. during the transformation process. There's also a CMS
based on it that is currently under development
(www.callistocms.com - might be down ATM).

Both of these have configurable caches.

You might also want to check into installing Bundle::XML to
get a lot of common support packages at once. The one thing
that I would recommend heavily *against* is installing the
C version of Xalan. I've seen some discussion of it on
other lists and the general consensus is that it's the
slowest parser currently available. AFAIK LibXSLT is
currently the fastest, with Sablotron not far behind. I've
used both without any problems.

See the tip below for delivery of XHTML through XSLT. Took
me a bit of figuring out when I first started using AxKit.
I know that I don't owe yet (first post, BTW) but it might
help in your situation.

HTH,
Scott G. Kearn

Sole Proprietor, S.tygian B.lacksmith S.tudios
Craftsmanship. Pure and simple. (sm)

-----BEGIN PGP SIGNATURE-----
Version: CKT:658:B08

iQA/AwUBPTtCw8w1sgi+BrqYEQK8rACgrbwIF3lTXxQ7dFmno39MFyB0D0oAnjJ0
I6fPeGsSXbbzioF3t0ysCshG
=4jKo
-----END PGP SIGNATURE-----

<tip type="Delivering XHTML through XSLT" name="S. G. Kearn">
One of the problems with delivering XHTML pages through server-side XSLT is
that it needs to be delivered as XML.. but this will cause many browsers,
including Internet Explorer, to display it as XML. This often isn't what is
intended. However, if it's delivered as HTML (the default with most XSLT
processors) it won't include the DOCTYPE element, default namespace, etc.
and won't trigger IE's standards-compliant mode.

In order to get around this, make sure to properly set the attributes of
the xsl:output element. It should appear as follows:

<xsl:output method="xml" omit-xml-declaration="yes"
doctype-public="-//W3C//DTD XHTML 1 Strict//EN"
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
media-type="text/html"/>

The method attribute assures that the page will be delivered with the
default namespace and tag structure intact, while the media-type attribute
assures that the client application will process the output as HTML. The
omit-xml-declaration attribute is set to "yes" in order to make sure that
the DOCTYPE element is the first line (required for triggering IE's
standards-compliant mode), and the doctype declaration itself is
constructed from the values for the doctype-public and doctype-system
attributes. Modify those as needed.
</tip>




More information about the thelist mailing list