XML::Filter::Namespace - strip all but a single namespace
use XML::Filter::Namespace; # The traditional way. use XML::SAX::ParserFactory; use XML::SAX::Writer; my $w = XML::SAX::Writer->new( Output => \*STDOUT ); my $xfn = XML::Filter::Namespace->new( Handler => $w ); $xfn->ns( 'urn:my-namespace' ); my $p = XML::SAX::ParserFactory->parser( Handler => $xfn ); $p->parse_uri( '-' ); # Take input from STDIN. # The SAX Machines way. use XML::SAX::Machines qw( Pipeline ); my $strip = XML::Filter::Namespace->new; $strip->ns( 'urn:my-namespace' ); my $m = Pipeline->new( $strip => \*STDOUT ); $m->parse_uri( '-' ); # Take input from STDIN.
This module strips out everything in an XML document that does not belong in a specified namespace. This often provides a view of the XML that is much clearer when multiple namespaces are in use.
A warning will be issued if a publicid is specified without a systemid.
Duplicate namespace declarations will be stripped out.
Set the namespace to include. Must be set before parsing.
Set to the SystemID of a DTD. This will cause a DOCTYPE declaration to be output.
Set to the PublicId of a DTD. This will cause a DOCTYPE declaration to be output.
Set to a hash reference whose keys are tag names (sans prefix) and whose values are true. Those tags will have newlines output after their close tag.
XML::SAX::Base(3), filtns(1).
There should be an option to keep attributes which are in the empty namespace.
Dominic Mitchell <cpan@semantico.com>
@(#) $Id: Namespace.pm,v 1.8 2003/04/27 18:41:40 dom Exp $
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install XML::Filter::Namespace, copy and paste the appropriate command in to your terminal.
cpanm
cpanm XML::Filter::Namespace
CPAN shell
perl -MCPAN -e shell install XML::Filter::Namespace
For more information on module installation, please visit the detailed CPAN module installation guide.