> -----Original Message----- > From: Benjamin Brown [mailto:[email protected]] > Sent: 09 April 2009 16:20 > To: [email protected] > Subject: RE: Descendant or self axis problem - a known issue? > > > > 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] > > > > 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(.... > > > > I had thought of this but I believed the descendant-or-self would also > return the reference on the node with the axis on (otherwise where does > the "self" part come in)? :) > > For a simple xpath axis examples please see > http://www.zvon.org/xxl/XSL-Ref/Tutorials/Axes/ax8.html > > The output clearly illustrates a descendant or self actually returning the > axis'd element "aaa", whereas just "descendant" seems to be what you are > describing and the functionality that JCR 1.4 seems to be providing? > > In my mind > /aaa/descendant-or-self::* > is akin to > /jcr:root/cms:Views/cms:viewObject/descendant-or-self::node() > and therefore I would expect any *references* on the axis'd node > /jcr:root/cms:Views/cms:viewObject/ > to be returned as per their example which returned the axis'd element. > > Thanks, > > Benjamin
Replying to my own post... also unfortunately I can't move axis back one node on the xpath as you alluded to with your (expanded) query below /jcr:root/cms:Views//cms:viewObject/jcr:deref(.... because it matches incorrectly. For example (again using original example top) I may want the references on the following node and its children only /jcr:root/cms:Views/cms:viewObject/cms:viewObject and to do this via the suggested method above the query would be cms:Views/cms:viewObject//cms:viewObject/jcr:deref(.... this would also return references on the following (!) > > > 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] Benjamin
