Thanks Danny. But this logic will not work if my nodes changed as below.
If check node by node using 2 loops it'll be very slow (node $x and node $y are part of another big node sequence). xquery version "1.0-ml"; let $x := <List xmlns="http://www.mynamespace.com/report/1"> <item> <term1>a b c</term1> <term2>key1</term2> </item> <item> <term1>d e f</term1> <term2>key2</term2> </item> <item> <term1>g h i.</term1> <term2>key3</term2> </item> <item> <term1>j k l</term1> <term2>key4</term2> </item> <item> <term1>m n o</term1> <term2>key5</term2> </item> </List> let $y := <List xmlns="http://www.mynamespace.com/report/1"> <item> <term1>d e f</term1> <term2>key2</term2> </item> <item> <term1>a b c</term1> <term2>key1</term2> </item> <item> <term1>j k l</term1> <term2>key4</term2> </item> <item> <term1>g h i.</term1> <term2>key6</term2> </item> </List> Regards, From: [email protected] [mailto:[email protected]] On Behalf Of Danny Sokolsky Sent: Friday, July 02, 2010 4:42 PM To: General Mark Logic Developer Discussion Subject: Re: [MarkLogic Dev General] fuzzy node comparison logic You can try and do a deep-equal on the children elements and if at least ½ of them are true, then return true. Something like: xquery version "1.0-ml"; let $x := <List xmlns="http://www.mynamespace.com/report/1"> <item> <term1>a b c</term1> <term2>key1</term2> </item> <item> <term1>d e f</term1> <term2>key2</term2> </item> <item> <term1>g h i.</term1> <term2>key3</term2> </item> <item> <term1>j k l</term1> <term2>key4</term2> </item> <item> <term1>m n o</term1> <term2>key5</term2> </item> </List> let $y := <List xmlns="http://www.mynamespace.com/report/1"> <item> <term1>a b c</term1> <term2>key1</term2> </item> <item> <term1>d e f</term1> <term2>key2</term2> </item> <item> <term1>g h i.</term1> <term2>key6</term2> </item> <item> <term1>j k l</term1> <term2>key4</term2> </item> </List> let $count := fn:count($x/node()) let $tf := for $child at $i in $x/node() return if (fn:deep-equal($child, $y/element()[$i])) then 1 else 0 let $sum := fn:sum($tf) return if (($count div $sum) ge .5) then fn:true() else fn:false() -Danny From: [email protected] [mailto:[email protected]] On Behalf Of Joshi, Utsav (LNG-CON) Sent: Friday, July 02, 2010 1:25 PM To: [email protected] Subject: [MarkLogic Dev General] fuzzy node comparison logic I want to compare node like below. Deep-equal will give me true or false (for below case, it will give false) I want it to return me true if it matches more than 50% of item nodes (for below case, it is matching 3 item nodes so it should return me true) Is there any way I can do that? <List xmlns="http://www.mynamespace.com/report/1"> <item> <term1>a b c</term1> <term2>key1</term2> </item> <item> <term1>d e f</term1> <term2>key2</term2> </item> <item> <term1>g h i.</term1> <term2>key3</term2> </item> <item> <term1>j k l</term1> <term2>key4</term2> </item> <item> <term1>m n o</term1> <term2>key5</term2> </item> </List> <List xmlns="http://www.mynamespace.com/report/1"> <item> <term1>a b c</term1> <term2>key1</term2> </item> <item> <term1>d e f</term1> <term2>key2</term2> </item> <item> <term1>g h i.</term1> <term2>key6</term2> </item> <item> <term1>j k l</term1> <term2>key4</term2> </item> </List> Regards
_______________________________________________ General mailing list [email protected] http://developer.marklogic.com/mailman/listinfo/general
