ASCOPE::Apache::XSLT - Aaron's mod_perl XSLT handler.


 <Directory /path/to/some/directory>
  <FilesMatch "\.xml$">
   SetHandler           perl-script
   PerlHandler          ASCOPE::Apache::XSLT
   PerlSetVar           ASCOPE_cachedir         /path/to/cache
   PerlSetVar           ASCOPE_contenttype      text/html
   PerlAddVar           ASCOPE_style            /path/to/make-html.xsl
   PerlAddVar           ASCOPE_style            /path/to/do-something-with-html.xsl
   PerlAddVar           ASCOPE_xslparameter     "css_screen '/mystyles.css screen'"


This is Aaron's mod_perl XSLT handler. It reads a source document and applies one or more stylesheets,caching the output of each transformation along the way.

This is not a replacement for AxKit.

I couldn't get AxKit to do something I needed and decided that it would probably take just as long to write my own thingy as it would to figure out a fix to my problem.

Since I only use AxKit for doing transformations, and not any of the other whiz-bang stuff it can do, I opted for the former.

If the handler encounters any errors during the transformation process, it will simply return the source document as-is. (I may finesse this in future releases.)



The content-type of the final output.



One or more XSLT stylesheets to be applied to the source document. The output of one stylesheet is cached to disk and fed to its subsequent stylesheet.



For example, you may have a series of nested directories organized by date where you want to apply a single, unique stylesheet for the year, month and day.

By default, the handler will apply all of the stylesheets that are added by each Directory's ASCOPE_style PerlSetVar directive.

If you enable the ASCOPE_reset_styles PerlSetVar directive, then the handler will only apply the first stylesheet; that it the most recently defined stylesheet assigned by the ASCOPE_style PerlSetVar directive.

Example :

 <Directory /path/to/content>
   PerlModule           ASCOPE::Apache::XSLT
   SetHandler           perl-script
   PerlHandler          ASCOPE::Apache::XSLT
   PerlSetVar           ASCOPE_cachedir         /usr/local/www/htcache
   PerlSetVar           ASCOPE_contenttype      text/html
 # Index for month
 <DirectoryMatch "/path/to/content/[0-9]{4}/[0-9]{2}">
  PerlSetVar   ASCOPE_reset_styles    On
  <FilesMatch    "index\.html$">
   PerlSetVar   ASCOPE_style          /path/to/render-month.xsl
 # Index for day
 <DirectoryMatch "/path/to/content/[0-9]{4}/[0-9]{2}/[0-9]{2}">
  PerlSetVar   ASCOPE_reset_styles    On
  <FilesMatch    "index\.html$">
   PerlSetVar   ASCOPE_style          /path/to/render-day.xsl


The path to the directory where cache files should be saved. If no value is defined, then the default is '/tmp'.

If the latter, note that your cache files may be deleted whenever the Apache is restarted.


One or more CGI parameters to pass to your XSLT stylesheets.

(Eventually, it would be nice to have a finer grain control to specify parameters on a per-stylesheet basis.)

The following list of CGI parameters are treated specially:


One or more fixed parameters to pass to your XSLT stylesheets.

The parameter name is determined to be every up to, and excluding the first white-space in the key value. The parameter value is everything else.

These directives should be double quoted; additionally if your parameter value contains white-space, the entire value should be wrapped in single quotes.

 PerlAddVar   ASCOPE_xslparameter         "cow moo"
 PerlAddVar   ASCOPE_xslparameter         "duck 'quack quack quack'"

If there ASCOPE_cgiparameter and ASCOPE_xslparameter directives with conflicting keys, the latter will always clobber the former.


This package knows how to play nicely with Apache::Filter.




$Date: 2003/09/25 13:42:08 $




Copyright (c) 2002-2003, Aaron Straup Cope. All Rights Reserved.

This is free software, you may use it and distribute it under the same terms as Perl itself.