XML-Compare
view release on metacpan or search on metacpan
Makefile.PL
README
dist.ini
lib/Test/XML/Compare.pm
lib/XML/Compare.pm
t/00-load.t
t/01-basic.t
t/02-attribute.t
t/03-comments.t
t/04-exceptions.t
t/05-cdata.t
t/50-load.t
t/51-basic.t
t/52-attribute.t
t/53-comments.t
t/55-cdata.t
t/pod-coverage.t
t/pod.t
lib/XML/Compare.pm view on Meta::CPAN
not ( $_->isa("XML::LibXML::Text") && ($_->data =~ /\A\s*\Z/) )
}
$node1->childNodes();
my @nodes2 = grep { (!$in) or (!exists $in->{$_->nodePath}) }
grep { (not $_->isa('XML::LibXML::Comment')) and
not ( $_->isa("XML::LibXML::Text") && ($_->data =~ /\A\s*\Z/) )
} $node2->childNodes();
# firstly, convert all CData nodes to Text Nodes
@nodes1 = _convert_cdata_to_text( @nodes1 );
@nodes2 = _convert_cdata_to_text( @nodes2 );
# append all the consecutive Text nodes
@nodes1 = _squash_text_nodes( @nodes1 );
@nodes2 = _squash_text_nodes( @nodes2 );
# check that the nodes contain the same number of children
if ( @nodes1 != @nodes2 ) {
_die $l, 'different number of child nodes: (%d, %d)', scalar @nodes1, scalar @nodes2;
}
lib/XML/Compare.pm view on Meta::CPAN
}
$nn =~ s{#text}{text()};
$self->_are_nodes_same( [@$l,$nn], $nodes1[$i], $nodes2[$i] );
}
_msg($l, '/');
return 1;
}
# takes an array of nodes and converts all the CDATASection nodes into Text nodes
sub _convert_cdata_to_text {
my @nodes = @_;
my @new;
foreach my $n ( @nodes ) {
if ( ref $n eq 'XML::LibXML::CDATASection' ) {
$n = XML::LibXML::Text->new( $n->data() );
}
push @new, $n;
}
return @new;
}
( run in 0.544 second using v1.01-cache-2.11-cpan-454fe037f31 )