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

Thanks, I tried print OUTPUTFILE $stylesheet->transform($source)->documentElement->toS but it gives the error "Can't call method "toS" on an undefined value"

Replies are listed 'Best First'.
Re^3: Unwanted <?xml> tags with Lib::XSLT
by aeolai (Initiate) on Jul 05, 2012 at 22:53 UTC
    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);