r44434 - in /branches/upstream/libxml-parser-lite-tree-perl/current: MANIFEST META.yml README lib/XML/Parser/Lite/Tree.pm lib/XML/Parser/LiteCopy.pm t/00_xmlparserlite.t t/08_cdata.t

jawnsy-guest at users.alioth.debian.org jawnsy-guest at users.alioth.debian.org
Sun Sep 20 18:54:03 UTC 2009


Author: jawnsy-guest
Date: Sun Sep 20 18:53:57 2009
New Revision: 44434

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=44434
Log:
[svn-upgrade] Integrating new upstream version, libxml-parser-lite-tree-perl (0.12)

Added:
    branches/upstream/libxml-parser-lite-tree-perl/current/t/00_xmlparserlite.t
    branches/upstream/libxml-parser-lite-tree-perl/current/t/08_cdata.t
Modified:
    branches/upstream/libxml-parser-lite-tree-perl/current/MANIFEST
    branches/upstream/libxml-parser-lite-tree-perl/current/META.yml
    branches/upstream/libxml-parser-lite-tree-perl/current/README
    branches/upstream/libxml-parser-lite-tree-perl/current/lib/XML/Parser/Lite/Tree.pm
    branches/upstream/libxml-parser-lite-tree-perl/current/lib/XML/Parser/LiteCopy.pm

Modified: branches/upstream/libxml-parser-lite-tree-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libxml-parser-lite-tree-perl/current/MANIFEST?rev=44434&op=diff
==============================================================================
--- branches/upstream/libxml-parser-lite-tree-perl/current/MANIFEST (original)
+++ branches/upstream/libxml-parser-lite-tree-perl/current/MANIFEST Sun Sep 20 18:53:57 2009
@@ -1,6 +1,7 @@
 Makefile.PL
 MANIFEST
 README
+t/00_xmlparserlite.t
 t/01_basic.t
 t/02_options.t
 t/03_comments.t
@@ -8,6 +9,7 @@
 t/05_doctypes.t
 t/06_attributes.t
 t/07_stack.t
+t/08_cdata.t
 lib/XML/Parser/LiteCopy.pm
 lib/XML/Parser/Lite/Tree.pm
 META.yml                                 Module meta-data (added by MakeMaker)

Modified: branches/upstream/libxml-parser-lite-tree-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libxml-parser-lite-tree-perl/current/META.yml?rev=44434&op=diff
==============================================================================
--- branches/upstream/libxml-parser-lite-tree-perl/current/META.yml (original)
+++ branches/upstream/libxml-parser-lite-tree-perl/current/META.yml Sun Sep 20 18:53:57 2009
@@ -1,7 +1,7 @@
 # http://module-build.sourceforge.net/META-spec.html
 #XXXXXXX This is a prototype!!!  It will change in the future!!! XXXXX#
 name:         XML-Parser-Lite-Tree
-version:      0.11
+version:      0.12
 version_from: lib/XML/Parser/Lite/Tree.pm
 installdirs:  site
 requires:

Modified: branches/upstream/libxml-parser-lite-tree-perl/current/README
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libxml-parser-lite-tree-perl/current/README?rev=44434&op=diff
==============================================================================
--- branches/upstream/libxml-parser-lite-tree-perl/current/README (original)
+++ branches/upstream/libxml-parser-lite-tree-perl/current/README Sun Sep 20 18:53:57 2009
@@ -29,5 +29,6 @@
 Contains XML::Parser::Lite:
 Copyright (C) 2000-2007 Paul Kulchenko <paulclinger at yahoo.com>
 Copyright (C) 2008 Martin Kutter <martin.kutter at fen-net.de>
+Copyright (C) 2009 Cal Henderson <cal at iamcal.com>
 SOAP::Lite is free software; you can redistribute it
 and/or modify it under the same terms as Perl itself.

Modified: branches/upstream/libxml-parser-lite-tree-perl/current/lib/XML/Parser/Lite/Tree.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libxml-parser-lite-tree-perl/current/lib/XML/Parser/Lite/Tree.pm?rev=44434&op=diff
==============================================================================
--- branches/upstream/libxml-parser-lite-tree-perl/current/lib/XML/Parser/Lite/Tree.pm (original)
+++ branches/upstream/libxml-parser-lite-tree-perl/current/lib/XML/Parser/Lite/Tree.pm Sun Sep 20 18:53:57 2009
@@ -5,7 +5,7 @@
 use warnings;
 use XML::Parser::LiteCopy;
 
