You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by Łukasz Sroka <Lu...@comarch.com> on 2007/03/19 12:05:20 UTC

Different resoult query SQL and XPath

Hi
I have SQL query :
select * from nt:unstructured where jcr:path like '%/childNode0Level1'
and XPath :
//GUI//childNode0Level1
My repository :
root
|->jcr:system
|->GUI
         |->new.xml

new.xml look :
<rootElement>
   <childNode0Level1>
       <childNode0Level2>
       </childNode0Level2>
   </childNode0Level1>
<childNode1Level1>
       <childNode0Level2>
       </childNode0Level2>
   </childNode1Level1>
   <childNode0Level1>
       <childNode0Level2>
       </childNode0Level2>
   </childNode0Level1>
</rootElement>

And the problem is different result returned  by  XPath and SQL. XPath  
find  2 childNode0Level1 and SQL only 1. Why?



Re: Different resoult query SQL and XPath

Posted by Łukasz Sroka <Lu...@comarch.com>.
Hi,

It works fine. Thank you

BR
Łukasz Sroka

Re: Different resoult query SQL and XPath

Posted by Marcel Reutegger <ma...@gmx.net>.
Hi Łukasz,

Łukasz Sroka wrote:
> I have SQL query :
> select * from nt:unstructured where jcr:path like '%/childNode0Level1'
> and XPath :
> //GUI//childNode0Level1

those two statements are not exactly the same because the XPath statement you 
have contains two descendant-or-self axis. but that's another issue.

the reason why the SQL query only return one node is the fact that:
jcr:path like '%/childNode0Level1'

is roughly equivalent to an XPath statement:

//childNode0Level[1]

See spec section: 8.5.2.2

if you need all same name siblings you have to write:

jcr:path like '%/childNode0Level1[%]'

regards
  marcel