You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Matt Sergeant <ma...@sergeant.org> on 2000/04/22 19:52:36 UTC
[ANNOUNCE] Apache::XMLStylesheet
I've completed my <?xml-stylesheet?> mapper. Rather than try and stuff
modules into the type="..." attribute I decided it was best to just leave
that as a content-type, and allow you to add mappings to you .htaccess or
wherever you want them...
I've also updated Apache::XPath::NotXSLT to use this module, and for some
glorious reason I'm now getting 80 requests/sec. Very nice.
It's all available on http://xml.sergeant.ord/download/ - I'll upload to
CPAN after I hear back from people, or some other time if no interest is
generated ;-) (PS: Appologies if anyone was trying to access
xml.sergeant.org this afternoon - there seems to be a bug in mod_perl that
I was grappling with to get this to work).
Here's the README. Let me know if there are any questions.
NAME
Apache::XMLStylesheet - Execute module based on <?xml-
stylesheet?>
SYNOPSIS
# in .htaccess
PerlHandler +Apache::XMLStylesheet
PerlSetVar StylesheetMap "text/xsl => XML::XSLT::transformfiles, \
application/x-mystyle => My::Style"
PerlSetVar PreferredStyle "default style"
DESCRIPTION
This module automatically detects XML stylesheet types and
associates modules/functions with those stylesheets according to
the StylesheetMap variable. See http://www.w3.org/TR/xml-
stylesheet for details on the xml-stylesheet processing
instruction that this module uses.
This module also checks for you whether the xml file and
stylesheet files exist, so you don't need to check that in your
template/stylesheet implementation if you don't want to. If an
error occurs at any point it is logged in the error log, and
DECLINED is returned, so that other Apache modules might have a
chance to process the file.
In the mapping you can either present a function (fully
qualified with package), or a package. Different parameters are
passed depending on whether you specify a function or a package:
'type' => Package::function
The function receives the xml filename as the first
parameter, and the stylesheet filename as the second
parameter. The return value of the method is not considered,
and Apache always returns OK.
'type' => Package
The Package's handler() function is called, with the
Apache::Request object as the first parameter, the xml
filename as the second parameter and the stylesheet filename
as the third parameter. Apache returns whatever the return
value of the handler() function is.
The PreferredStyle option will make use of the "alternate"
attribute of the xml-stylesheet processing instruction.
PerlFixupHandler
If you install Apache::XMLStylesheet as a PerlFixupHandler,
rather than an ordinary PerlHandler, the actual type handler
gets called by pushing the handler onto the stack as a
PerlHandler. The benefits of this are that it gives you better
information from the Apache::Request object given as the first
parameter. The downside is that it's significantly slower than
installing as an ordinary PerlHandler (80 requests/sec vs 20 for
a PerlFixupHandler). If anyone can tell me why its so much
slower I'd love to know.
Apache::MimeXML
Originally this module required that Apache::MimeXML v0.03 or
higher be installed, because this module sets the Apache notes
table entry:
is_xml => 1
However it appears that you can't operate PerlTypeHandlers _and_
PerlHandlers at the same time with mod_perl. I've logged a bug,
and hopefully it will get fixed. In the meantime only files
ending in .xml will be processed by this module, which isn't
great.
AUTHOR
Matt Sergeant, matt@sergeant.org
LICENSE
This module is distributed under the same terms as Perl itself.
--
<Matt/>
Fastnet Software Ltd. High Performance Web Specialists
Providing mod_perl, XML, Sybase and Oracle solutions
Email for training and consultancy availability.
http://sergeant.org http://xml.sergeant.org