XML::LibXML::Pipeline - a pipe of XML::LibXSLT objects


  my $p = XML::LibXML::Pipeline->new(
  $res = $p->transform(parse_xml_file("input.xml"));
  $p->output_file($res, "output.xml");


This enables easy chaining of multiple XML transformer objects. The objects in the pipeline do not have to be XML::LibXSLT objects; they just need to implement the transform() method. (This method must take, and return, and XML::LibXML::Document.) In addition, the last transformer in the pipeline must support the methods output_string($doc) and output_file($doc, $filename) if you wish to use these methods.


my $p = XML::LibXML::Pipeline->new($obj1 [, $obj2]...)


$res = $p->transform($doc [, %args ])

Transforms $doc; that is, each of the objects in the pipeline are called with parameters ($doc, %args).

All objects are called with the same arguments; there is no way to selectively pass arguments to the transformers. (If you need to do this, assemble the pipeline by hand.)

$s = $p->output_string($doc)

This runs the output_string() method of the last object in the pipeline on $doc, returning a string.

Note that $doc itself has toString() and toFile() methods; as XML::LibXSLT explains, however, "always output the document in XML format, and in UTF8, which may not be what you asked for in the xsl:output tag."

$p->output_file($doc, $filename)

This runs the output_file() method of the last object in the pipeline on $doc.

See also output_string().


Michael Stillwell <>