r10449 - in /branches/upstream/libxml-filter-buffertext-perl: ./ current/ current/BufferText.pm current/Changes current/MANIFEST current/Makefile.PL current/README current/t/ current/t/05basic.t

vdanjean at users.alioth.debian.org vdanjean at users.alioth.debian.org
Sat Dec 1 12:27:30 UTC 2007


Author: vdanjean
Date: Sat Dec  1 12:27:29 2007
New Revision: 10449

URL: http://svn.debian.org/wsvn/?sc=1&rev=10449
Log:
[svn-inject] Installing original source of libxml-filter-buffertext-perl

Added:
    branches/upstream/libxml-filter-buffertext-perl/
    branches/upstream/libxml-filter-buffertext-perl/current/
    branches/upstream/libxml-filter-buffertext-perl/current/BufferText.pm   (with props)
    branches/upstream/libxml-filter-buffertext-perl/current/Changes   (with props)
    branches/upstream/libxml-filter-buffertext-perl/current/MANIFEST   (with props)
    branches/upstream/libxml-filter-buffertext-perl/current/Makefile.PL   (with props)
    branches/upstream/libxml-filter-buffertext-perl/current/README   (with props)
    branches/upstream/libxml-filter-buffertext-perl/current/t/
    branches/upstream/libxml-filter-buffertext-perl/current/t/05basic.t   (with props)

Added: branches/upstream/libxml-filter-buffertext-perl/current/BufferText.pm
URL: http://svn.debian.org/wsvn/branches/upstream/libxml-filter-buffertext-perl/current/BufferText.pm?rev=10449&op=file
==============================================================================
--- branches/upstream/libxml-filter-buffertext-perl/current/BufferText.pm (added)
+++ branches/upstream/libxml-filter-buffertext-perl/current/BufferText.pm Sat Dec  1 12:27:29 2007
@@ -1,0 +1,97 @@
+
+###
+# XML::Filter::BufferText - Filter to put all characters() in one event
+# Robin Berjon <robin at knowscape.com>
+# 04/07/2003 - v1.01
+# 26/11/2001 - v0.01
+###
+
+package XML::Filter::BufferText;
+use strict;
+use base qw(XML::SAX::Base);
+use vars qw($VERSION $AUTOLOAD);
+$VERSION = '1.01';
+
+#-------------------------------------------------------------------#
+# now who said SAX was complex...
+#-------------------------------------------------------------------#
+sub characters { $_[0]->{_CharBuffer} .= $_[1]->{Data};}
+
+sub AUTOLOAD {
+    my $self = shift;
+    my $data = shift;
+    my $call = $AUTOLOAD;
+    $call =~ s/^.*:://;
+    return if $call eq 'DESTROY';
+
+    if (defined $self->{_CharBuffer} and length $self->{_CharBuffer}) {
+        $self->SUPER::characters( { Data => $self->{_CharBuffer} } );
+        $self->{_CharBuffer} = '';
+    }
+    $call = 'SUPER::' . $call;
+    $self->$call($data);
+}
+#-------------------------------------------------------------------#
+
+### AUTOLOAD and inheritance don't work all that well, this is a
+### workaround for that problem.
+sub start_document;     sub end_document;           sub start_element;
+sub end_element;        sub processing_instruction; sub comment;
+sub skipped_entity;     sub ignorable_whitespace;   sub end_entity;
+sub start_entity;       sub entity_reference;
+sub start_cdata;        sub end_cdata;
+
+1;
+#,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,#
+#`,`, Documentation `,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,#
+#```````````````````````````````````````````````````````````````````#
+
+=pod
+
+=head1 NAME
+
+XML::Filter::BufferText - Filter to put all characters() in one event
+
+=head1 SYNOPSIS
+
+  my $h = SomeHandler->new;
+  my $f = XML::Filter::BufferText->new( Handler => $h );
+  my $p = SomeParser->new( Handler => $f );
+  $p->parse;
+
+=head1 DESCRIPTION
+
+This is a very simple filter. One common cause of grief (and programmer
+error) is that XML parsers aren't required to provide character events in one
+chunk. They can, but are not forced to, and most don't. This filter does the
+trivial but oft-repeated task of putting all characters into a single event.
+
+Note that this won't help you cases such as:
+
+  <foo> blah <!-- comment --> phubar </foo>
+
+In the above case, given the interleaving comment, there will be two
+C<character()> events. This may be worked around in the future if there is
+demand for it.
+
+An interesting way to use this filter, instead of telling users to use it,
+is to return it from your handler's constructor, already configured and all.
+That'll make the buffering totally transparent to them (C<XML::SAX::Writer>
+does that).
+
+=head1 AUTHOR
+
+Robin Berjon, robin at knowscape.com
+
+=head1 COPYRIGHT
+
+Copyright (c) 2001-2002 Robin Berjon. All rights reserved. This program is
+free software; you can redistribute it and/or modify it under the same
+terms as Perl itself.
+
+=head1 SEE ALSO
+
+XML::SAX::*, XML::Generator::*, XML::Handler::*, XML::Filter::*
+
+=cut
+

Propchange: branches/upstream/libxml-filter-buffertext-perl/current/BufferText.pm
------------------------------------------------------------------------------
    svn:executable = 

Added: branches/upstream/libxml-filter-buffertext-perl/current/Changes
URL: http://svn.debian.org/wsvn/branches/upstream/libxml-filter-buffertext-perl/current/Changes?rev=10449&op=file
==============================================================================
--- branches/upstream/libxml-filter-buffertext-perl/current/Changes (added)
+++ branches/upstream/libxml-filter-buffertext-perl/current/Changes Sat Dec  1 12:27:29 2007
@@ -1,0 +1,11 @@
+
+Revision history for XML::Filter::BufferText:
+
+1.01  2003-07-04 21:50
+    - fixed a long standing bug related to buffering of cdata events
+
+1.00  sun 20020706 20:37
+    - cleaned up docs
+
+0.01  sun 20020127 19:59:55
+    - original version

Propchange: branches/upstream/libxml-filter-buffertext-perl/current/Changes
------------------------------------------------------------------------------
    svn:executable = 

Added: branches/upstream/libxml-filter-buffertext-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/branches/upstream/libxml-filter-buffertext-perl/current/MANIFEST?rev=10449&op=file
==============================================================================
--- branches/upstream/libxml-filter-buffertext-perl/current/MANIFEST (added)
+++ branches/upstream/libxml-filter-buffertext-perl/current/MANIFEST Sat Dec  1 12:27:29 2007
@@ -1,0 +1,6 @@
+BufferText.pm
+Changes
+Makefile.PL
+MANIFEST
+t/05basic.t
+README

Propchange: branches/upstream/libxml-filter-buffertext-perl/current/MANIFEST
------------------------------------------------------------------------------
    svn:executable = 

Added: branches/upstream/libxml-filter-buffertext-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/branches/upstream/libxml-filter-buffertext-perl/current/Makefile.PL?rev=10449&op=file
==============================================================================
--- branches/upstream/libxml-filter-buffertext-perl/current/Makefile.PL (added)
+++ branches/upstream/libxml-filter-buffertext-perl/current/Makefile.PL Sat Dec  1 12:27:29 2007
@@ -1,0 +1,12 @@
+use ExtUtils::MakeMaker;
+WriteMakefile(
+    'NAME'		    => 'XML::Filter::BufferText',
+    'VERSION_FROM'	=> 'BufferText.pm',
+    'AUTHOR'        => 'Robin Berjon',
+    'ABSTRACT'      => 'SAX Filter to guarantee characters in one event',
+    'PREREQ_PM'		=> {
+                        XML::SAX::Base  => '1.03',
+                        Test::More      => '0.40',
+                        XML::SAX        => '0.04',
+                       },
+);

Propchange: branches/upstream/libxml-filter-buffertext-perl/current/Makefile.PL
------------------------------------------------------------------------------
    svn:executable = 

Added: branches/upstream/libxml-filter-buffertext-perl/current/README
URL: http://svn.debian.org/wsvn/branches/upstream/libxml-filter-buffertext-perl/current/README?rev=10449&op=file
==============================================================================
--- branches/upstream/libxml-filter-buffertext-perl/current/README (added)
+++ branches/upstream/libxml-filter-buffertext-perl/current/README Sat Dec  1 12:27:29 2007
@@ -1,0 +1,10 @@
+
+XML::Filter::BufferText v0.01
+=============================================================================
+
+This is a very simple filter. One common cause of grief (and programmer
+error) is that XML parsers aren't required to provide character events in one
+chunk. They can, but are not forced to, and most don't. This filter does the
+trivial but oft-repeated task of putting all characters into a single event.
+
+-- Robin Berjon <robin at knowscape.com>

Propchange: branches/upstream/libxml-filter-buffertext-perl/current/README
------------------------------------------------------------------------------
    svn:executable = 

Added: branches/upstream/libxml-filter-buffertext-perl/current/t/05basic.t
URL: http://svn.debian.org/wsvn/branches/upstream/libxml-filter-buffertext-perl/current/t/05basic.t?rev=10449&op=file
==============================================================================
--- branches/upstream/libxml-filter-buffertext-perl/current/t/05basic.t (added)
+++ branches/upstream/libxml-filter-buffertext-perl/current/t/05basic.t Sat Dec  1 12:27:29 2007
@@ -1,0 +1,41 @@
+
+###
+# XML::Filter::BufferText tests
+# Robin Berjon <robin at knowscape.com>
+# 29/01/2002 - v0.01
+###
+
+use strict;
+use Test::More tests => 4;
+BEGIN { use_ok('XML::Filter::BufferText'); }
+
+
+package TestBuffer;
+use strict;
+use vars qw( $COUNT $DATA );
+$COUNT = 0;
+$DATA  = '';
+
+sub new { return bless {}, 'TestBuffer'; }
+sub characters { $COUNT++; }
+sub comment { $DATA = $_[1]->{Data}; }
+
+package main;
+my $h = TestBuffer->new;
+my $f = XML::Filter::BufferText->new( Handler => $h );
+
+$f->start_document;
+$f->characters({ Data => 'foo1' });
+$f->characters({ Data => 'foo2' });
+$f->end_document;
+ok($TestBuffer::COUNT == 1);
+
+$TestBuffer::DATA  = '';
+$TestBuffer::COUNT = 0;
+$f->start_document;
+$f->characters({ Data => 'foo1' });
+$f->comment({ Data => 'COMMENT' });
+$f->characters({ Data => 'foo2' });
+$f->end_document;
+ok($TestBuffer::COUNT == 2);
+ok($TestBuffer::DATA  eq 'COMMENT');

Propchange: branches/upstream/libxml-filter-buffertext-perl/current/t/05basic.t
------------------------------------------------------------------------------
    svn:executable = 




More information about the Pkg-perl-cvs-commits mailing list