1. Summary
  2. Files
  3. Support
  4. Report Spam
  5. Create account
  6. Log in

SaxonAndPerl

From saxon

(Difference between revisions)
Jump to: navigation, search
(Initial content of page copied from saxon-help email)
m (section on LibXML added)
 
(8 intermediate revisions not shown)
Line 1: Line 1:
-
I found XML::Saxon::XSLT2 yesterday on CPAN, tried it and am so happy
+
=Saxon and Perl=
-
now that there finally is some XSLT 2.0 for perl that I thought I let
+
-
you know. In case you don't know already. So far I have only tried
+
-
trivial xslt, so I am not at all sure what the module author Toby
+
-
Inkster means when he writes that LibXSLT is likely to be more
+
-
reliable.
+
-
Anyways, the module is here:
+
On June 18, 2010 Toby Inkster published an early version (0.003) of his module <b>XML::Saxon::XSLT2</b> on [http://search.cpan.org/~tobyink/XML-Saxon-XSLT2-0.003/lib/XML/Saxon/XSLT2.pm CPAN]. The module is still in its early phase, but this seems to be the first time that Saxon and and XSLT 2.0 become easily available from perl.
-
http://search.cpan.org/~tobyink/XML-Saxon-XSLT2-0.003/lib/XML/Saxon/XSLT2.pm
+
 
 +
The module is based on Inline::Java which makes Java code available from Perl.
 +
 
 +
==Installation==
 +
 
 +
You should be able to install the module like any other module from CPAN.
 +
 
 +
<code>
 +
perl -MCPAN -e 'install XML::Saxon::XSLT2'
 +
</code>
 +
 
 +
should install the module, or download it from CPAN and do the install procedure manually
 +
 
 +
<code><pre>
 +
perl Makefile.PL
 +
make
 +
make test
 +
make install
 +
</pre></code>
 +
 
 +
Mainly, the module depends on Inline::Java, so if you can install that, you should have no problems. More details on dependencies [http://deps.cpantesters.org/?module=XML::Saxon::XSLT2;perl=latest here].
 +
 
 +
==Usage==
 +
 
 +
For more info on the usage of the module please see the documentation that comes with XML::Saxon::XSLT, e.g. [http://search.cpan.org/~tobyink/XML-Saxon-XSLT2-0.003/lib/XML/Saxon/XSLT2.pm here]. Maybe it still helps to some people see some actual code:
 +
 
 +
<code><pre>
 +
use XML::Saxon::XSLT2;
 +
open( my $source, '<:encoding(UTF-8)', $ARGV[0] ) or die $!;
 +
open( $xslt, '<:encoding(UTF-8)', $ARGV[1] ) or die $!;
 +
my $transformer = XML::Saxon::XSLT2->new($xslt);
 +
print $transformer->transform($source);
 +
</pre></code>
 +
 
 +
==LibXML==
 +
 
 +
If you are using Perl and XML chances are you are using Gnome's LibXML through Petr Pajas's XML::LibXML module. Well, in that case XML::Saxon::XSLT2 is right for you since it integrates well with XML::LibXML. Instead of opening files on disk, you can hand over XML::LibXML objects both for the source document and the xsl transformation.
 +
 
 +
==Performance==
 +
 
 +
At some point it would be nice to know something about the performance of using XML::Saxon::XSLT2.

Current revision as of 04:18, 23 August 2010

Contents

Saxon and Perl

On June 18, 2010 Toby Inkster published an early version (0.003) of his module XML::Saxon::XSLT2 on CPAN. The module is still in its early phase, but this seems to be the first time that Saxon and and XSLT 2.0 become easily available from perl.

The module is based on Inline::Java which makes Java code available from Perl.

Installation

You should be able to install the module like any other module from CPAN.

perl -MCPAN -e 'install XML::Saxon::XSLT2'

should install the module, or download it from CPAN and do the install procedure manually

perl Makefile.PL
make
make test
make install

Mainly, the module depends on Inline::Java, so if you can install that, you should have no problems. More details on dependencies here.

Usage

For more info on the usage of the module please see the documentation that comes with XML::Saxon::XSLT, e.g. here. Maybe it still helps to some people see some actual code:

use XML::Saxon::XSLT2;
open( my $source, '<:encoding(UTF-8)', $ARGV[0] ) or die $!;
open( $xslt, '<:encoding(UTF-8)', $ARGV[1] ) or die $!;
my $transformer = XML::Saxon::XSLT2->new($xslt);
print $transformer->transform($source);

LibXML

If you are using Perl and XML chances are you are using Gnome's LibXML through Petr Pajas's XML::LibXML module. Well, in that case XML::Saxon::XSLT2 is right for you since it integrates well with XML::LibXML. Instead of opening files on disk, you can hand over XML::LibXML objects both for the source document and the xsl transformation.

Performance

At some point it would be nice to know something about the performance of using XML::Saxon::XSLT2.

Personal tools