[xquery-talk] Returning dublicates

Howard Katz howardk at fatdog.com
Fri Jun 17 17:31:37 PDT 2005


Just to add: anybody see any way of doing this w/out rebuilding the document
from scratch? Kudos if so. I'll be happy to send the winning contestant a
barely used first edition of Michael Kay's prize-winning "XSLT: Programmer's
Reference". (Only because I've got the second on order. :-)
Howard

  _____  

From: talk-bounces at xquery.com [mailto:talk-bounces at xquery.com] On Behalf Of
Howard Katz
Sent: Friday, June 17, 2005 7:49 AM
To: 'EXTERNAL Kruse Peter (Praktikant;CR/AEF4)'; talk at xquery.com
Subject: RE: [xquery-talk] Returning dublicates 


How about this:
 
declare function local:get-distinct( $node as node()* )
{
     for $distincts in fn:distinct-values( $node )
     return $distincts
};
 
<A>
{
     let $root := doc( "test_2.xml" )/A
     for $distinct-text in local:get-distinct( $root/B )
     return 
         if ( count( $root/B[ . = $distinct-text ] ) >= 2 )
         then <B>{ $distinct-text }</B>
         else ()
}
</A>
 
Howard


  _____  

From: talk-bounces at xquery.com [mailto:talk-bounces at xquery.com] On Behalf Of
EXTERNAL Kruse Peter (Praktikant;CR/AEF4)
Sent: Friday, June 17, 2005 6:46 AM
To: talk at xquery.com
Subject: [xquery-talk] Returning dublicates 



Hi list, 
You are always a very big help for me, so i feel free to ask more questions.


I have an XML tree (of course) and want to find those nodes with certain
properties, which exists twice (or more). 

So i have 
<A> 
        <B>mary</B> 
        <B>tom</B> 
        <B>bob</B> 
        <B>mary</B> 
        <B>bob</B> 
</A> 

And i'd like to have a result like 
<A> 
        <B>mary</B> 
        <B>bob</B> 
</A> 

Note: <B>tom</B> is not included in the result, because there is only one
occurance of <B>tom</B> 

Thank you all for your patients and have a nice weekend 

Mit freundlichen Grüßen, Best Regards 
        Peter 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://xquery.com/pipermail/talk/attachments/20050617/f5a6f7d1/attachment.htm


More information about the talk mailing list