jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ard Schrijvers <a.schrijv...@onehippo.com>
Subject Re: XPath query: check if child-node does not exist
Date Wed, 01 Dec 2010 15:01:28 GMT
On Wed, Dec 1, 2010 at 2:47 PM, Nicolas Betheuil
<Nicolas.Betheuil@europe.adp.com> wrote:
> Hi,
>
> Only to tell you where i'm gone because i ever try this
> http://dev.day.com/discussion-groups/content/lists/jackrabbit-users/2010-11/2010-11-23_Re_xpath_query_of_subnode_Alexander_Klimetschek.html
>
> You will not succeed to do what you want. The xpath implementation is very far to be
exaustive as all the documentation tell it. Think about going back to whiteboard to try to
find a workaround to your problem.
>
> The conditions (between []) can only test properties on same node, not child nodes even
is sql2.

What makes you think this is the case? Are you referring to some JR version?

child conditions are supported within the where [] clause. Only
fn:name() which you should use for nodename clauses, does not seem to
work in child where clauses.

I am however not sure what the query below would need to return:

//element(*,mynode)[child/grandchild/@name!='grandchild2' and @property='test']

I think the query is very confusing. Imo, for child predicates you
should try to avoid != . I think not many developers know the subtle
difference between != and not() : It is *very* different when handling
multi valued properties. The != is not very intuitive then. Same holds
imo for child queries.

You can try:

//element(*,mynode)[not(child/grandchild/@name = 'grandchild2') and
@property='test']

I assume now 'name' is a property of the grandchild node.

Otherwise, and I agree with Nicolas, you should reconsider you content model.

Regards Ard

>
> -----Message d'origine-----
> De : Stefan Hagedorn [mailto:nachteilhaft@gmx.de]
> Envoyé : mercredi 1 décembre 2010 14:39
> À : users@jackrabbit.apache.org
> Objet : XPath query: check if child-node does not exist
>
> Hi,
>
> I am trying to build a XPath query that gets all nodes that do not have
> a certain (grand)child node but do have a property with a certain value
>
> example
>
> node1 (property=test)
>  + child
>     + grandchild1
>     + grandchild2
>
>
> node2 (property=test)
>  + child
>     + grandchild1
>
>
> With my query I would like to find all nodes ("nodeX") that do not have
> a grandchild "grandchild2" but do have a property "property" with value
> "test".
>
> i.e. in the example above I would like the query to return node2 (since
> node1 has a grandchild "grandchild2".
>
> It doesn't matter to me if "grandchildX" is the name of the
> grandchild-node, or if it was in an extra name-property of the grandchild.
>
> I tried with the grandchild names as a property (all grandchildren have
> the same node name) and have the following sample:
> //element(*,mynode)[child/grandchild/@name!='grandchild2' and
> @property='test']
>
> But this also returns node1 as this has a granchild which is not
> grandchild2 ...
>
>
> Is this possible with Jackrabbit/XPath and could someone please show me
> how? ;)
>
> Thanks in advance,
> Stefan
>



-- 
Hippo
Europe  •  Amsterdam  Oosteinde 11  •  1017 WT Amsterdam  •  +31 (0)20 522 4466
Hippo USA Inc  • 755 Baywood Drive  • Second Floor  • Petaluma, CA  •
94954 USA  • Phone +1 (707) 658-4535
Canada    •   Montréal  5369 Boulevard St-Laurent  •  Montréal QC H2T
1S5  •  +1 (514) 316 8966
www.onehippo.com  •  www.onehippo.org  •  info@onehippo.com

Mime
View raw message