[xquery-talk] Returning dublicates
Howard Katz
howardk at fatdog.com
Fri Jun 17 08:48:39 PDT 2005
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/d81636ff/attachment.htm
More information about the talk
mailing list