jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Guggisberg <stefan.guggisb...@gmail.com>
Subject Re: bug in Item.getPath?
Date Mon, 21 Sep 2009 07:04:24 GMT
hi rodrigo

On Mon, Sep 21, 2009 at 8:00 AM, Rodrigo Meza
<rodrigo.meza.forms@gmail.com> wrote:
> Hi,
>    I have a repository with same name siblings, like:
>  myItem[1]
>  myItem[2]
>  myItem[3]
>  myItem[4]
> However, when I call getPath() on the first node defined with this name, I
> obtain "myItem"  instead of "myItem[1]". Is this behaviour correct?... as
> far as I know it is not, because the specification of  getPath() in
> jsr170-spec says:
> " Returns the absolute path to this item.
> If the path includes items that are same name sibling nodes or multi-value
> properties then those elements in the path will include the appropriate
> “square bracket” index notation (for example, /a/b[3]/c).
> A RepositoryException is thrown if an error occurs."
> Am I getting something wrong from the specification? There exist other
> method that returns the square bracket index notation for the first element?

index value 1 is always implied if not explicitly specified.

see "4.3.1 Index Notation" (JCR 1.0 Spec):

However, as opposed to the semantics of XPath, a name in a content
repository path that does not explicitly specify an index implies an
index of 1. For example, /a/b/c is equivalent to /a[1]/b[1]/c[1].

you can determine each items index value by calling Item.getIndex().


> Thanks,
>  Rodrigo.

View raw message