XML::Essex::NamespaceMap - XML::Essex::NamespaceMap documentation


XML-Filter-Essex documentation Contained in the XML-Filter-Essex distribution.

Index


Code Index:

NAME

Top

    XML::Essex::NamespaceMap - ...

SYNOPSIS

Top

DESCRIPTION

Top

Contains a mapping of namespaces to prefixes.

METHODS

Top

new
    my $map = ns_map $ns1 => $prefix1, ...;  ## In Essex scripts.
    my $map = XML::Essex::NamespaceMap->new(
        $essex,
        $ns1 => $prefix1,
        ...
    );
    my $unregistered_map = XML::Essex::NamespaceMap->new(
        $ns1 => $prefix1,
        ...
    );

LIMITATIONS

Top

No way to get at the namespaces and prefixes. Can add one when one is needed, most uses should go through the essex object to fall back to earlier mappings if a mapping doesn't happen to have a particular namespace or prefix.

COPYRIGHT

Top

LICENSE

Top

You may use this module under the terms of the BSD, Artistic, oir GPL licenses, any version.

AUTHOR

Top

Barrie Slaymaker <barries@slaysys.com>


XML-Filter-Essex documentation Contained in the XML-Filter-Essex distribution.
package XML::Essex::NamespaceMap;

$VERSION = 0.000_1;

use strict;

sub new {
    my $proto = shift;
    my $essex;
    $essex = shift if @_ && UNIVERSAL::isa( $_[0], "XML::Essex" );
    my %map = @_;

    my $self = bless {
        Essex => $essex,
        Map   => \%map,
    }, ref $proto || $proto;

    $self->{Essex}->add_namespace_map( $self->{Map} ) if $self->{Essex};

    return $self;
}

sub DESTROY {
    my $self = shift;

    if ( $self->{Essex} ) {
        $self->{Essex}->remove_namespace_map( $self->{Map} );
    }
    else {
        ## Clear out the map in case it was added to an Essex
        ## we don't happen to refer to.
        %{$self->{Map}} = ();
    }
}

1;