You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by Rodrigo Meza <ro...@gmail.com> on 2009/09/21 08:00:55 UTC
bug in Item.getPath?
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?
Thanks,
Rodrigo.
Re: bug in Item.getPath?
Posted by Philipp Bunge <bu...@crimson.ch>.
Hi Rodrigo,
> see "4.3.1 Index Notation" (JCR 1.0 Spec):
>
> <quote>
> 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].
> </quote>
Also take a look at "3.4.3.1 Standard Form" in the JCR 2.0 spec draft:
<blockquote>
A string constructed without any of the optional syntax shown in the
algorithm is
called the standard form of a JCR path. Such a lexical path has the following
characteristics:
- All name segments are in qualified form, none are in expanded form.
- No name segment has a [1] index.
- There is no trailing forward slash (“/”).
</blockquote>
Cheers,
Philipp
Re: bug in Item.getPath?
Posted by Stefan Guggisberg <st...@gmail.com>.
hi rodrigo
On Mon, Sep 21, 2009 at 8:00 AM, Rodrigo Meza
<ro...@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):
<quote>
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].
</quote>
you can determine each items index value by calling Item.getIndex().
cheers
stefan
>
> Thanks,
> Rodrigo.
>