NAME

XML::XSLT - A perl module for processing XSLT

SYNOPSIS

 use XML::XSLT;

 my $parser = XML::XSLT->new ($xslfile, $xslflag, warnings => "Active");

 $parser->transform_document ($xmlfile, $xmlflag);
 $parser->print_result;  

 $parser->dispose ();

	The variables $xmlfile and $xslfile are filenames, e.g. "filename",
        regular Perl filehandles, pass those with *FILEHANDLE, or Perl streams.

        After dispose, the parser object is destroyed. The result thus also!

# Alternative sources

The stylesheets and the documents may be passed as filenames, file handles regular strings, string references or DOM-trees. The source type is identified by the flags "FILE" (filename and -handle), "STRING" (string and string ref) and "DOM" (DOM-tree). For example:

my $parser = XML::XSLT->new ($xslstring, "STRING", warnings => "Active");

$parser->transform_document ($xmldom_rootnode, "DOM");
$parser->print_result;

# Alternatives for print_result()

Instead of printing to STDOUT, a filename or file can be passed to print_result():

$parser->print_result($outputfile);

       The variable $outputfile is a filename, e.g. "filename" or a regular
       Perl filehandle. Pass the latter with *FILEHANDLE.

Instead of printing at all, the result can be requested as a string or a DOM tree as well with:

$parser->result_string;

$parser->result_tree;

# Reusable parser objects

This approach attaches one stylesheet to one parser object. The stylesheet can be applied to multiple documents and multiple parser objects can co-exist:

my $parser1 = XML::XSLT->new ($xslfile1, $xslflag1, warnings => "Active");
my $parser2 = XML::XSLT->new ($xslfile2, $xslflag2, warnings => "Active");

$parser1->transform_document ($xmlfile1, $xmlflag1);
$parser1->print_result ($xmlout1);
$parser1->transform_document ($xmlfile2, $xmlflag2);
$parser1->print_result ($xmlout2);  
$parser2->transform_document ($xmlfile1, $xmlflag1);
$parser2->print_result ($xmlout3);  
$parser2->transform_document ($xmlfile2, $xmlflag2);
$parser2->print_result ($xmlout4);  

This way the stylesheet-file does not have to be parsed all over again, but is reused each time.

DESCRIPTION

This module implements the W3C's XSLT specification. The goal is full implementation of this spec, but it isn't yet. However, it already works well. Below is given the set of working xslt commands.

XML::XSLT makes use of XML::DOM and LWP::UserAgent, while XML::DOM uses XML::Parser. Therefore XML::Parser, XML::DOM and LWP::UserAgent have to be installed properly for XML::XSLT to run.

LICENCE

Copyright (c) 1999 Geert Josten & Egon Willighagen. All Rights Reserverd. This module is free software, and may be distributed under the same terms and conditions as Perl.

XML::XSLT Commands

xsl:apply-imports no

Not supported yet.

xsl:apply-templates limited

Attribute 'select' is supported to the same extent as xsl:value-of supports path selections.

Not supported yet: - attribute 'mode' - xsl:sort and xsl:with-param in content

xsl:attribute partially

Adds an attribute named to the value of the attribute 'name' and as value the stringified content-template.

Not supported yet: - attribute 'namespace'

xsl:attribute-set no

Not supported yet.

xsl:call-template yes

Takes attribute 'name' which selects xsl:template's by name.

Not supported yet: - xsl:sort and xsl:with-param in content

xsl:choose yes

Tests sequentially all xsl:whens until one succeeds or until an xsl:otherwise is found. Limited test support, see xsl:when

xsl:comment yes

Supported.

xsl:copy partially

Not supported yet: - attribute 'use-attribute-sets'

xsl:copy-of limited

Attribute 'select' functions as well as with xsl:value-of

xsl:decimal-format no

Not supported yet.

xsl:element no

Not supported yet.

xsl:fallback no

Not supported yet.

xsl:for-each limited

Attribute 'select' functions as well as with xsl:value-of

Not supported yet: - xsl:sort in content

xsl:if limited

Identical to xsl:when, but outside xsl:choose context.

xsl:import no

Not supported yet.

xsl:include yes

Takes attribute href, which can be relative-local, absolute-local as well as an URL (preceded by identifier http:).

xsl:key no

Not supported yet.

xsl:message no

Not supported yet.

xsl:namespace-alias no

Not supported yet.

xsl:number no

Not supported yet.

xsl:otherwise yes

Supported.

xsl:output no

Not supported yet.

xsl:param experimental

Synonym for xsl:variable (currently). See xsl:variable for support.

xsl:preserve-space no

Not supported yet. Whitespace is always preserved.

xsl:processing-instruction yes

Supported.

xsl:sort no

Not supported yet.

xsl:strip-space no

Not supported yet. No whitespace is stripped.

xsl:stylesheet limited

Minor namespace support: other namespace than 'xsl:' for xsl-commands is allowed if xmlns-attribute is present. xmlns URL is verified. Other attributes are ignored.

xsl:template limited

Attribute 'name' and 'match' are supported to minor extend. ('name' must match exactly and 'match' must match with full path or no path)

Not supported yet: - attributes 'priority' and 'mode'

xsl:text partially

Not supported yet: - attribute 'disable-output-escaping'

xsl:transform limited

Synonym for xsl:stylesheet

xsl:value-of limited

Inserts attribute or element values. Limited support:

<xsl:value-of select="."/>

<xsl:value-of select="/root-elem"/>

<xsl:value-of select="elem"/>

<xsl:value-of select="//elem"/>

<xsl:value-of select="elem[n]"/>

<xsl:value-of select="//elem[n]"/>

<xsl:value-of select="@attr"/>

<xsl:value-of select="text()"/>

<xsl:value-of select="processing-instruction()"/>

<xsl:value-of select="comment()"/>

and combinations of these;

Not supported yet: - attribute 'disable-output-escaping'

xsl:variable experimental

Very limited. It should be possible to define a variable and use it with &lt;xsl:value select="$varname" /&gt; within the same template.

xsl:when limited

Only inside xsl:choose. Limited test support:

<xsl:when test="@attr='value'">

<xsl:when test="elem='value'">

<xsl:when test="path/[@attr='value']">

<xsl:when test="path/[elem='value']">

<xsl:when test="path">

path is supported to the same extend as with xsl:value-of

xsl:with-param experimental

It is currently not functioning. (or is it?)

SUPPORT

Support can be obtained from the XML::XSLT mailling list:

http://xmlxslt.listbot.com/

General information, like bugs and current functionality, can be found at the XML::XSLT homepage:

http://www.sci.kun.nl/sigma/Persoonlijk/egonw/xslt/