[xquery-talk] RE: aggregate , grouping

fatma helmy fatmahelmy2000 at yahoo.com
Wed Dec 21 10:36:40 PST 2005


dear all
let me clarify my question since i am in bad need to
answer
i need the xquery statemnt whose input is
  <trans id=1>
   <item>
         <elem> it </elem>
   </item>
  </trans>
  <trans id=2>
     <item>
         <elem> is </elem>
    </item>
  </trans>
the oupt of the xquery i need is the following:-
trans/item count is 2
trans/item/elem/ count is 2
i dont need  the repetition of the repeated nodes . no
duplicates in node name.
what is the xquery that can do this or where can i
find xquery algebra description


--- Michael Kay <mhk at mhk.me.uk> wrote:

>  
> > Grouping is a bit convoluted in XQuery 1.0. I
> assume here 
> > that by "distinct" you mean "having distinct
> values of the 
> > @id attribute".
> > 
> > You can select the first <trans> element having
> each distinct id using
> > 
> > for $i in distinct-values(trans/@id)
> > return trans[@id=$i][1]
> > 
> > But it's not clear to me from your problem
> description what 
> > you then want to do with these elements.
> > 
> > Michael Kay
> > http://www.saxonica.com/ 
> > 
> > > -----Original Message-----
> > > From: fatma helmy
> [mailto:fatmahelmy2000 at yahoo.com] 
> > > Sent: 21 December 2005 11:46
> > > To: talk at xquery.com
> > > Subject: aggregate , grouping
> > > 
> > > Dear all
> > > suppose i have xml like
> > > <trans id=1>
> > >    <item>
> > >         <elem> it </elem>
> > >    </item>
> > > </trans>
> > > <trans id=2>
> > >    <item>
> > >         <elem> is </elem>
> > >    </item>
> > > </trans>
> > > 
> > > i need to slect distint nodes such that i can
> > > automatically get the node names which are
> <trans> ,
> > > <item> , <elem> 
> > > and also i want to keep the path they came from
> for
> > > exammple node elem is in the path trans/item/
> > > then i need aggregate function which produces
> the
> > > count of certain pathfor example . path
> item/elem  is
> > > repeated twice in trans 1 and trans 2
> > > 
> > > thanks
> > > 
> > > 
> > > 
> > >
> __________________________________________________
> > > Do You Yahoo!?
> > > Tired of spam?  Yahoo! Mail has the best spam
> protection around 
> > > http://mail.yahoo.com 
> > > 
> > 
> 
> 
> 




__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


More information about the talk mailing list