Skip Menu |

This queue is for tickets about the XML-SAX-Writer CPAN distribution.

Report information
The Basics
Id: 152
Status: resolved
Priority: 0/
Queue: XML-SAX-Writer

People
Owner: Nobody in particular
Requestors: rho [...] bigpond.net.au
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.36
Fixed in: (no value)



Subject: namespace handling broken?
I'm using 0.36 here as my local mirror does not seem to have 0.37, This is perl, v5.6.1 built for i586-linux. It seems that local namespace declarations are not honored by start_element. It checks the tag and the attributes but xmlns:xxxx = 'yyyy' never seem to make it into the XML::NamespaceSupport object. I have patched Writer.pm just to support my thesis: 112,118d111 < # add local NS declarations < foreach my $a (keys %$attr) { < if ($attr->{$a}->{Prefix} eq 'xmlns') { < $self->{NSHelper}->declare_prefix($attr->{$a}->{LocalName}, $attr->{$a}->{Value}); < } < } Maybe you can have a look. Thx! \rho PS: Testfile attached.
package my_filter; use base qw(XML::SAX::Base); use Data::Dumper; sub new { my $class = shift; my %options = @_; my $self = bless \%options, $class; return $self; } sub start_element { my $self = shift; my $data = shift; if ($data->{NamespaceURI} eq 'in' && $data->{LocalName} eq 'default') { print "start_element $data->{LocalName}", "\n",Dumper ($self, $data); $self->SUPER::start_element ({ 'LocalName' => 'xxxx', 'NamespaceURI' => 'out', 'Prefix' => 'out', 'Name' => 'out:xxxx' }); $self->SUPER::characters ({Data => 'rumsti'}); $self->SUPER::end_element ({ 'LocalName' => 'xxxx', 'NamespaceURI' => 'out', 'Prefix' => 'out', 'Name' => 'out:xxxx' }); } else { $self->SUPER::start_element ($data); } } sub end_element { my $self = shift; my $data = shift; if ($data->{NamespaceURI} eq 'in' && $data->{LocalName} eq 'default') { } else { $self->SUPER::end_element ($data); } } 1; my $s; use XML::SAX::Writer; my $writer = new XML::SAX::Writer (Output => \$s); my $filter = new my_filter (Handler => $writer); use XML::SAX::ParserFactory; my $parser = XML::SAX::ParserFactory->parser(Handler => $filter, RequiredFeatures => { 'http://xml.org/sax/features/validation' => 1, }); $parser->parse_string(q|<?xml version="1.0"?> <slides xmlns = "http://topicmaps.bond.edu.au/SlideML/" xmlns:in = "in" xmlns:out = "out"> <in:default/> </slides>|); print $s; __END__
The bug report got entered twice, I'm closing this one and looking into the other one. Thanks ! -- --darobin