[MarkLogic Dev General] XQuery help to COUNT multiple node

Geert Josten Geert.Josten at daidalos.nl
Wed Apr 1 04:20:19 PST 2009


Hi Deepak,

Though I guess there are ways to test whether a certain element exists within a parent using cts function, it certainly doesn't provide features to count occurences of a child within a particular parent. To gather these parents or its children, you will still need an xpath expression of some kind.

I guess that a call to xdmp:unpath, xdmp:value, or xdmp:eval is your best bet. This does require additional privileges. You can find the description of all three of these function on this page: http://developer.marklogic.com/pubs/4.0/apidocs/Extension.html

You could also resort to something like: //*[local-name() = 'BB'][count(*[local-name() = 'zz']) > 2] but that must be a performance killer..

Kind regards,
Geert

>


Drs. G.P.H. Josten
Consultant


http://www.daidalos.nl/
Daidalos BV
Source of Innovation
Hoekeindsehof 1-4
2665 JZ Bleiswijk
Tel.: +31 (0) 10 850 1200
Fax: +31 (0) 10 850 1199
http://www.daidalos.nl/
KvK 27164984
De informatie - verzonden in of met dit emailbericht - is afkomstig van Daidalos BV en is uitsluitend bestemd voor de geadresseerde. Indien u dit bericht onbedoeld hebt ontvangen, verzoeken wij u het te verwijderen. Aan dit bericht kunnen geen rechten worden ontleend.


> From: general-bounces at developer.marklogic.com
> [mailto:general-bounces at developer.marklogic.com] On Behalf Of
> deepak mohan
> Sent: woensdag 1 april 2009 13:52
> To: General Mark Logic Developer Discussion
> Subject: Re: [MarkLogic Dev General] XQuery help to COUNT
> multiple node
>
>
> I cannot use the xpath anywhere, because the element will be
> selected randomly....
> depending upon the selected root element within which the
> multiple occurence of desired will be found out...
>
> thanks for your response....
>
>
>
> --- On Wed, 1/4/09, Vyacheslav Sedov
> <vyacheslav.sedov at gmail.com> wrote:
>
>
>
>       From: Vyacheslav Sedov <vyacheslav.sedov at gmail.com>
>       Subject: Re: [MarkLogic Dev General] XQuery help to
> COUNT multiple node
>       To: "General Mark Logic Developer Discussion"
> <general at developer.marklogic.com>
>       Date: Wednesday, 1 April, 2009, 5:01 PM
>
>
>       try $n/zz[3] instead count(..)
>
>       With best wishes,
>       Slav
>
>       On Wed, Apr 1, 2009 at 3:05 PM, deepak mohan
> <dpk_bio007 at yahoo.co.in> wrote:
>       > Hi Friends,
>       >
>       >     I want to select the node which has the a desired
> node(<zz>) exists more
>       > than 2.
>       >
>       > The xml structure goes like this:
>       > <AA>
>       >     <BB>
>       >           <zz></zz>
>       >           <zz></zz>
>       >           <zz></zz>
>       >     </BB>
>       >     <BB>
>       >           <zz></zz>
>       >      </BB>
>       > </AA>
>       >
>       > My expected results should be <BB>...</BB>.. (in this case...)
>       >
>       > I tried with,
>       > for $n in //AA/BB
>       > where count($n/zz) > 2
>       > return $n
>       >
>       > But the element will be chosen dynamically...
>       > Solution using implicit function (cts:...) will be
> more helpful and much
>       > appreciated.... :)
>       >
>       > thanks,
>       > Deepak M.
>       >
>       > ________________________________
>       > Download prohibited? No problem. CHAT from any
> browser, without download.
>       > _______________________________________________
>       > General mailing list
>       > General at developer.marklogic.com
>       > http://xqzone.com/mailman/listinfo/general
>       >
>       >
>       _______________________________________________
>       General mailing list
>       General at developer.marklogic.com
>       http://xqzone.com/mailman/listinfo/general
>
>
>
> ________________________________
>
> Add more friends to your messenger and enjoy! Invite them
> now.
> <http://in.rd.yahoo.com/tagline_messenger_6/*http://messenger.
> yahoo.com/invite/>
>



More information about the General mailing list