SYNOPSIS

 use XML::XSLT;

 my $xslt = XML::XSLT->new ($xsl, warnings => 1);

 $xslt->transform ($xmlfile);
 print $xslt->toString;

 $xslt->dispose();

DESCRIPTION

This module implements the W3C's \s-1XSLT\s0 specification. The goal is full implementation of this spec, but we have not yet achieved that. However, it already works well. See \*(L"\s-1XML::XSLT\s0 Commands\*(R" for the current status of each command.

\s-1XML::XSLT\s0 makes use of \s-1XML::DOM\s0 and LWP::Simple, while \s-1XML::DOM\s0 uses XML::Parser. Therefore XML::Parser, \s-1XML::DOM\s0 and LWP::Simple have to be installed properly for \s-1XML::XSLT\s0 to run.

Specifying Sources

The stylesheets and the documents may be passed as filenames, file handles regular strings, string references or DOM-trees. Functions that require sources (e.g. new), will accept either a named parameter or simply the argument.

Either of the following are allowed:

my $xslt = XML::XSLT->new($xsl); my $xslt = XML::XSLT->new(Source => $xsl);

In documentation, the named parameter `Source' is always shown, but it is never required.

\s-1METHODS\s0

Returns a new \s-1XSLT\s0 parser object. Valid flags are:

DOMparser_args

Hashref of arguments to pass to the XML::DOM::Parser object's parse method.

variables

Hashref of variables and their values for the stylesheet.

base

Base of \s-1URL\s0 for file inclusion.

debug

Turn on debugging messages.

warnings

Turn on warning messages.

indent

Starting amount of indention for debug messages. Defaults to 0.

indent_incr

Amount to indent each level of debug message. Defaults to 1.

Gives the \s-1XSLT\s0 object new \s-1XML\s0 to process. Returns an \s-1XML::DOM\s0 object corresponding to the \s-1XML\s0.

base

The base \s-1URL\s0 to use for opening documents.

parser_args

Arguments to pase to the parser.

Gives the \s-1XSLT\s0 object a new stylesheet to use in processing \s-1XML\s0. Returns an \s-1XML::DOM\s0 object corresponding to the stylesheet. Any arguments present are passed to the XML::DOM::Parser.

base

The base \s-1URL\s0 to use for opening documents.

parser_args

Arguments to pase to the parser.

process(%variables)

Processes the previously loaded \s-1XML\s0 through the stylesheet using the variables set in the argument. Processes the given \s-1XML\s0 through the stylesheet. Returns an \s-1XML::DOM\s0 object corresponding to the transformed \s-1XML\s0. Any arguments present are passed to the XML::DOM::Parser. Processes the given \s-1XML\s0 through the stylesheet. Returns a string containg the result. Example: use XML::XSLT qw(serve);

$xslt = XML::XSLT->new($xsl); print $xslt->serve $xml;

http_headers

If true, then prepends the appropriate \s-1HTTP\s0 headers (e.g. Content-Type, Content-Length); Defaults to true.

xml_declaration

If true, then the result contains the appropriate <?xml?> header. Defaults to true.

xml_version

The version of the \s-1XML\s0. Defaults to 1.0.

doctype

The type of \s-1DOCTYPE\s0 this document is. Defaults to \s-1SYSTEM\s0.

xsl_output_method

Get or set the <xsl:output method= attribute. Valid arguments are 'html', 'text' and 'xml'

toString

Returns the result of transforming the \s-1XML\s0 with the stylesheet as a string.

to_dom

Returns the result of transforming the \s-1XML\s0 with the stylesheet as an \s-1XML::DOM\s0 object.

media_type

Returns the media type (aka mime type) of the object.

dispose

Executes the \*(C`dispose\*(C' method on each \s-1XML::DOM\s0 object.

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 yes

Partially

xsl:call-template yes

Takes attribute 'name' which selects xsl:template's by name. Weak support: - xsl:with-param (select attrib not supported) Not supported yet: - xsl:sort

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
xsl:copy-of limited

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

xsl:decimal-format no

Not supported yet.

xsl:element yes
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 \s-1URL\s0 (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 limited

Only the initial xsl:output element is used. The \*(L"text\*(R" output method is not supported, but shouldn't be difficult to implement. Only the \*(L"doctype-public\*(R", \*(L"doctype-system\*(R", \*(L"omit-xml-declaration\*(R", \*(L"method\*(R", and \*(L"encoding\*(R" attributes have any support.

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 \s-1URL\s0 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 yes

Supported.

xsl:transform limited

Synonym for xsl:stylesheet

xsl:value-of limited

Inserts attribute or element values. Limited support: <xsl:value-of select=\*(L".\*(R"/> <xsl:value-of select=\*(L"/root-elem\*(R"/> <xsl:value-of select=\*(L"elem\*(R"/> <xsl:value-of select=\*(L"//elem\*(R"/> <xsl:value-of select=\*(L"elem[n]\*(R"/> <xsl:value-of select=\*(L"//elem[n]\*(R"/> <xsl:value-of select=\*(L"@attr\*(R"/> <xsl:value-of select=\*(L"text()\*(R"/> <xsl:value-of select=\*(L"processing-instruction()\*(R"/> <xsl:value-of select=\*(L"comment()\*(R"/> and combinations of these. Not supported yet: - attribute 'disable-output-escaping'

xsl:variable partial or from literal text in the stylesheet.
xsl:when limited

Only inside xsl:choose. Limited test support: <xsl:when test=\*(L"@attr='value'\*(R"> <xsl:when test=\*(L"elem='value'\*(R"> <xsl:when test=\*(L"path/[@attr='value']\*(R"> <xsl:when test=\*(L"path/[elem='value']\*(R"> <xsl:when test=\*(L"path\*(R"> 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

General information, bug reporting tools, the latest version, mailing lists, etc. can be found at the \s-1XML::XSLT\s0 homepage:

http://xmlxslt.sourceforge.net/

DEPRECATIONS

Methods and interfaces from previous versions that are not documented in this version are deprecated. Each of these deprecations can still be used but will produce a warning when the deprecation is first used. You can use the old interfaces without warnings by passing \*(C`new()\*(C' the flag \*(C`use_deprecated\*(C'. Example:

$parser = XML::XSLT->new($xsl, "FILE", use_deprecated => 1);

The deprecated methods will disappear by the time a 1.0 release is made.

The deprecated methods are :

output_string

use toString instead

result_string

use toString instead

output

use toString instead

result

use toString instead

result_mime_type

use media_type instead

output_mime_type

use media_type instead

result_tree

use to_dom instead

output_tree

use to_dom instead

transform_document

use transform instead

process_project

use process instead

open_project

use \*(C`Source\*(C' argument to new() and transform instead.

print_output

use serve() instead.

BUGS

Yes.

HISTORY

Geert Josten and Egon Willighagen developed and maintained \s-1XML::XSLT\s0 up to version 0.22. At that point, Mark Hershberger started moving the project to Sourceforge and began working on it with Bron Gondwana.

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.

AUTHORS

Geert Josten <[email protected]>

Egon Willighagen <[email protected]>

Mark A. Hershberger <[email protected]>

Bron Gondwana <[email protected]>

Jonathan Stowe <[email protected]>

RELATED TO XML::XSLT…

\s-1XML::DOM\s0, LWP::Simple, XML::Parser