Hi Abishek,
You'll need a recursive approach, but the essence will likely resemble
(distantly) something like the following:
let $left := <test><a>1</a><a>2</a><b>3</b></test>
let $right := <test><a>1</a><b>3</b><a>2</a><a>2</a></test>
return
(count($left/node()) = count($right/node()))
and
(every $leftchild in $left/node()
satisfies
(some $rightchild in $right/node()
satisfies deep-equal($leftchild, $rightchild)
)
)
Kind regards,
Geert
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]] On Behalf Of
> Narayanan, Abishek (LNG-CON)
> Sent: woensdag 5 mei 2010 16:32
> To: General Mark Logic Developer Discussion
> Subject: Re: [MarkLogic Dev General] XML diff (Andrew_Redhead)
>
> Thanks Greet and David.
> By change in the sequence I meant any change in the
> sequence of siblings alone should be ignored. So if <a>
> <b>val1</b>
> <b>val2</b>
> </a>
>
> Is represented as
> <a>
> <b>val2</b>
> <b>val1</b>
> </a>
>
> I would not like to see 2 deletes and 2 inserts. I think
> that's what you meant by (I would want to know if Doc 1 is
> "A,B" and doc2 is "B,A" ).
> I feel even if it marks the above as a different we can still
> build something on top of it (maybe in java) so as to ignore
> the 2 deletes and
> 2 inserts.
> I shall dig into the XSLT algorithm and try to find on how to
> convert it to an XQuery.
>
> I am curious to know if someone built document compare
> functionality while uploading, updated version of XMLs in
> mark logic. Have most of them opted for java to do this?
>
> Thanks again.
> Abishek
>
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]] On Behalf Of
> Geert Josten
> Sent: Wednesday, May 05, 2010 2:53 AM
> To: General Mark Logic Developer Discussion
> Subject: Re: [MarkLogic Dev General] XML diff (Andrew_Redhead)
>
> > For example you quote "Any change in the sequence is to be ignored."
> > That is definitely something that I wouldnt consider "right"
> > for a general purpose tool ( I would want to know if Doc
> 1 is "A,B"
> > and doc2 is "B,A" ).
> > And is that 2 modifications or 2 deletes and 2 inserts?
>
> If the tool would optimize right, it would detect one 'move'
> (which is 1 delete + 1 insert of something identical). But it
> takes a lot of brute force to optimize all such identified changes.
>
> > I've used various XML Diffs in various tools and libraries and was
> > never quite happy with any of them.
> >
> > But OTOH, having a public domain algorithm implemented in
> pure XQuery
> > would be *awesome*.
>
> I guess pretty much every XML Editor has it's own XML Diff
> feature somewhere. The Arbortext Editor had one that could be
> used separately from commandline, which worked well enough
> for our purposes. It was called aptdiff, not sure it is still
> available..
>
> There is also a more straight-forward algorithm that I used
> for doing deep-equals in XSLT 1. It should be fairly easy to
> convert it to XQuery.
> It is not a very smart algorithm, so A,B versus B,A would be
> seen as a diff between first child and the second child. You
> can find it here:
> http://xsltunit.org/xsltunit.xsl
>
> Kind regards,
> Geert
>
>
> drs. G.P.H. (Geert) Josten
> Consultant
>
>
> Daidalos BV
> Hoekeindsehof 1-4
> 2665 JZ Bleiswijk
>
> T +31 (0)10 850 1200
> F +31 (0)10 850 1199
>
> mailto:[email protected]
> http://www.daidalos.nl/
>
> KvK 27164984
>
> P Please consider the environment before printing this mail.
> De informatie - verzonden in of met dit e-mailbericht - is
> afkomstig van Daidalos BV en is uitsluitend bestemd voor de
> geadresseerde. Indien u dit bericht onbedoeld hebt ontvangen,
> verzoeken wij u het te verwijderen. Aan dit bericht kunnen
> geen rechten worden ontleend.
>
> _______________________________________________
> General mailing list
> [email protected]
> http://developer.marklogic.com/mailman/listinfo/general
> _______________________________________________
> General mailing list
> [email protected]
> http://developer.marklogic.com/mailman/listinfo/general
>
_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general