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
|