Accepting request 53033 from home:jnweiger:perl

tested ok, mine

OBS-URL: https://build.opensuse.org/request/show/53033
OBS-URL: https://build.opensuse.org/package/show/devel:languages:perl/perl-XML-TreeBuilder?expand=0&rev=1
This commit is contained in:
Juergen Weigert
2010-11-15 13:43:38 +00:00
committed by Git OBS Bridge
commit 6de0f3cb19
6 changed files with 394 additions and 0 deletions

23
.gitattributes vendored Normal file
View File

@@ -0,0 +1,23 @@
## Default LFS
*.7z filter=lfs diff=lfs merge=lfs -text
*.bsp filter=lfs diff=lfs merge=lfs -text
*.bz2 filter=lfs diff=lfs merge=lfs -text
*.gem filter=lfs diff=lfs merge=lfs -text
*.gz filter=lfs diff=lfs merge=lfs -text
*.jar filter=lfs diff=lfs merge=lfs -text
*.lz filter=lfs diff=lfs merge=lfs -text
*.lzma filter=lfs diff=lfs merge=lfs -text
*.obscpio filter=lfs diff=lfs merge=lfs -text
*.oxt filter=lfs diff=lfs merge=lfs -text
*.pdf filter=lfs diff=lfs merge=lfs -text
*.png filter=lfs diff=lfs merge=lfs -text
*.rpm filter=lfs diff=lfs merge=lfs -text
*.tbz filter=lfs diff=lfs merge=lfs -text
*.tbz2 filter=lfs diff=lfs merge=lfs -text
*.tgz filter=lfs diff=lfs merge=lfs -text
*.ttf filter=lfs diff=lfs merge=lfs -text
*.txz filter=lfs diff=lfs merge=lfs -text
*.whl filter=lfs diff=lfs merge=lfs -text
*.xz filter=lfs diff=lfs merge=lfs -text
*.zip filter=lfs diff=lfs merge=lfs -text
*.zst filter=lfs diff=lfs merge=lfs -text

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
.osc

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:41c9e44c2ceb745b97a5f2c9a225fd51ed309e65f234b27a719ef83ec7a15f11
size 6440

View File

