in reply to Unwanted <?xml> tags with Lib::XSLT

Untested, but I think this will do it for you:

print OUTPUTFILE $stylesheet->transform($source)->documentElement->toS +tring;
perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'

Replies are listed 'Best First'.
Re^2: Unwanted <?xml> tags with Lib::XSLT
by aeolai (Initiate) on Jul 03, 2012 at 15:28 UTC
    Thanks, I tried print OUTPUTFILE $stylesheet->transform($source)->documentElement->toS but it gives the error "Can't call method "toS" on an undefined value"
      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);