-our $VERSION = '0.11';
+our $VERSION = '0.12';
 
 use vars qw( $parser );
 
@@ -25,9 +25,10 @@
 		Handlers => {
 			Start	=> sub { $self->_start_tag(@_); },
 			Char	=> sub { $self->_do_char(@_); },
+			CData	=> sub { $self->_do_cdata(@_); },
 			End	=> sub { $self->_end_tag(@_); },
 			Comment	=> sub { $self->_do_comment(@_); },
-			XMLDecl	=> sub { $self->_do_xmldecl(@_); },
+			PI	=> sub { $self->_do_pi(@_); },
 			Doctype	=> sub { $self->_do_doctype(@_); },
 		};
 	$self->{process_ns} = $self->{opts}->{process_ns} || 0;
@@ -99,6 +100,22 @@
 	1;
 }
 
+sub _do_cdata {
+	my $self = shift;
+	shift;
+
+	for my $content(@_){
+
+		my $new_tag = {
+			'type' => 'cdata',
+			'content' => $content,
+		};
+
+		push @{$self->{tag_stack}->[-1]->{children}}, $new_tag;
+	}
+	1;
+}
+
 sub _end_tag {
 	my $self = shift;
 
@@ -122,7 +139,7 @@
 	1;
 }
 
-sub _do_xmldecl {
+sub _do_pi {
 	my $self = shift;
 	shift;
 
@@ -271,12 +288,9 @@
 
 	if ($obj->{type} eq 'pi'){
 
-		if ($obj->{content} =~ m/^(\S+)\s+(.*)\?$/s){
-
-			delete $obj->{content};
-			$obj->{target} = $1;
-			$obj->{content} = $2;
-		}
+		my ($x, $y) = split /\s+/, $obj->{content}, 2;
+		$obj->{target} = $x;
+		$obj->{content} = $y;
 	}
 
 
@@ -286,12 +300,9 @@
 
 	if ($obj->{type} eq 'dtd'){
 
-		if ($obj->{content} =~ m/^(\S+)\s+(.*)$/s){
-
-			delete $obj->{content};
-			$obj->{name} = $1;
-			$obj->{content} = $2;
-		}
+		my ($x, $y) = split /\s+/, $obj->{content}, 2;
+		$obj->{name} = $x;
+		$obj->{content} = $y;
 	}
 
 

Modified: branches/upstream/libxml-parser-lite-tree-perl/current/lib/XML/Parser/LiteCopy.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libxml-parser-lite-tree-perl/current/lib/XML/Parser/LiteCopy.pm?rev=44434&op=diff
==============================================================================
--- branches/upstream/libxml-parser-lite-tree-perl/current/lib/XML/Parser/LiteCopy.pm (original)
+++ branches/upstream/libxml-parser-lite-tree-perl/current/lib/XML/Parser/LiteCopy.pm Sun Sep 20 18:53:57 2009
@@ -1,25 +1,22 @@
-# NOTE: This module comes from SOAP::Lite, which you probably don't
-# have, so it's repackaged here to avoid the huge dependancy tree.
-# also, the current version in CPAN doesn't run under older perls
-# so i've removed the 'use version' magic. And it's been renamed
-# so that search.cpan.org doesn't whine at me
-
-# ======================================================================
+# NOTE: This module originally came from SOAP::Lite, which you probably
+# don't have. It was first repackaged here just to avoid the huge 
+# dependancy tree, but this version has several features (CDATA
+# support, better PI and Comment support) that have been added.
+
 #
 # Copyright (C) 2000-2007 Paul Kulchenko (paulclinger at yahoo.com)
 # Copyright (C) 2008 Martin Kutter (martin.kutter at fen-net.de)
+# Copyright (C) 2009 Cal Henderson (cal at iamcal.com)
+#
 # SOAP::Lite is free software; you can redistribute it
 # and/or modify it under the same terms as Perl itself.
 #
-# $Id: Lite.pm 249 2008-05-05 20:35:05Z kutterma $
-#
-# ======================================================================
 
 package XML::Parser::LiteCopy;
 
 use strict;
 use vars qw($VERSION);
-$VERSION = '0.710.05';
+$VERSION = '0.720.00';
 
 sub new {
     my $class = shift;
@@ -41,7 +38,7 @@
     no strict 'refs'; local $^W;
     # clear all handlers if called without parameters
     if (not @_) {
-        for (qw(Start End Char Final Init Comment Doctype XMLDecl)) {
+        for (qw(Start End Char Final Init CData Comment Doctype PI)) {
             *$_ = sub {}
         }
     }
@@ -69,42 +66,47 @@
     # this copyright and citation notice remains intact and that modifications
     # or additions are clearly identified.
 
-    # Modifications may be tracked on SOAP::Lite's SVN at
-    # https://soaplite.svn.sourceforge.net/svnroot/soaplite/
-    #
     use re 'eval';
     my $TextSE = "[^<]+";
-    my $UntilHyphen = "[^-]*-";
-    my $Until2Hyphens = "([^-]*)-(?:[^-]$[^-]*-)*-";
-    my $CommentCE = "$Until2Hyphens(?{${package}::comment(\$2)})>?";
-#    my $Until2Hyphens = "$UntilHyphen(?:[^-]$UntilHyphen)*-";
-#    my $CommentCE = "$Until2Hyphens>?";
+
+    # the following backrefs have been added:
+    # 1 : TextSE
+    # 2 : MarkupSPE / DeclCE / CommentCE
+    # 3 : MarkupSPE / DeclCE / CDATA_CE
+    # 4 : MarkupSPE / DeclCE / DocTypeCE
+    # 5 : MarkupSPE / PI_CE
+    # 6 : MarkupSPE / EndTagCE
+    # 7+: MarkupSPE / ElemTagCE
+
+    my $Until2Hyphens = "(?:[^-]*)-(?:[^-]+-)*-";
+    my $CommentCE = "($Until2Hyphens)(?{${package}::comment(\$2)})>?";
+
     my $UntilRSBs = "[^\\]]*](?:[^\\]]+])*]+";
-    my $CDATA_CE = "$UntilRSBs(?:[^\\]>]$UntilRSBs)*>";
+    my $CDATA_CE = "($UntilRSBs(?:[^\\]>]$UntilRSBs)*)(?{${package}::cdata(\$3)})>";
+
     my $S = "[ \\n\\t\\r]+";
     my $NameStrt = "[A-Za-z_:]|[^\\x00-\\x7F]";
     my $NameChar = "[A-Za-z0-9_:.-]|[^\\x00-\\x7F]";
     my $Name = "(?:$NameStrt)(?:$NameChar)*";
     my $QuoteSE = "\"[^\"]*\"|'[^']*'";
     my $DT_IdentSE = "$Name(?:$S(?:$Name|$QuoteSE))*";
-#    my $DT_IdentSE = "$S$Name(?:$S(?:$Name|$QuoteSE))*";
     my $MarkupDeclCE = "(?:[^\\]\"'><]+|$QuoteSE)*>";
     my $S1 = "[\\n\\r\\t ]";
-    my $UntilQMs = "[^?]*\\?";
-    my $PI_Tail = "\\?>|$S1$UntilQMs(?:[^>?]$UntilQMs)*";
+    my $UntilQMs = "[^?]*\\?+";
+
+    my $PI_Tail = "\\?|$S1$UntilQMs(?:[^>?]$UntilQMs)*";
     my $DT_ItemSE = "<(?:!(?:--$Until2Hyphens>|[^-]$MarkupDeclCE)|\\?$Name(?:$PI_Tail>))|%$Name;|$S";
-    my $DocTypeCE = "$S($DT_IdentSE(?:$S)?(?:\\[(?:$DT_ItemSE)*](?:$S)?)?)>(?{${package}::_doctype(\$3)})";
-#    my $PI_Tail = "\\?>|$S1$UntilQMs(?:[^>?]$UntilQMs)*>";
-#    my $DT_ItemSE = "<(?:!(?:--$Until2Hyphens>|[^-]$MarkupDeclCE)|\\?$Name(?:$PI_Tail))|%$Name;|$S";
-#    my $DocTypeCE = "$DT_IdentSE(?:$S)?(?:\\[(?:$DT_ItemSE)*](?:$S)?)?>?";
+    my $DocTypeCE = "$S($DT_IdentSE(?:$S)?(?:\\[(?:$DT_ItemSE)*](?:$S)?)?)>(?{${package}::_doctype(\$4)})";
+
     my $DeclCE = "--(?:$CommentCE)?|\\[CDATA\\[(?:$CDATA_CE)?|DOCTYPE(?:$DocTypeCE)?";
-#    my $PI_CE = "$Name(?:$PI_Tail)?";
-    my $PI_CE = "($Name(?:$PI_Tail))>(?{${package}::_xmldecl(\$5)})";
+
+    my $PI_CE = "($Name(?:$PI_Tail))>(?{${package}::_pi(\$5)})";
+
     # these expressions were modified for backtracking and events
-#    my $EndTagCE = "($Name)(?{${package}::_end(\$2)})(?:$S)?>";
+
     my $EndTagCE = "($Name)(?{${package}::_end(\$6)})(?:$S)?>";
     my $AttValSE = "\"([^<\"]*)\"|'([^<']*)'";
-#    my $ElemTagCE = "($Name)(?:$S($Name)(?:$S)?=(?:$S)?(?:$AttValSE)(?{[\@{\$^R||[]},\$4=>defined\$5?\$5:\$6]}))*(?:$S)?(/)?>(?{${package}::_start( \$3,\@{\$^R||[]})})(?{\${7} and ${package}::_end(\$3)})";
+
     my $ElemTagCE = "($Name)"
         . "(?:$S($Name)(?:$S)?=(?:$S)?(?:$AttValSE)"
         . "(?{[\@{\$^R||[]},\$8=>defined\$9?\$9:\$10]}))*(?:$S)?(/)?>"
@@ -193,23 +195,26 @@
 }
 
 sub comment {
-    Comment(__PACKAGE__, $_[0]);
+    Comment(__PACKAGE__, substr $_[0], 0, -2);
 }
 
 sub end {
      pop(@stack) eq $_[0] or die "mismatched tag '$_[0]'\n";
      End(__PACKAGE__, $_[0]);
- }
+}
+
+sub cdata {
+    die "CDATA outside of tag stack" unless @stack;
+    CData(__PACKAGE__, substr $_[0], 0, -2);
+}
 
 sub _doctype {
     Doctype(__PACKAGE__, $_[0]);
 }
 
-sub _xmldecl {
-    XMLDecl(__PACKAGE__, $_[0]);
-}
-
-
+sub _pi {
+    PI(__PACKAGE__, substr $_[0], 0, -1);
+}
 
 # ======================================================================
 1;
@@ -218,13 +223,13 @@
 
 =head1 NAME
 
-XML::Parser::Lite - Lightweight regexp-based XML parser
+XML::Parser::LiteCopy - Lightweight regexp-based XML parser
 
 =head1 SYNOPSIS
 
-  use XML::Parser::Lite;
-
-  $p1 = new XML::Parser::Lite;
+  use XML::Parser::LiteCopy;
+
+  $p1 = new XML::Parser::LiteCopy;
   $p1->setHandlers(
     Start => sub { shift; print "start: @_\n" },
     Char => sub { shift; print "char: @_\n" },
@@ -232,7 +237,7 @@
   );
   $p1->parse('<foo id="me">Hello World!</foo>');
 
-  $p2 = new XML::Parser::Lite
+  $p2 = new XML::Parser::LiteCopy
     Handlers => {
       Start => sub { shift; print "start: @_\n" },
       Char => sub { shift; print "char: @_\n" },
@@ -290,6 +295,10 @@
  Char
  End
  Final
+ CData
+ Doctype
+ Comment
+ PI
 
 All other handlers are ignored.
 
@@ -325,9 +334,9 @@
 
 See L<XML::Parser> for details
 
-=head2 XMLDecl
-
-See L<XML::Parser> for details
+=head2 PI
+
+See XMLDecl in L<XML::Parser> for details, but also includes other processing instructions
 
 =head2 Doctype
 
@@ -346,7 +355,9 @@
 
 Copyright (C) 2000-2007 Paul Kulchenko. All rights reserved.
 
-Copyright (C) 2008- Martin Kutter. All rights reserved.
+Copyright (C) 2008 Martin Kutter. All rights reserved.
+
+Copyright (C) 2009 Cal Henderson. All rights reserved.
 
 This library is free software; you can redistribute it and/or modify
 it under the same terms as Perl itself.
@@ -362,6 +373,8 @@
 
 Additional handlers supplied by Adam Leggett.
 
+Further modifications by Cal Henderson.
+
 =cut
 
 

Added: branches/upstream/libxml-parser-lite-tree-perl/current/t/00_xmlparserlite.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libxml-parser-lite-tree-perl/current/t/00_xmlparserlite.t?rev=44434&op=file
==============================================================================
--- branches/upstream/libxml-parser-lite-tree-perl/current/t/00_xmlparserlite.t (added)
+++ branches/upstream/libxml-parser-lite-tree-perl/current/t/00_xmlparserlite.t Sun Sep 20 18:53:57 2009
@@ -1,0 +1,178 @@
+use Test::More tests => 67;
+
+use XML::Parser::LiteCopy;
+use Data::Dumper;
+
+my($s, $c, $e, $a);
+
+
+#
+# start, char, end
+#
+
+($s, $c, $e) = (0) x 3;
+my $p1 = XML::Parser::LiteCopy->new();
+$p1->setHandlers(
+    Start => sub { $s++; },
+    Char => sub { $c++; },
+    End => sub { $e++; },
+);
+$p1->parse('<foo>Hello World!</foo>');
+
+is($s, 1);
+is($c, 1);
+is($e, 1);
+
+
+#
+# attributes from start event
+#
+
+($s, $c, $e) = (0) x 3;
+my %foo;
+my $p2 = new XML::Parser::LiteCopy
+  Handlers => {
+    Start => sub { shift; $s++; %foo = @_[1..$#_] if $_[0] eq 'foo'; },
+    Char => sub { $c++; },
+    End => sub { $e++; },
+  }
+;
+$p2->parse('<foo id="me" root="0" empty="">Hello <bar>cruel</bar> <foobar/> World!</foo>');
+is($s, 3);
+is($c, 4);
+is($e, 3);
+is($foo{id}, 'me');
+ok(defined $foo{root});
+is($foo{root}, '0');
+ok(defined $foo{empty});
+is($foo{empty}, '');
+
+
+#
+# Char & CDATA
+#
+
+sub test_chars {
+  my @chars;
+  my $p = new XML::Parser::LiteCopy
+    Handlers => {
+      Char => sub { push @chars, $_[1]; },
+      CData => sub { push @chars, 'CDATA:'.$_[1]; },
+    }
+  ;
+  my $in = shift;
+  $p->parse($in);
+  is(scalar @chars, scalar @_);
+  is_deeply(\@chars, \@_);
+}
+
+&test_chars('<foo />', ());
+&test_chars('<foo></foo>', ());
+&test_chars('<foo>hey</foo>', ('hey'));
+&test_chars('<foo>hey&lt;</foo>', ('hey&lt;'));
+&test_chars('<foo>&amp;hey</foo>', ('&amp;hey'));
+
+&test_chars('<foo><![CDATA[yo]]></foo>', ('CDATA:yo'));
+&test_chars('<foo><![CDATA[ yo ]]></foo>', ('CDATA: yo '));
+&test_chars('<foo><![CDATA[foo]bar]]></foo>', ('CDATA:foo]bar'));
+&test_chars('<foo><![CDATA[foo]]bar]]></foo>', ('CDATA:foo]]bar'));
+&test_chars('<foo><![CDATA[foo]>bar]]></foo>', ('CDATA:foo]>bar'));
+&test_chars('<foo><![CDATA[foo]]]></foo>', ('CDATA:foo]'));
+
+&test_chars('<foo>woo<![CDATA[foo]]><![CDATA[bar]]>yay</foo>', ('woo','CDATA:foo','CDATA:bar','yay'));
+
+
+#
+# comments
+#
+
+sub test_comments {
+  my @comments;
+  my $p = new XML::Parser::LiteCopy
+    Handlers => {
+      Comment => sub { push @comments, $_[1]; },
+    }
+  ;
+  my $in = shift;
+  $p->parse($in);
+  is(scalar @comments, scalar @_);
+  is_deeply(\@comments, \@_);
+}
+
+# >>> A note about comments:
+# An XML comment opens with a "<!--" delimiter and generally closes with the first subsequent
+# occurrence of the closing "-->" delimiter. An explicitly stated exception is that a double
+# hyphen is not permitted within the body of a comment. This rule ensures that unterminated
+# comments are detected if a new comment opening delimiter is encountered. There is an
+# additional restriction that comments cannot be terminated with the "--->" sequence, that is,
+# that the body of the comment cannot terminate with a hyphen
+
+&test_comments('<foo></foo>', ());
+&test_comments('<foo><!--a--></foo>', ('a'));
+&test_comments('<foo><!-- b --></foo>', (' b '));
+&test_comments('<foo><!-- c-d --></foo>', (' c-d '));
+&test_comments('<foo><!-- e- --></foo>', (' e- '));
+&test_comments('<foo><!-- - --></foo>', (' - '));
+&test_comments('<foo><!--fg--></foo><!--h-->', ('fg','h'));
+&test_comments('<foo><!--i-j--></foo>', ('i-j'));
+
+
+#
+# processing instructions (PI)
+#
+
+sub test_pi {
+  my @instructions;
+  my $p = new XML::Parser::LiteCopy
+    Handlers => {
+      PI => sub { push @instructions, $_[1]; },
+    }
+  ;
+  my $in = shift;
+  $p->parse($in);
+  is(scalar @instructions, scalar @_);
+  is_deeply(\@instructions, \@_);
+}
+
+&test_pi('<foo />', ());
+&test_pi('<?name pidata?><foo />', ('name pidata'));
+&test_pi('<?xml version="1.0"? encoding="UTF-8"?><foo/>', ('xml version="1.0"? encoding="UTF-8"'));
+&test_pi(qq|<bar><?php\nexit;\n?></bar>|, (qq|php\nexit;\n|));
+&test_pi('<?yay woo??><foo />', ('yay woo?')); # technically allowed...
+
+
+#
+# error conditions
+#
+
+$p2->setHandlers;
+
+# check for junk before
+eval { $p2->parse('foo<foo id="me">Hello World!</foo>') };
+ok($@ =~ /^junk .+ before/);
+
+# check for junk after
+eval { $p2->parse('<foo id="me">Hello World!</foo>bar') };
+ok($@ =~ /^junk .+ after/);
+
+# check for non-closed tag
+eval { $p2->parse('<foo id="me">Hello World!') };
+ok($@ =~ /^not properly closed tag 'foo'/);
+
+# check for non properly closed tag
+eval { $p2->parse('<foo id="me">Hello World!<bar></foo></bar>') };
+ok($@ =~ /^mismatched tag 'foo'/);
+
+# check for unwanted tag
+eval { $p2->parse('<foo id="me">Hello World!</foo><bar></bar>') };
+ok($@ =~ /^multiple roots, wrong element 'bar'/);
+
+# check for string without elements
+eval { $p2->parse('  ') };
+ok($@ =~ /^no element found/);
+
+# TODO tests
+# check for unclosed PI: $p2->parse('<?pi<foo></foo>');
+# check for unclosed CDATA
+# check for bad doctype
+# check for bad comments (various kinds)

Added: branches/upstream/libxml-parser-lite-tree-perl/current/t/08_cdata.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libxml-parser-lite-tree-perl/current/t/08_cdata.t?rev=44434&op=file
==============================================================================
--- branches/upstream/libxml-parser-lite-tree-perl/current/t/08_cdata.t (added)
+++ branches/upstream/libxml-parser-lite-tree-perl/current/t/08_cdata.t Sun Sep 20 18:53:57 2009
@@ -1,0 +1,34 @@
+use Test::More tests => 4;
+
+use XML::Parser::Lite::Tree;
+my $x = XML::Parser::Lite::Tree->instance();
+
+my $tree = $x->parse('<foo><![CDATA[MethodUndefined]]></foo>');
+
+is(&get_node($tree, '0')->{type}, 'element');
+is(&get_node($tree, '0')->{name}, 'foo');
+
+is(&get_node($tree, '0/0')->{type}, 'cdata');
+is(&get_node($tree, '0/0')->{content}, 'MethodUndefined');
+
+
+
+
+
+
+#
+# a super-simple xpath-like function for finding a single given child
+#
+
+sub get_node {
+	my ($tree, $path) = @_;
+	my $node = $tree;
+	if (length $path){
+		my @refs = split /\//, $path;
+		for my $ref (@refs){
+			$node = $node->{children}->[$ref];
+		}
+	}
+	return $node;
+}
+




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