[xquery-talk] Returning dublicates
philippe michiels
philippe.michiels at gmail.com
Fri Jun 17 23:28:54 PDT 2005
Hi,
In fact, it is easy to see that this is impossible. You can only
select entire nodes -- not just parts of it, in XQuery. And if you
cannot just select the node, you are forced to rebuild it, right?
--Ph
On 6/17/05, Howard Katz <howardk at fatdog.com> wrote:
>
> 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
> _______________________________________________
> talk at xquery.com
> http://xquery.com/mailman/listinfo/talk
>
>
More information about the talk
mailing list