Hi,

On Thu, Apr 9, 2009 at 16:06, Benjamin Brown
<[email protected]> wrote:
> Hi,
>
> I've been working with an xpath query recently that's made me think that the 
> descendant or self axis seems to be broken (JCR 1.4)
>
> I have a tree of nodes like the following (written by hand as I don't have 
> the actual output readily available):
>
> cms:Views/cms:viewObject/cms:viewObject
> cms:Views/cms:viewObject/cms:viewObject[2]
> cms:Views/cms:viewObject/cms:viewObject[3]/cms:viewObject
> cms:Views/cms:viewObject/cms:viewObject[3]/cms:viewObject[2]
>
> Where all cms:viewObject nodes contain multiple references to other (non 
> view) nodes.
>
> In order retrieve ALL the references under for cms:Views/cms:viewObject
>
> I think I can query like this (truncated as it's a long query)
> /jcr:root/cms:Views/cms:viewObject//jcr:deref(@cms:reference, 
> '*')//element(cms:content,
>
> This query should (I believe) retrieve the referenced nodes for all of the 
> view nodes (6) listed above, inclusive of the reference of the node it was 
> called on (i.e. self).
>
> I find that it is omitting the reference on the self node 
> cms:Views/cms:viewObject and returns only the nodes referenced on the 
> descendents of the specified view node - is this expected behaviour/a known 
> bug and is there a work around apart from doing two queries?

In XPath // is the abbreviated syntax for /descendant-or-self::node()/
(see: http://www.w3.org/TR/xpath20/#abbrev), which means your query is
translated into:

/jcr:root/cms:Views/cms:viewObject/descendant-or-self::node()/jcr:deref(@cms:reference,
'*')/descendant-or-self::node()/element(cms:content,

this will never select /cms:Views/cms:viewObject

why don't you just select all nodes name cms:viewObject and then
dereference them?

//cms:viewObject/jcr:deref(....

regards
 marcel

> I can provide more detailed output if necessary.
>
> Thanks,
>
> Benjamin
>

Reply via email to