You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by Frederic Laugier <hi...@dementia7.net> on 2008/03/03 12:37:28 UTC
XPath exists/not exists question
Hello,
I have a question regarding the Exists / Not exists XPath operators.
My test data contains three nodes :
+ nodeA
- prop1 = 'value'
+ child
- subprop1 = 'something'
+ nodeB
- prop1 = 'value'
+ child
+ nodeC
- prop1 = 'value'
The query //*[child/@subprop1)] returns nodeA
The query //*[child/not(@subprop1)] returns nodeB
The query //*[not(child/@subprop1)] returns nodeB
I may be mistaken but I thought the third query would return nodeC as well
Can anybody tell me if I'm wrong, or if there is any other way to test
the non existence of a property in a child node regardless if the child
node exists or not ?
I'm using Jackrabbit 1.5 (r633030).
Best regards,
Frederic Laugier.
Re: XPath exists/not exists question
Posted by smieci24 <sm...@gmail.com>.
Hi
I have problem with such queries using child node properties in new OCM
module.
I have tried build query using Filter but it only works with current object
property (not childs).
Example:
+ nodeA
- prop1 = 'value'
+ child
- subprop1 = 'something'
Code to build query:
Filter filter = queryManager.createFilter(NodeA.class);
filter.addEqualTo("prope1/subprop1", "plain/text");
Query query = queryManager.createQuery(filter)
Collection result = objectContentManager().getObjects(query);
Result is always 0. I log also generated jcr expression:
"//element(*, nt:unstructured) [(@null = 'plain/text') and (
@ocm:classname='com.test.NodeA')]"
@null - it means that property was not found. And it is true because in log
we can see:
"Impossible to find the jcrFieldName for the attribute :prope1/subprop1"
It is a bug or I missed something ?
Best regards
Marcin Muras
Frederic Laugier wrote:
>
> Hello,
>
> I have a question regarding the Exists / Not exists XPath operators.
>
>
> My test data contains three nodes :
>
> + nodeA
> - prop1 = 'value'
> + child
> - subprop1 = 'something'
>
> + nodeB
> - prop1 = 'value'
> + child
>
> + nodeC
> - prop1 = 'value'
>
>
>
> The query //*[child/@subprop1)] returns nodeA
>
> The query //*[child/not(@subprop1)] returns nodeB
>
> The query //*[not(child/@subprop1)] returns nodeB
>
> I may be mistaken but I thought the third query would return nodeC as well
>
> Can anybody tell me if I'm wrong, or if there is any other way to test
> the non existence of a property in a child node regardless if the child
> node exists or not ?
>
> I'm using Jackrabbit 1.5 (r633030).
>
> Best regards,
> Frederic Laugier.
>
>
>
--
View this message in context: http://www.nabble.com/XPath-exists-not-exists-question-tp15802262p20015955.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.
Re: XPath exists/not exists question
Posted by Frederic Laugier <hi...@dementia7.net>.
Sure thing, I've created https://issues.apache.org/jira/browse/JCR-1447
and attached a test case (sorry again the test data are in French).
Marcel Reutegger wrote:
> Hi Frederic,
>
> this is most likely a bug in jackrabbit, can you please file a jira issue?
>
> thank you.
>
> regards
> marcel
>
> Frederic Laugier wrote:
>> Hello,
>>
>> I have a question regarding the Exists / Not exists XPath operators.
>>
>>
>> My test data contains three nodes :
>>
>> + nodeA
>> - prop1 = 'value'
>> + child
>> - subprop1 = 'something'
>>
>> + nodeB
>> - prop1 = 'value'
>> + child
>>
>> + nodeC
>> - prop1 = 'value'
>>
>>
>>
>> The query //*[child/@subprop1)] returns nodeA
>>
>> The query //*[child/not(@subprop1)] returns nodeB
>>
>> The query //*[not(child/@subprop1)] returns nodeB
>>
>> I may be mistaken but I thought the third query would return nodeC as
>> well
>>
>> Can anybody tell me if I'm wrong, or if there is any other way to test
>> the non existence of a property in a child node regardless if the child
>> node exists or not ?
>>
>> I'm using Jackrabbit 1.5 (r633030).
>>
>> Best regards,
>> Frederic Laugier.
>>
>>
Re: XPath exists/not exists question
Posted by Marcel Reutegger <ma...@gmx.net>.
Hi Frederic,
this is most likely a bug in jackrabbit, can you please file a jira issue?
thank you.
regards
marcel
Frederic Laugier wrote:
> Hello,
>
> I have a question regarding the Exists / Not exists XPath operators.
>
>
> My test data contains three nodes :
>
> + nodeA
> - prop1 = 'value'
> + child
> - subprop1 = 'something'
>
> + nodeB
> - prop1 = 'value'
> + child
>
> + nodeC
> - prop1 = 'value'
>
>
>
> The query //*[child/@subprop1)] returns nodeA
>
> The query //*[child/not(@subprop1)] returns nodeB
>
> The query //*[not(child/@subprop1)] returns nodeB
>
> I may be mistaken but I thought the third query would return nodeC as well
>
> Can anybody tell me if I'm wrong, or if there is any other way to test
> the non existence of a property in a child node regardless if the child
> node exists or not ?
>
> I'm using Jackrabbit 1.5 (r633030).
>
> Best regards,
> Frederic Laugier.
>
>