in reply to Re: XML::Twig and #default prefix
in thread XML::Twig and #default prefix

Hello,

I reversed the mapping and I got ns_prefix to report the prefix that I expected, xsd, in this case. That's OK.

What isn't OK is that namespace returns an empty string and not the namespace URL that I assigned in the mapping. Why?

Thanks a lot for your rapid response.

-- DJpumps

Replies are listed 'Best First'.
Re^3: XML::Twig and #default prefix
by mirod (Canon) on Dec 12, 2007 at 09:52 UTC

    I get the proper result:

    /usr/bin/perl use strict; use warnings; use XML::Twig; my $twig = XML::Twig->parse( map_xmlns => { 'http://www.w3.org/2001/XM +LSchema' => 'xsd', }, \*DATA); printf "\$twig->root->gi: %s\n", $twig->root->gi; printf "\$twig->root->namespace: %s\n", $twig->root->namespace; __DATA__ <schema xmlns="http://www.w3.org/2001/XMLSchema"><element name="alert" +/></schema>

    gives me:

    $twig->root->gi: xsd:schema $twig->root->namespace: http://www.w3.org/2001/XMLSchema

    Which version of XML::Twig are you using? I get the results above with XML::Twig 3.32, the latest CPAN release.

      I got the results with 3.30. I'll try again with 3.32 although it does not seem that you made any changes that should affect this behavior between 3.30 and 3.32.
      -- DJpumps