Help language development. Donate to The Perl Foundation

LibXSLT cpan:WARRINGD last updated on 2020-06-17


Build Status


LibXSLT - Interface to the GNOME libxslt library


use LibXSLT;
use LibXML::Document;

# process a document with an internal '<?xml-stylesheet ..>' processing-instruction
my LibXML::Document $doc .= parse(location => 'foo.xml');
my Str $result = LibXSLT.process: :$doc;  

# provide an external style-sheet
my LibXML::Document $xsl .= parse(location => 'bar.xsl', :!cdata);
my Str $result = LibXSLT.process: :$doc, :$xsl;

# OO interface
use LibXSLT::Document;
use LibXSLT::Stylesheet;
my LibXSLT $xslt .= new();

my LibXSLT::Stylesheet $stylesheet;
$stylesheet = $xslt.parse-stylesheet($xsl);
# -OR-
# get the stylesheet from a document's '<?xml-stylesheet ..>' processing-instruction
$stylesheet .= load-stylesheet-pi(:$doc);

my LibXSLT::Document::Xslt $results = $stylesheet.transform(:$doc).Xslt;
say $results.Str;


This module is an interface to the GNOME project's libxslt.


LibXSLT has some global options. Note that these are probably not thread or even fork safe - so only set them once per process. Each one of these options can be called either as class methods, or as instance methods. However either way you call them, it still sets global options.

Each of the option methods returns its previous value, and can be called without a parameter to retrieve the current value.


The following methods are available on the LibXSLT class or object:

Input Callbacks

To define LibXSLT or LibXSLT::Stylesheet specific input callbacks, reuse the LibXML input callback API as described in LibXML::InputCallback.

Security Callbacks

To create security preferences for the transformation see LibXSLT::Security. Once the security preferences have been defined you can apply them to an LibXSLT or LibXSLT::Stylesheet instance using the security-callbacks() method.


This module requires the libxslt native library to be installed. Please follow the instructions below based on your platform:

Debian Linux

sudo apt-get install libxslt-dev

Mac OS X

brew update
brew install libxslt




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

Copyright 2001-2009, Ltd.


This Raku module is based on the Perl 5 XML::LibXSLT module. The process() method has been adapted from the Perl 5 XML::LibXSL::Easy module.

With thanks to: Matt Sergeant, Shane Corgatelli, Petr Pal's, Shlomi Fish, יובל קוג'מן (Yuval Kogman)