AnsweredAssumed Answered

XPath category queries + ancestor axis

Question asked by dbevacqua on Aug 2, 2006
Latest reply on Aug 3, 2006 by andy
Hi

(Apologies in advance - I think this is going to be a long one…)

I'm trying to write a generic search interface that allows users to query the repo for nodes of a particular type, specifying criteria about the attributes and categories of ancestors and descendants. I've come up against a few issues and I wonder if you could point me in the right direction. I'm new to XPath so this may all be perfectly obvious…

A typical kind of query is:


"give me all nodes of type A that have a descendant of type B in category x and an ancestor of type C in category y"

Ideally I would do this in the Lucene language, but I can only use TYPE: to specify the type of node I want returned (i.e. there seems no way to make the required statements about types B and C). element() and subtypeOf() do not appear to be supported in the Lucene search. So I think I need to use XPath.

So, question 1: how do I do category queries using XPath?

These are simple enough to do in the Lucene language, and very quick. I can't seem to reproduce such queries in XPath though. I've tried things like:


//*[@myNamespace:myCategory='workspace://SpacesStore/414c42b3-2226-11db-86ce-1f31bf652f1c']

and


//*[@myNamespace:myCategory='414c42b3-2226-11db-86ce-1f31bf652f1c']

both with and without single quotes.

where myCategory is a single-valued property of type d:category and 414c42b3-2226-11db-86ce-1f31bf652f1c is the guid of a category node.

What am I doing wrong? do I need to deref() the property? do I need to use a different delimiter, or some function?


Once I've solved that, there's the slightly knottier problem of specifying criteria about ancestors. So:

Question 2: Would it be feasible for me to implement the ancestor:: axis in the XPath search? Any pointers? Jaxen seems to support it. Was it not implemented for performance reasons or something more fundamental?


If I can't do these kinds of queries as XPaths, I guess I could combine the results of a number of Lucene searches. So for the original query, I would break it down into:


all ancestors of                  <– just analyse the nodes returned by Lucene?
   (all nodes of type B in category x)  <– Lucene query
with type B
   
intersection

all descendants of                   
   (all nodes of type C in category y) <– Lucene query
with type A    


Bit of a kludge though.

Hope this makes some kind of sense and (even more) that you can help!

Many thanks in advance.

Dominic

Outcomes