From 216289180cf975ede9c66447e63b3dd5bdaf8079 Mon Sep 17 00:00:00 2001 From: "sgunderson@bigfoot.com" <> Date: Wed, 6 Sep 2006 16:04:38 +0200 Subject: [PATCH] Check the contents of text nodes when diffing. --- tests/xml-diff.pl | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/xml-diff.pl b/tests/xml-diff.pl index 970b658..22b828a 100644 --- a/tests/xml-diff.pl +++ b/tests/xml-diff.pl @@ -58,6 +58,23 @@ sub compare { compare_attr_list($attrs1, $attrs2, $nsup1, $nsup2) if (defined($attrs1)); compare_attr_list($attrs2, $attrs1, $nsup2, $nsup1) if (defined($attrs2)); + # if this is a text node, check the contents + if ($n1->getNodeType == XML::DOM::TEXT_NODE) { + my $d1 = $n1->getData; + my $d2 = $n2->getData; + + # ignore leading/trailing whitespace + $d1 =~ s/^\s+//; + $d2 =~ s/^\s+//; + $d1 =~ s/\s+$//; + $d2 =~ s/\s+$//; + + if ($d1 ne $d2) { + print STDERR "$nsuri1/$lname1 has differing textual content\n"; + exit(1); + } + } + # this element is ok, let's compare all children my $c1 = $n1->getChildNodes; my $c2 = $n2->getChildNodes; -- 2.39.2