ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> perl-xml
perl-xml
Re: is there a way to check if one xml document is contained in another?
by Yishay Weiss other posts by this author
Sep 12 2005 3:33AM messages near this date
view in the new Beta List Site
Re: is there a way to check if one xml document is contained in another? | Re: is there a way to check if one xml document is contained in another?
& XSLT Thanks for the reply but I'm afraid that only solves part of the problem. If 
you look at the output you'll see there's one message such as:

>  > Rogue element 'b' in element '/a[1]'. in context /a[1]

But the rest are:

>  > Attribute 'name' has different value in element 'b'. in context 
> /a[1]/b[1]
>  > Attribute 'name' has different value in element 'b'. in context 
> /a[1]/b[2]
>  > Attribute 'name' has different value in element 'b'. in context 
> /a[1]/b[3]

which your grep would not filter out. To generalize the problem semanticdiff 
compares src and dst elements according to their corresponding xpath's. This 
is good when there's an indentical number of elements in src and in dst, but 
it doesn't work in my case where the number of elements in src is less than 
the number in dst. I only want to see if the src elements are contained in 
dst elements. Your solution would have been good if I could guarantee that 
the first elements in src document correspond to the first in dst. But as my 
example demonstrates this is not always the case.

Yishay

> From: David Nicol <davidnicol@[...].com>
> Reply-To: rapnap@[...].com
> To: Yishay Weiss <yishayjobs@[...].com>
> CC: perl-xml@[...].com
> Subject: Re: is there a way to check if one xml document is contained in 
> another?
> Date: Tue, 6 Sep 2005 16:06:35 -0500
> 
> On 9/5/05, Yishay Weiss <yishayjobs@[...].com> wrote:
> 
>  > my $diff = XML::SemanticDiff->new();
>  >
>  > foreach my $change ($diff->compare($src, $dst)) {
>  >     print "$change->{message} in context $change->{context}\n";
>  > }
>  >
>  > output:
>  > Attribute 'name' has different value in element 'b'. in context 
> /a[1]/b[1]
>  > Attribute 'name' has different value in element 'b'. in context 
> /a[1]/b[2]
>  > Attribute 'name' has different value in element 'b'. in context 
> /a[1]/b[3]
>  > Rogue element 'b' in element '/a[1]'. in context /a[1]
>  >
>  > =======
>  >
>  >
>  > All messages except the last I'd like to disregard programatically. Has
>  > anyone done this? Any ideas?
> 
> Well, there's running the output through `grep -v` or its perl equivalent 
> of
> something like
> 
>   foreach my $change ($diff->compare($src, $dst)) {
>       $change->{message} =~ /^Rogue/ or next;
>       print "$change->{message} in context $change->{context}\n";
>   }
> 
> 
> 
> 
> --
> David L Nicol
> sig block blocked by internal administrative order


_______________________________________________
Perl-XML mailing list
Perl-XML@[...].com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Thread:
Yishay Weiss
David Nicol
Yishay Weiss
Vaclav Barta
Yishay Weiss

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved