On 18 November 2010 12:16, Torgeir Veimo <[email protected]> wrote: > On 18 November 2010 00:21, Clemens Wyss <[email protected]> wrote: >> I re-read your initial post ;-) >> How about: >> //element(*)[...@prefix='<path prefix extracted from the nodes path>'] > > The trick is to get that path prefix extracted > > What I was thinking was that if the subscription contained a reference > to a node instead of it's path, then if it was possible to implicitly > dereference this reference in the query, and check if it refers to a > parent node of the given node / path from the event listeners onevent > call. > >> If your subscription nodes have a specific nodetype, e.g. >> 'myblog:subscription': >> //element(*, myblog:subscription)[...@prefix='<path prefix extracted from >> the nodes path>']
It looks like this is not possible to do using a query, so an iteration over parent nodes seems necessary. Given a node, traverse up its parent nodes, and find subscriber nodes: 1) if subscribers are stored as subnodes of the node, just retrieve a nodeiterator for the subscriber child nodes, or 2) if subscribers are stored elsewhere, eg as subscriber nodes under a users 'home' node, with references to the subscribed-to nodes, fetch all such nodes with node.getReferences() (and check if correct nodetype). Anyone got any other ideas worth pursuing for subscriptions? -- -Tor
