NAME

XML::Filter::Namespace - strip all but a single namespace

SYNOPSIS

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.

DESCRIPTION

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.

METHODS

ns ( NAMESPACE )

Set the namespace to include. Must be set before parsing.

systemid ( SYSTEMID )

Set to the SystemID of a DTD. This will cause a DOCTYPE declaration to be output.

publicid ( PUBLICID )

Set to the PublicId of a DTD. This will cause a DOCTYPE declaration to be output.

nl_after_tag ( HASHREF )

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.

SEE ALSO

XML::SAX::Base(3), filtns(1).

BUGS

There should be an option to keep attributes which are in the empty namespace.

AUTHOR

Dominic Mitchell <cpan@semantico.com>

VERSION

@(#) $Id: Namespace.pm,v 1.7 2003/04/24 13:40:52 dom Exp $

LICENSE

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.