Skip Menu |
 

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

Report information
The Basics
Id: 28921
Status: resolved
Priority: 0/
Queue: XML-LibXML

People
Owner: Nobody in particular
Requestors: hull [...] snap.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 1.63
Fixed in: (no value)



Subject: Adding XML::SAX::DocumentLocator support to XML::LibXML::SAX::Parser
Download (untitled) / with headers
text/plain 248b
The XML::LibXML::SAX::Parser module doesn't really support XML::SAX::DocumentLocator. The attached patch is my stab at adding that support. If it looks good, I hope that it will be considered for inclusion in XML::LibXML. Thanks! -- David Hull
Subject: Parser.pm.diff
Download Parser.pm.diff
text/x-diff 1.2k
--- lib/XML/LibXML/SAX/Parser.pm.orig 2007-08-20 16:25:04.000000000 -0700 +++ lib/XML/LibXML/SAX/Parser.pm 2007-08-20 16:26:31.000000000 -0700 @@ -43,6 +43,21 @@ my $self = shift; my ($node) = @_; + $self->{node_stack} = []; + my $doc = $node->ownerDocument(); + my $dtd = defined $doc ? $doc->externalSubset() : undef; + + $self->set_document_locator( + XML::SAX::DocumentLocator->new( + sub { defined $dtd ? $dtd->publicId() : undef }, + sub { defined $dtd ? $dtd->systemId() : undef }, + sub { $self->{node_stack}->[$#{$self->{node_stack}}]->line_number() }, + sub { 1 }, + sub { defined $doc ? $doc->encoding() : undef }, + sub { defined $doc ? $doc->version() : undef}, + ), + ); + if ( $node->nodeType() == XML_DOCUMENT_NODE || $node->nodeType == XML_HTML_DOCUMENT_NODE ) { $self->start_document({}); @@ -55,6 +70,8 @@ sub process_node { my ($self, $node) = @_; + push(@{$self->{node_stack}}, $node); + my $node_type = $node->nodeType(); if ($node_type == XML_COMMENT_NODE) { $self->comment( { Data => $node->getData } ); @@ -102,6 +119,8 @@ else { # warn("unsupported node type: $node_type"); } + + pop(@{$self->{node_stack}}); } sub process_element {
Download (untitled) / with headers
text/plain 240b
Thanks for the patch. I didn't like the push/pop thing so I didn't use it, but I committed something semantically equivalent to the SVN. It would be nice if you could provide some regression tests of this feature for t/14sax.t. -- Petr


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.