This is definitely an interesting idea, but you'd need some kind of tooling. Otherwise, it's just easier to write the XPATH query by hand IMHO.
On Wed, Jul 13, 2011 at 7:07 PM, sam web scale expert <[email protected]> wrote: > Is there query api that builds query from resources? > Since a resource is a tree, I was thinking I could express query as a > resource (a tree): > > GET /query/foo.json > > will return the query result of foo as json. The query is structured in > /query/foo tree. > > /query/foo/@searchRoot = "/content/diaries" > /query/foo/or/has/@bar = True > /query/foo/or/has/@author = True > /query/foo/or/and/is/@publishDate = 2011-07-03 00:00:00 > /query/foo/or/and/is/@cateogry = "secret" > ... > would build: > /jcr:root/content/diaries//*[(@bar and @author) or (@publishDate = > '2011-07-03 00:00:00' and @category = 'secret')] > > > Is there something like this? > If not, would having this kind of API be useful? > I know I can just store xpath as a property in a node... But since xpath is > deprecated in JCR 2.0, I was wondering if it could be useful to store query > in a resource somehow. > > It's like prepared queries.. in a way. > And the resource might even cache query results and run the query only when > needed to. >
