Eventually found the answer. Storing the result of $stylesheet->transform() and using $stylesheet->output_file() fixes this issue, e.g:
use Lib::XSLT;
my $parser = XML::LibXML->new();
my $xslt = XML::LibXSLT->new();
my $source = XML::LibXML->load_xml(location => "$xmlFile");
my $style_doc = $parser->parse_file(Path::Class::File->new("$xsltFile"
+));
my $stylesheet = $xslt->parse_stylesheet($style_doc);
my $results = $stylesheet->transform($source);
$stylesheet->output_file($results, $outputFile);
|