XML::STX - a pure Perl STX processor


XML-STX documentation  | view source Contained in the XML-STX distribution.

Index


NAME

Top

XML::STX - a pure Perl STX processor

SYNOPSIS

Top

 use XML::STX;

 $stx = XML::STX->new();

 $transformer = $stx->new_transformer($stylesheet_uri);
 $transformer->transform($source_uri);

DESCRIPTION

Top

XML::STX is a pure Perl implementation of STX processor. Streaming Transformations for XML (STX) is a one-pass transformation language for XML documents that builds on the Simple API for XML (SAX). See http://stx.sourceforge.net/ for more details.

Dependencies: XML::SAX, XML::NamespaceSupport and Clone.

The current version is unstable.

USAGE

Top

Shortcut TrAX-like API

Thanks to various shortcuts of the TrAX-like API, this is the simplest way to run transformations. This can be what you want if you are happy with just one transformation context per stylesheet, and your input data is in files. Otherwise, you may want to use some more features of this API (see Full TrAX-like API|full trax-like api).

 use XML::STX;

 $stx = XML::STX->new();

 $transformer = $stx->new_transformer($stylesheet_uri);
 $transformer->transform($source_uri);

Full TrAX-like API

This is the regular interface to XML::STX allowing to run independent transformations for single template, bind external parameters, and associate drivers/handlers with input/output channels.

 use XML::STX;

 $stx = XML::STX->new();

 $stylesheet = $stx->new_source($stylesheet_uri);
 $templates = $stx->new_templates($stylesheet);
 $transformer = $templates->new_transformer();

 $transformer->{Parameters} = {par1 => 5, par2 => 'foo'}';

 $source = $stx->new_source($source_uri);
 $result = $stx->new_result();

 $transformer->transform($source, $result);

SAX Filter

 use XML::STX;
 use SAX2Parser;
 use SAX2Handler;

 $stx = XML::STX->new();
 $stx_parser = XML::STX::Parser->new();
 $xml_parser1 = SAX2Parser->new(Handler => $stx_parser);
 $stylesheet =  $xml_parser1->parse_uri($templ_uri);

 $writer = XML::SAX::Writer->new();
 $stx = XML::STX->new(Handler => $writer, Sheet => $stylesheet );
 $xml_parser2 = SAX2Parser->new(Handler => $stx);
 $xml_parser2->parse_uri($data_uri);

Legacy API (deprecated)

 use XML::STX;

 $stx = XML::STX->new();
 $parser_t = SAX2Parser->new();
 $stylesheet = $stx->get_stylesheet($parser_t, $templ_uri);

 $parser = SAX2Parser->new();
 $handler = SAX2Handler->new();
 $stx->transform($stylesheet, $parser, $data_uri, $handler);

Command-line Interface

XML::STX is shipped with stxcmd.pl script allowing to run STX transformations from the command line.

Usage:

 stxcmd.pl [OPTIONS] <stylesheet> <data> [PARAMS]

Run stxcmd.pl -h for more details.

AUTHOR

Top

Petr Cimprich (Ginger Alliance), petr@gingerall.cz

SEE ALSO

Top

XML::SAX, XML::NamespaceSupport, perl(1).


XML-STX documentation  | view source Contained in the XML-STX distribution.