File: xml_records_thru_libxslt

package info (click to toggle)
libxml-sax-machines-perl 0.46-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 436 kB
  • sloc: perl: 1,767; makefile: 9
file content (32 lines) | stat: -rw-r--r-- 773 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
use XML::SAX::Machines 0.31;
use XML::SAX::Machines qw( Pipeline ByRecord Tap );
use XML::Filter::XSLT;

my $f = XML::Filter::XSLT->new( Source => { ByteStream => \*DATA } );

Pipeline(
    ByRecord( $f ),
    \*STDOUT
)->parse_uri( $ARGV[0] );


## "in-place upgrades" until some new releases hit CPAN ;)
use IO::Handle;   ## XML::LibXML needs this to read from filehandles...

sub XML::Filter::XSLT::LibXSLT::set_handler {
    my $self = shift;
    $self->{Handler} = shift;
    $self->{Parser}->set_handler( $self->{Handler} )
        if $self->{Parser};
}



__END__
<xslt:transform version="1.0"
            xmlns:xslt="http://www.w3.org/1999/XSL/Transform"
>
    <xslt:template match="state">
        <xslt:copy-of select="."/>
    </xslt:template>
</xslt:transform>