You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jackrabbit.apache.org by Shane Preater <sh...@googlemail.com> on 2006/10/04 14:35:42 UTC

xpath aggregation question

Hi,
I am trying to return the distinct brand property on a series of nodes and
have no idea how to go about it. Any help would be fantastic.

for example:
/categories//products/*   will return all my products
all the nodes returned have a brand property so:

/categories//products/*/@brand  will return all the brands

but how make the list distinct? Or will I need to use an SQL query instead?

Many thanks,
Shane.

Re: xpath aggregation question

Posted by Shane Preater <sh...@googlemail.com>.
Hi,
Thanks for the swift response.

I'll have to work out a way around the finding the parent node but hey such
is life.

I actually really like the brand idea you have proposed and I think I will
follow your advice and set it as a reference.

Cheers,
Shane.

On 04/10/06, Jukka Zitting <ju...@gmail.com> wrote:
>
> Hi,
>
> On 10/4/06, Shane Preater <sh...@googlemail.com> wrote:
> > I am trying to return the distinct brand property on a series of nodes
> and
> > have no idea how to go about it. Any help would be fantastic.
> >
> > for example:
> > /categories//products/*   will return all my products
> > all the nodes returned have a brand property so:
> >
> > /categories//products/*/@brand  will return all the brands
> >
> > but how make the list distinct? Or will I need to use an SQL query
> instead?
>
> Again, I'm sorry to say that the query features in JSR 170 won't help
> you there. There is no support for aggregate results, joins, or other
> advanced query features, so you'll essentially need to work around the
> limitation by post-processing the query results.
>
> But again there is an alternative where you setup separate
> referenceable brand nodes like /categories/brands/* and turn the
> @brand property of a product node into a reference. Then you can list
> all your brands by listing the children of /categories/brands and you
> will also have a very efficient way to retrieve all the products of a
> given brand.
>
> BR,
>
> Jukka Zitting
>
> --
> Yukatan - http://yukatan.fi/ - info@yukatan.fi
> Software craftsmanship, JCR consulting, and Java development
>

Re: xpath aggregation question

Posted by Jukka Zitting <ju...@gmail.com>.
Hi,

On 10/4/06, Shane Preater <sh...@googlemail.com> wrote:
> I am trying to return the distinct brand property on a series of nodes and
> have no idea how to go about it. Any help would be fantastic.
>
> for example:
> /categories//products/*   will return all my products
> all the nodes returned have a brand property so:
>
> /categories//products/*/@brand  will return all the brands
>
> but how make the list distinct? Or will I need to use an SQL query instead?

Again, I'm sorry to say that the query features in JSR 170 won't help
you there. There is no support for aggregate results, joins, or other
advanced query features, so you'll essentially need to work around the
limitation by post-processing the query results.

But again there is an alternative where you setup separate
referenceable brand nodes like /categories/brands/* and turn the
@brand property of a product node into a reference. Then you can list
all your brands by listing the children of /categories/brands and you
will also have a very efficient way to retrieve all the products of a
given brand.

BR,

Jukka Zitting

-- 
Yukatan - http://yukatan.fi/ - info@yukatan.fi
Software craftsmanship, JCR consulting, and Java development