# regression testing.
#
+use strict;
+use warnings;
+
use XML::DOM;
use XML::Parser;
use XML::NamespaceSupport;
-use Scalar::Util;
-package XML::Template;
my $parser = XML::DOM::Parser->new;
my $d1 = $parser->parsefile($ARGV[0]);
if ($n1->getNodeType != $n2->getNodeType) {
printf STDERR "Node types don't match (%u vs. %u)\n",
- $n1->getNodeType, $n2->getNodeType);
+ $n1->getNodeType, $n2->getNodeType;
exit(1);
}
my ($nsuri1, undef, $lname1) = $nsup1->process_element_name($n1->getNodeName);
my ($nsuri2, undef, $lname2) = $nsup2->process_element_name($n2->getNodeName);
+ $nsuri1 |= '';
+ $nsuri2 |= '';
+
# compare element names
unless ($nsuri1 eq $nsuri2 && $lname1 eq $lname2) {
print STDERR "$nsuri1/$lname1 != $nsuri2/$lname2\n";
}
sub compare_attr_list {
- my ($attrs1, $attrs2, $nsup1, $nsup2);
+ my ($attrs1, $attrs2, $nsup1, $nsup2) = @_;
for my $attr1 ($attrs1->getValues) {
- my $name = $attr->getName;
+ my $name = $attr1->getName;
next if ($name =~ /^xmlns:(.*)$/);
- my ($nsuri1, undef, $lname1) = $nsup1->process_attribute_name($n1->getName);
+ my ($nsuri1, undef, $lname1) = $nsup1->process_attribute_name($attr1->getName);
+ $nsuri1 |= '';
if (!defined($attrs2)) {
# n2 has no attributes at all
my $attr2_found;
for my $attr2 ($attrs2->getValues) {
- my ($nsuri2, undef, $lname2) = $nsup2->process_attribute_name($n2->getName);
+ next if ($attr2->getName =~ /^xmlns:(.*)$/);
+ my ($nsuri2, undef, $lname2) = $nsup2->process_attribute_name($attr2->getName);
+ $nsuri2 |= '';
if ($nsuri1 eq $nsuri2 && $lname1 eq $lname2) {
$attr2_found = $attr2;
last;
}
- if ($attr1->getValue ne $attr2->getValue) {
+ if ($attr1->getValue ne $attr2_found->getValue) {
print STDERR "Attribute $nsuri1/$lname1 has differing values\n";
}
}