Skip Menu | You are currently an anonymous guest. | Login | Return to Main | About rt.cpan.org
 

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.

X Report information
Id: 18491
Status: resolved
Left: 0 min
Priority: 0/0
Queue: XML-SemanticDiff

Owner: SHLOMIF <SHLOMIF [...] cpan.org>
Requestors: CLOTHO <cpan [...] clotho.com>
Cc:
AdminCc:

Severity: Important
Broken in: 0.95
Fixed in: (no value)




X History Display mode: Brief headersFull headers
#   Fri Mar 31 22:22:48 2006 CLOTHO - Ticket created  
Subject: Same tag name in different locations causes spurious change
[text/plain 669b]
Attached below are two variations of the same XML file. Both have
<Description> tags at the root level and also one level deeper, inside
the <TimeZone> tag. They should be considered identical, but this short
example program erroneously reports that they are different.

use XML::SemanticDiff;
my $diff = XML::SemanticDiff->new();
foreach my $change ($diff->compare('derived.xml', 'orig.xml')) {
print "$change->{message}\n";
}

% perl compare.pl
Child element 'Description' missing from element
'/LocalPresentationManifest[1]/Properties[1]/TimeZone[1]'.
Rogue element 'Description' in element
'/LocalPresentationManifest[1]/Properties[1]/TimeZone[1]'.


Subject: derived.xml

[text/xml 479b]
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<LocalPresentationManifest>
<Properties>
<TimeZone>
<Description>(GMT-06:00) Central Time (US &amp; Canada)</Description>
<Abbreviation>CST</Abbreviation>
<Identifier>19</Identifier>
<Name>Central Time</Name>
</TimeZone>
<Description>This presentation is a brief overview of the MediaLandscape Product and Serivce Offerings.</Description>
</Properties>
</LocalPresentationManifest>


Subject: orig.xml

[text/xml 532b]
<LocalPresentationManifest xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Properties>
<Description>This presentation is a brief overview of the MediaLandscape Product and Serivce Offerings.</Description>
<TimeZone>
<Identifier>19</Identifier>
<Name>Central Time</Name>
<Description>(GMT-06:00) Central Time (US &amp; Canada)</Description>
<Abbreviation>CST</Abbreviation>
</TimeZone>
</Properties>
</LocalPresentationManifest>

#   Fri Mar 31 22:56:00 2006 CLOTHO - Correspondence added  
Subject: [PATCH] Same tag name in different locations causes spurious change
[text/plain 1.6k]
I've looked at the code a little more deeply, and have created a patch
that fixes the problem. The following diagnostic shows where the error
comes from:

use XML::SemanticDiff;
use Data::Dumper;
my $diff = XML::SemanticDiff->new();
for my $file ('derived.xml', 'orig.xml') {
print "$file\n";
print " $_\n" for keys %{$diff->read_xml($file)};
}

% perl showdoc.pl
derived.xml
/LocalPresentationManifest[1]
/LocalPresentationManifest[1]/Properties[1]/TimeZone[1]
/LocalPresentationManifest[1]/Properties[1]/TimeZone[1]/Description[1]
/LocalPresentationManifest[1]/Properties[1]/TimeZone[1]/Identifier[1]
/LocalPresentationManifest[1]/Properties[1]/TimeZone[1]/Abbreviation[1]
/LocalPresentationManifest[1]/Properties[1]/Description[1]
/LocalPresentationManifest[1]/Properties[1]/TimeZone[1]/Name[1]
/LocalPresentationManifest[1]/Properties[1]
orig.xml
/LocalPresentationManifest[1]
/LocalPresentationManifest[1]/Properties[1]/TimeZone[1]
/LocalPresentationManifest[1]/Properties[1]/TimeZone[1]/Description[2]
/LocalPresentationManifest[1]/Properties[1]/TimeZone[1]/Abbreviation[1]
/LocalPresentationManifest[1]/Properties[1]/TimeZone[1]/Identifier[1]
/LocalPresentationManifest[1]/Properties[1]/TimeZone[1]/Name[1]
/LocalPresentationManifest[1]/Properties[1]/Description[1]
/LocalPresentationManifest[1]/Properties[1]