@@ -0,0 +1,275 @@
---
Changes | 7 ++
lib/XML/TreeBuilder.pm | 116 +++++++++++++++++++++++++++++++++----------------
t/10main.t | 26 +++++++++-
3 files changed, 108 insertions(+), 41 deletions(-)
Index: XML-TreeBuilder-3.09/Changes
===================================================================
--- XML-TreeBuilder-3.09.orig/Changes
+++ XML-TreeBuilder-3.09/Changes
@@ -1,5 +1,10 @@
-# Time-stamp: "2004-06-10 20:28:41 ADT"
+2009-16-03 Jeff Fearn <jfearn@redhat.com>
+ Release 3.09.x
+
+ Added NoExpand option to allow entities to be left untouched in xml.
+ Added ErrorContext option to allow better reporting of error locations.
+ Expanded tests to test these options.
2004-06-10 Sean M. Burke <sburke@cpan.org>
Index: XML-TreeBuilder-3.09/lib/XML/TreeBuilder.pm
===================================================================
--- XML-TreeBuilder-3.09.orig/lib/XML/TreeBuilder.pm
+++ XML-TreeBuilder-3.09/lib/XML/TreeBuilder.pm
@@ -5,6 +5,7 @@ package XML::TreeBuilder;
use strict;
use XML::Element ();
use XML::Parser ();
+use Carp;
use vars qw(@ISA $VERSION);
$VERSION = '3.09';
@@ -12,8 +13,15 @@ $VERSION = '3.09';
#==========================================================================
sub new {
- my $class = ref($_[0]) || $_[0];
- # that's the only parameter it knows
+ my ( $this, $arg ) = @_;
+ my $class = ref($this) || $this;
+
+ my $NoExpand = ( delete $arg->{'NoExpand'} || undef );
+ my $ErrorContext = ( delete $arg->{'ErrorContext'} || undef );
+
+ if ( %{$arg} ) {
+ croak "unknown args: " . join( ", ", keys %{$arg} );
+ }
my $self = XML::Element->new('NIL');
bless $self, $class; # and rebless
@@ -21,57 +29,76 @@ sub new {
$self->{'_store_comments'} = 0;
$self->{'_store_pis'} = 0;
$self->{'_store_declarations'} = 0;
+ $self->{'NoExpand'} = $NoExpand if ($NoExpand);
+ $self->{'ErrorContext'} = $ErrorContext if ($ErrorContext);
my @stack;
+
# Compare the simplicity of this to the sheer nastiness of HTML::TreeBuilder!
- $self->{'_xml_parser'} = XML::Parser->new( 'Handlers' => {
+ $self->{'_xml_parser'} = XML::Parser->new(
+ 'Handlers' => {
+ 'Default' => sub {
+ if ( ( $self->{'NoExpand'} ) && ( $_[1] =~ /&.*\;/ ) ) {
+ $stack[-1]->push_content( $_[1] );
+ }
+ return;
+ },
'Start' => sub {
shift;
- if(@stack) {
+ if (@stack) {
push @stack, $self->{'_element_class'}->new(@_);
$stack[-2]->push_content( $stack[-1] );
- } else {
+ }
+ else {
$self->tag(shift);
- while(@_) { $self->attr(splice(@_,0,2)) };
+ while (@_) { $self->attr( splice( @_, 0, 2 ) ) }
push @stack, $self;
}
},
'End' => sub { pop @stack; return },
- 'Char' => sub { $stack[-1]->push_content($_[1]) },
+ 'Char' => sub { $stack[-1]->push_content( $_[1] ) },
'Comment' => sub {
return unless $self->{'_store_comments'};
- (
- @stack ? $stack[-1] : $self
- )->push_content(
- $self->{'_element_class'}->new('~comment', 'text' => $_[1])
- );
+ ( @stack ? $stack[-1] : $self )
+ ->push_content( $self->{'_element_class'}
+ ->new( '~comment', 'text' => $_[1] ) );
return;
},
'Proc' => sub {
return unless $self->{'_store_pis'};
- (
- @stack ? $stack[-1] : $self
- )->push_content(
- $self->{'_element_class'}->new('~pi', 'text' => "$_[1] $_[2]")
- );
+ ( @stack ? $stack[-1] : $self )
+ ->push_content( $self->{'_element_class'}
+ ->new( '~pi', 'text' => "$_[1] $_[2]" ) );
return;
},
+ 'Final' => sub {
+ $self->root()->traverse(
+ sub {
+ my ( $node, $start ) = @_;
+ if ( ref $node ) { # it's an element
+ $node->attr( 'NoExpand', undef );
+ $node->attr( 'ErrorContext', undef );
+ }
+ }
+ );
+ },
+
# And now, declarations:
'Attlist' => sub {
return unless $self->{'_store_declarations'};
shift;
- (
- @stack ? $stack[-1] : $self
- )->push_content(
- $self->{'_element_class'}->new('~declaration',
- 'text' => join ' ', 'ATTLIST', @_
+ ( @stack ? $stack[-1] : $self )->push_content(
+ $self->{'_element_class'}->new(
+ '~declaration',
+ 'text' => join ' ',
+ 'ATTLIST', @_
)
);
return;
@@ -80,11 +107,11 @@ sub new {
'Element' => sub {
return unless $self->{'_store_declarations'};
shift;
- (
- @stack ? $stack[-1] : $self
- )->push_content(
- $self->{'_element_class'}->new('~declaration',
- 'text' => join ' ', 'ELEMENT', @_
+ ( @stack ? $stack[-1] : $self )->push_content(
+ $self->{'_element_class'}->new(
+ '~declaration',
+ 'text' => join ' ',
+ 'ELEMENT', @_
)
);
return;
@@ -93,32 +120,47 @@ sub new {
'Doctype' => sub {
return unless $self->{'_store_declarations'};
shift;
- (
- @stack ? $stack[-1] : $self
- )->push_content(
- $self->{'_element_class'}->new('~declaration',
- 'text' => join ' ', 'DOCTYPE', @_
+ ( @stack ? $stack[-1] : $self )->push_content(
+ $self->{'_element_class'}->new(
+ '~declaration',
+ 'text' => join ' ',
+ 'DOCTYPE', @_
)
);
return;
},
- });
+ 'Entity' => sub {
+ return unless $self->{'_store_declarations'};
+ shift;
+ ( @stack ? $stack[-1] : $self )->push_content(
+ $self->{'_element_class'}->new(
+ '~declaration',
+ 'text' => join ' ',
+ 'ENTITY', @_
+ )
+ );
+ return;
+ },
+ },
+ 'NoExpand' => $self->{'NoExpand'},
+ 'ErrorContext' => $self->{'ErrorContext'}
+ );
return $self;
}
#==========================================================================
sub _elem # universal accessor...
{
- my($self, $elem, $val) = @_;
+ my ( $self, $elem, $val ) = @_;
my $old = $self->{$elem};
$self->{$elem} = $val if defined $val;
return $old;
}
-sub store_comments { shift->_elem('_store_comments', @_); }
-sub store_declarations { shift->_elem('_store_declarations', @_); }
-sub store_pis { shift->_elem('_store_pis', @_); }
+sub store_comments { shift->_elem( '_store_comments', @_ ); }
+sub store_declarations { shift->_elem( '_store_declarations', @_ ); }
+sub store_pis { shift->_elem( '_store_pis', @_ ); }
#==========================================================================
Index: XML-TreeBuilder-3.09/t/10main.t
===================================================================
--- XML-TreeBuilder-3.09.orig/t/10main.t
+++ XML-TreeBuilder-3.09/t/10main.t
@@ -2,7 +2,7 @@
# Time-stamp: "2004-06-10 20:22:53 ADT"
use Test;
-BEGIN { plan tests => 3 }
+BEGIN { plan tests => 4 }
use XML::TreeBuilder;
@@ -29,8 +29,7 @@ my $y = XML::Element->new_from_lol(
]
);
-
-ok $x->same_as($y);
+ok($x->same_as($y));
unless( $ENV{'HARNESS_ACTIVE'} ) {
$x->dump;
@@ -45,6 +44,27 @@ unless( $ENV{'HARNESS_ACTIVE'} ) {
$x->delete;
$y->delete;
+$x = XML::TreeBuilder->new({ 'NoExpand' => "1", 'ErrorContext' => "2" });
+$x->store_comments(1);
+$x->store_pis(1);
+$x->store_declarations(1);
+$x->parse(
+ qq{<!-- myorp --><Gee><foo Id="me" xml:foo="lal">Hello World</foo>} .
+ qq{<lor/><!-- foo --></Gee><!-- glarg -->}
+);
+
+$y = XML::Element->new_from_lol(
+ ['Gee',
+ ['~comment', {'text' => ' myorp '}],
+ ['foo', {'Id'=> 'me', 'xml:foo' => 'lal'}, 'Hello World'],
+ ['lor'],
+ ['~comment', {'text' => ' foo '}],
+ ['~comment', {'text' => ' glarg '}],
+ ]
+);
+
+ok($x->same_as($y));
+
ok 1;
print "# Bye from ", __FILE__, "\n";

View File

@@ -0,0 +1,13 @@
-------------------------------------------------------------------
Sun Nov 14 22:43:18 UTC 2010 - jw@novell.com
- added XML-TreeBuilder-NoExpand.patch from
http://rt.cpan.org/Public/Bug/Display.html?id=50060
-------------------------------------------------------------------
Fri Nov 12 23:18:07 UTC 2010 - jw@novell.com
- needed by publican
- initial package 3.09
* created by cpanspec 1.78.02

79
perl-XML-TreeBuilder.spec Normal file
View File

@@ -0,0 +1,79 @@
#
# spec file for package perl-XML-TreeBuilder (Version 3.09)
#
# Copyright (c) 2010 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via http://bugs.opensuse.org/
#
# norootforbuild
Name: perl-XML-TreeBuilder
%define cpan_name XML-TreeBuilder
Summary: Parser that builds a tree of XML::Element objects
Version: 3.09
Release: 1
License: CHECK(GPL+ or Artistic)
Group: Development/Libraries/Perl
Url: http://search.cpan.org/dist/XML-TreeBuilder/
Source: http://www.cpan.org/authors/id/S/SB/SBURKE/XML-TreeBuilder-%{version}.tar.bz2
Patch1: XML-TreeBuilder-NoExpand.patch
BuildArch: noarch
BuildRoot: %{_tmppath}/%{name}-%{version}-build
BuildRequires: perl
%if 0%{?suse_version} < 1120
BuildRequires: perl-macros
%endif
BuildRequires: perl(HTML::Element) >= 3.08
BuildRequires: perl(HTML::Tagset) >= 3.02
BuildRequires: perl(XML::Parser)
Requires: perl = %{perl_version}
Requires: perl(HTML::Element) >= 3.08
Requires: perl(HTML::Tagset) >= 3.02
Requires: perl(XML::Parser)
%description
This module uses XML::Parser to make XML document trees constructed of
XML::Element objects (and XML::Element is a subclass of HTML::Element
adapted for XML). XML::TreeBuilder is meant particularly for people who
are used to the HTML::TreeBuilder / HTML::Element interface to document
trees, and who don't want to learn some other document interface like
XML::Twig or XML::DOM.
%prep
%setup -q -n %{cpan_name}-%{version}
%patch1 -p1
%build
%{__perl} Makefile.PL INSTALLDIRS=vendor
%{__make} %{?_smp_mflags}
%check
%{__make} test
%install
%perl_make_install
# do not perl_process_packlist (noarch)
# remove .packlist file
%{__rm} -rf $RPM_BUILD_ROOT%perl_vendorarch
# remove perllocal.pod file
%{__rm} -rf $RPM_BUILD_ROOT%perl_archlib
%perl_gen_filelist
%clean
%{__rm} -rf $RPM_BUILD_ROOT
%files -f %{name}.files
%defattr(-,root,root,-)
%doc Changes README
%changelog