You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by Christoph Kiehl <ch...@sulu3000.de> on 2007/07/06 17:28:52 UTC
Combined attribute test on childnode for xpath query
Hi all,
I'm not a master of XPath at all, so may someone can tell me if the following is
possible with Jackrabbit, and if yes, how.
I need to execute a query like this:
//element(*, nt:foo)[test/*[@foo='a' and @bar='b']]
This means I need all nodes of type "nt:foo" which have "foo=a" and "bar=b" on
_one_ specific childnode. If I write it like that
//element(*, nt:foo)[test/@foo='a' and test/@bar='b']
it seems like the condition is matched if for example "test[1]/@foo='a' and
test[2]/@bar='b'" is true.
Thanks,
Christoph
Re: Combined attribute test on childnode for xpath query
Posted by Marcel Reutegger <ma...@gmx.net>.
Christoph Kiehl wrote:
> Could you give me a pointer what has to be done to support this? Is it a
> desirable feature at all?
It certainly is a desirable feature, but I wouldn't invest too much time at this
point because we will soon start with changes / enhancements for JCR 2.0.
> Or is it maybe easier to implement support for the ancestor axis? The
> query could be rewritten like this:
>
> //element(*, nt:foo)/test[@foo='a' and @bar='b']/..
yes, that's probably easier. because the query tree structure is quite limited
when it comes to predicates.
regards
marcel
Re: Combined attribute test on childnode for xpath query
Posted by Christoph Kiehl <ch...@sulu3000.de>.
Marcel Reutegger wrote:
>> I need to execute a query like this:
>>
>> //element(*, nt:foo)[test/*[@foo='a' and @bar='b']]
>
> I guess you rather mean:
>
> //element(*, nt:foo)[test[@foo='a' and @bar='b']]
Yes ;)
> but in any case, this is currently not possible in jackrabbit.
Could you give me a pointer what has to be done to support this? Is it a
desirable feature at all?
Or is it maybe easier to implement support for the ancestor axis? The query
could be rewritten like this:
//element(*, nt:foo)/test[@foo='a' and @bar='b']/..
>> This means I need all nodes of type "nt:foo" which have "foo=a" and
>> "bar=b" on _one_ specific childnode. If I write it like that
>>
>> //element(*, nt:foo)[test/@foo='a' and test/@bar='b']
>
> that's kind of the workaround for the above mentioned limitation.
>
>> it seems like the condition is matched if for example
>> "test[1]/@foo='a' and test[2]/@bar='b'" is true.
>
> correct.
>
> looks like another argument for Davids DM Rule #4.
Well ... I think it's kind of a weak argument ;) I would better like to add the
missing feature to Jackrabbit.
Cheers,
Christoph
Re: Combined attribute test on childnode for xpath query
Posted by Marcel Reutegger <ma...@gmx.net>.
Christoph Kiehl wrote:
> I'm not a master of XPath at all, so may someone can tell me if the
> following is possible with Jackrabbit, and if yes, how.
>
> I need to execute a query like this:
>
> //element(*, nt:foo)[test/*[@foo='a' and @bar='b']]
I guess you rather mean:
//element(*, nt:foo)[test[@foo='a' and @bar='b']]
but in any case, this is currently not possible in jackrabbit.
> This means I need all nodes of type "nt:foo" which have "foo=a" and
> "bar=b" on _one_ specific childnode. If I write it like that
>
> //element(*, nt:foo)[test/@foo='a' and test/@bar='b']
that's kind of the workaround for the above mentioned limitation.
> it seems like the condition is matched if for example "test[1]/@foo='a'
> and test[2]/@bar='b'" is true.
correct.
looks like another argument for Davids DM Rule #4.
regards
marcel