amonroy has asked for the wisdom of the Perl Monks concerning the following question:

I am re-posting because my original question was updated too many times so it might have been a little confusing. My apologies.

The problem I have is that XML::Twig seems to disregard the map_xmlns argument. Could someone tell me what's wrong with my code? The warn "matched!" never get's called.

use XML::Twig; use strict; my $twig = XML::Twig->new( map_xmlns => { "http://perlmonks.org" => 'aaa', "http://perlmonks.org/blah"=> 'bbb' }, TwigHandlers => { '/aaa:monastery/aaa:foo/bbb:bar/bbb:monk' => sub { warn "match +ed!"; $_[0]->purge; } } ); my $xml =<<XML; <?xml version="1.0" encoding="UTF-8"?> <prefix:monastery xmlns:prefix="http://perlmonks.org"> <prefix:foo> <prefix2:bar xmlns:prefix2="http://perlmonks.org/blah"> <prefix2:monk>Larry Wall</prefix2:monk> </prefix2:bar> </prefix:foo> </prefix:monastery> XML $twig->parse($xml);

Replies are listed 'Best First'.
Re: XML::Twig disregarding map_xmlns in the constructor
by PodMaster (Abbot) on Aug 30, 2004 at 04:52 UTC
    I'd say this qualifies as a bug, but I can't yet tell where. Looks like more than one colon causes a match not to happen (doesn't matter if its an absolute path or not). You'll be able to match bbb:monk.

    MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
    I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
    ** The third rule of perl club is a statement of fact: pod is sexy.