Return-Path: Delivered-To: apmail-incubator-jackrabbit-dev-archive@www.apache.org Received: (qmail 56557 invoked from network); 13 Dec 2004 19:22:40 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 13 Dec 2004 19:22:40 -0000 Received: (qmail 42547 invoked by uid 500); 13 Dec 2004 19:22:40 -0000 Mailing-List: contact jackrabbit-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: jackrabbit-dev@incubator.apache.org Delivered-To: mailing list jackrabbit-dev@incubator.apache.org Received: (qmail 42532 invoked by uid 99); 13 Dec 2004 19:22:40 -0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=FORGED_RCVD_HELO X-Spam-Check-By: apache.org Received-SPF: pass (hermes.apache.org: local policy) Received: from pm1.terions.de (HELO pm1.terions.de) (83.137.96.25) by apache.org (qpsmtpd/0.28) with ESMTP; Mon, 13 Dec 2004 11:22:35 -0800 Received: (qmail 1287 invoked by uid 98); 13 Dec 2004 19:25:58 -0000 Received: from p50855e5e.dip0.t-ipconnect.de (HELO tesat.lan) (jocsch@freaquac.de@80.133.94.94) by pm1.terions.de with SMTP; 13 Dec 2004 19:25:58 -0000 From: jocsch To: jackrabbit-dev@incubator.apache.org Subject: Re: sibling and basic understanding of jsr 170 Date: Mon, 13 Dec 2004 20:27:05 +0100 User-Agent: KMail/1.7 References: <200412131804.46374.jocsch@freaquac.de> <90a8d1c004121309276a116c07@mail.gmail.com> In-Reply-To: <90a8d1c004121309276a116c07@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200412132027.05718.jocsch@freaquac.de> X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N Thanks for the anwser. That's for sure not elegant. Hopefully some day I can replace this string manipulation with something cleaner ;-) Greetings, Markus Am Montag, 13. Dezember 2004 18:27 schrieb Stefan Guggisberg: > hi markus, > you're right, there's no easy solution for your particular use case, > > you could write a short utility method though, something like > > Node getSiblingOf(Node n, int index) > > that method would > > 1. extract the current subscript from the path of n (n.getPath()), > e.g. 99 > 2. compute new subscript (99-1=98) > 3. get sibling with > n.getParent().getNode(n.getName() + "[" + subscript + "]") > > not very elegant but more efficient than iterating over all children... > > cheers > stefan > > On Mon, 13 Dec 2004 18:04:46 +0100, jocsch wrote: > > Hi, > > > > sorry for posting a more jcr related question than a jackrabbit one, but > > I'm not in the expert group ;-) > > > > I have a problem finding a sibling related to a given Node. > > I set up a container node which has an undetermined number of children. > > The order of the children matters. So it looks like: > > > > RN > > > > tst:container > > > > |-... > > |-tst:child[98] > > |-tst:child[99] > > |-.... > > > > Now I have a use case where tst:child[99] is given and I need to show its > > preceding sibling tst:child[98]. > > I found no possibility to get this node other than iterating over all > > children (comparing to the given node and remembering the preceding > > node), because it seems that there is no getPosition() or something like > > that on the Node type. > > > > I think this solution is far from optimal. Is there a better solution? > > OK, I guess I can implement a kind of a linked list functionality into > > the child node types, but if possible, I want to avoid this. > > I know that there are xpath functions like following-sibling but I read > > somewhere that xpath queries are not yet implemented in jackrabbit. > > > > Thanks, > > Markus