Skip Menu |

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

Report information
The Basics
Id: 51533
Status: resolved
Priority: 0/
Queue: XML-Parser

People
Owner: Nobody in particular
Requestors: triddle [...] cpan.org
Cc:
AdminCc:

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



Subject: Patch for new feature: event length
I'm implementing a module that will allow random access to the contents of XML files too big to fit into memory. I plan to scan the input file for specific element names and build byte offsets for the XML content of each of those elements. Using XML::Parser::Expat->current_byte almost allows for this but it does not leave a good way to remove markup from start events. The attached patch includes a new accessor method for XML::Parser::Expat called current_length. It wraps the XML_GetCurrentByteCount function exactly like XML_GetCurrentByteIndex does. The patch also includes changes to the documentation to reflect the new method. Thanks for maintaing this great module.
Subject: XML-Parser-2.36+current_length.patch
diff -r -u XML-Parser-2.36/Expat/Expat.pm XML-Parser/Expat/Expat.pm --- XML-Parser-2.36/Expat/Expat.pm 2007-11-20 06:24:56.000000000 -0800 +++ XML-Parser/Expat/Expat.pm 2009-11-14 13:43:15.000000000 -0800 @@ -194,6 +194,14 @@ } } +sub current_length { + my $self = shift; + + if ($self->{_State_} == 1) { + return GetCurrentByteCount($self->{Parser}); + } +} + sub base { my ($self, $newbase) = @_; my $p = $self->{Parser}; @@ -1013,6 +1021,10 @@ Returns the current position of the parse. +=item current_length + +Returns the number of bytes of markup for the current event + =item base([NEWBASE]); Returns the current value of the base for resolving relative URIs. If diff -r -u XML-Parser-2.36/Expat/Expat.xs XML-Parser/Expat/Expat.xs --- XML-Parser-2.36/Expat/Expat.xs 2007-11-16 12:24:18.000000000 -0800 +++ XML-Parser/Expat/Expat.xs 2009-11-14 12:21:18.000000000 -0800 @@ -1971,6 +1971,10 @@ long XML_GetCurrentByteIndex(parser) XML_Parser parser + +long +XML_GetCurrentByteCount(parser) + XML_Parser parser int XML_GetSpecifiedAttributeCount(parser)
Ticket migrated to github as https://github.com/toddr/XML-Parser/issues/49