URL::Transform::SAX::Filter - SAX filter to execute url transformation function when an attribute with url is found
my $writer = XML::SAX::Writer->new( Output => sub { my $type = shift; $output_function->(@_); } ); my $filter = URL::Transform::SAX::Filter->new( Handler => $writer, transform_function => sub { return join('|', @_) }, ); my $sax_parser = XML::SAX::ParserFactory->parser( 'Handler' => $filter, ); $sax_parser->parse_file('test.html');
This filter examines every start tag for a presence of tags and their attributes which may hold link attributes. (SEE HTML::Tagset::linkElements)
For each of them the 'transform_function' is triggered which can modify the url. This function receives following arguments:
$self->{'transform_function'}->( 'tag_name' => 'img', 'attribute_name' => 'src', 'url' => 'http://search.cpan.org/s/img/cpan_banner.png', );
Object constructor.
Requires the 'transform_function' as the argument.
This function handles the 'transform_function' triggering with a proper arguments.
Just ignoring xml declaration. Otherwise we'll end-up with <?xml version="1.0"?> added to all documents.
<?xml version="1.0"?>
URL::Transform, URL::Transform::using::XML::SAX, XML::SAX::Base
Jozef Kutej
To install URL::Transform, copy and paste the appropriate command in to your terminal.
cpanm
cpanm URL::Transform
CPAN shell
perl -MCPAN -e shell install URL::Transform
For more information on module installation, please visit the detailed CPAN module installation guide.