The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

PApp::XSLT - wrapper for an XSLT implementation

SYNOPSIS

 use PApp::XSLT; # try to find any implementation, OR

 use PApp::XSLT::Sablotron; # choose sablotron
 use PApp::XSLT::LibXSLT;   # or choose libxslt
 use PApp::XSLT;            # before loading PApp::XSLT

DESCRIPTION

The PApp::XSLT module is more or less a wrapper around an unnamed XSLT implementation (currently XML::Sablotron or XML::LibXSLT, chosen at runtime, should be moderately easy to add XML::Transformiix or XML::XSLT).

new PApp::XSLT parameter => value...

Creates a new PApp::XSLT object with the specified behaviour. All parameters are optional.

 stylesheet     see the C<stylesheet> method.
 get_<scheme>   see the C<scheme_handler> method.
$old = $xslt->stylesheet([stylesheet-uri])

Set the stylesheet to use for later transformation requests by specifying a uri. The only supported scheme is currently data:,verbatim xml stylesheet text (the comma is not a typoe, see rfc2397 on why this is the most compatible form to the real data: scheme ;).

If the stylesheet is a code reference (or any reference), it is executed for each invocation and should return the actual stylesheet to use.

It always returns the current stylesheet.

$old = $xslt->scheme_handler($scheme[, $handler])

Set a handler for the given uri scheme. The handler will be called with the xslt object, the scheme name and the rest of the uri and is expected to return the whole document, e.g.

   $xslt->set_handler("http", sub {
      my ($self, $scheme, $uri) = @_;
      return "<dokument>text to be returned</dokument>";
   });

might be called with (<obj>, "http", "www.plan9.de/"). Hint: this function can easily be abused to feed data into a stylesheet dynamically.

Not all implementations support this method.

When the $handler argument is undef, the current handler will be deleted. If it is missing, nothing happens (only the old handler is returned).

$xslt->apply(document-uri[, param => value...])

Apply the document (specified by the given document-uri) and return it as a string. Optional arguments set the named global stylesheet parameters.

$xslt->apply_string(xml-doc[, param => value...])

The same as calling the apply-method with the uri data:,xml-doc, i.e. this method applies the stylesheet to the string.

SEE ALSO

PApp.

AUTHOR

 Marc Lehmann <schmorp@schmorp.de>
 http://home.schmorp.de/