The key information is the "Description[2]" from orig.xml. It seems
that the $position_index hash is erroneously only looking at the tag
name, not the xpath, when incrementing. The attached path uses the full
xpath as the key to $position_index.

-- Chris


[application/octet-stream 1.6k]
Message body not shown because it is too large or is not plain text.
#   Fri Mar 31 22:56:03 2006 CLOTHO - Status changed from 'new' to 'open'  
#   Mon Jul 02 06:22:41 2007 SHLOMIF - Correspondence added  
[text/plain 2.5k]
On Sat Apr 01 01:56:00 2006, CLOTHO wrote:
> I've looked at the code a little more deeply, and have created a
patch
> that fixes the problem. The following diagnostic shows where the
error
> comes from:
>
> use XML::SemanticDiff;
> use Data::Dumper;
> my $diff = XML::SemanticDiff->new();
> for my $file ('derived.xml', 'orig.xml') {
> print "$file\n";
> print " $_\n" for keys %{$diff->read_xml($file)};
> }
>
> % perl showdoc.pl
> derived.xml
> /LocalPresentationManifest[1]
> /LocalPresentationManifest[1]/Properties[1]/TimeZone[1]
> /LocalPresentationManifest[1]/Properties[1]/TimeZone[1]/Description[1]
> /LocalPresentationManifest[1]/Properties[1]/TimeZone[1]/Identifier[1]
> /LocalPresentationManifest[1]/Properties[1]/TimeZone[1]/Abbreviation[1]
> /LocalPresentationManifest[1]/Properties[1]/Description[1]
> /LocalPresentationManifest[1]/Properties[1]/TimeZone[1]/Name[1]
> /LocalPresentationManifest[1]/Properties[1]
> orig.xml
> /LocalPresentationManifest[1]
> /LocalPresentationManifest[1]/Properties[1]/TimeZone[1]
> /LocalPresentationManifest[1]/Properties[1]/TimeZone[1]/Description[2]
> /LocalPresentationManifest[1]/Properties[1]/TimeZone[1]/Abbreviation[1]
> /LocalPresentationManifest[1]/Properties[1]/TimeZone[1]/Identifier[1]
> /LocalPresentationManifest[1]/Properties[1]/TimeZone[1]/Name[1]
> /LocalPresentationManifest[1]/Properties[1]/Description[1]
> /LocalPresentationManifest[1]/Properties[1]
>
>
>
> The key information is the "Description[2]" from orig.xml. It seems
> that the $position_index hash is erroneously only looking at the tag
> name, not the xpath, when incrementing. The attached path uses the
full
> xpath as the key to $position_index.
>

Hi CLOTHO!

Thanks for your input.

I translated your example into a test file, and together with a
modified fix (as applicable to previous modifications) I applied it
into my development line of XML-SemanticDiff here :

http://svn.berlios.de/svnroot/repos/web-cpan/XML-SemanticDiff/trunk/

The changelog message reads:

<<<<<<<<<<<<<
- Applied a modified version of:
http://rt.cpan.org/Ticket/Display.html?id=18491
- Fixes a case where the same tags in different places with
identical contents, are not considered semantically identical.
- Thanks to CLOTHO for reporting it and suggesting a
fix.
- t/11tag-in-different-locations.t
>>>>>>>>>>>>>

Note that this development was not approved by the XML-SemanticDiff
originator. (who has been very unresponsive as of late).

Regards,

Shlomi Fish

#   Sun Jul 08 01:05:18 2007 SHLOMIF - Correspondence added  
[text/plain 29b]
Fixed in CPAN version - 0.96.
#   Sun Jul 08 01:05:20 2007 SHLOMIF - Status changed from 'open' to 'resolved'  
#   Sun Jul 08 01:05:21 2007 SHLOMIF - Given to SHLOMIF