XSLT transform with Perl

Here is a Perl snippet that transforms an XML file with XSLT:

use strict;
use XML::XSLT::Wrapper;

my $xml_input_filename = "xml/data.xml";
my $xml_output_filename = "xml/out.xml";
my $xsl_filename = "xml/transform.xslt";

my $xslt = XML::XSLT::Wrapper->new(
		ProcessorList => [
			'libxslt',
			'sablotron',
			'xslt'
		],
	);
my $result = $xslt->transform(
		OutFile => $xml_output_filename,
		xml => $xml_input_filename,
		xsl => $xsl_filename,
	);
$xslt->dispose();

Values given to [code]]czo2OlwieG1sID0+XCI7e1smKiZdfQ==[[/code] and [code]]czo2OlwieHNsID0+XCI7e1smKiZdfQ==[[/code] can be either file names, or xml/xslt code passed as a string.

If [code]]czo3OlwiT3V0RmlsZVwiO3tbJiomXX0=[[/code] is ommited, then the result of the transformation is returned to the variable [code]]czo3OlwiJHJlc3VsdFwiO3tbJiomXX0=[[/code].

This entry was posted in Data Processing, Programming, Tips & Tricks and tagged , , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>