<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic XPath category queries + ancestor axis in Alfresco Archive</title>
    <link>https://connect.hyland.com/t5/alfresco-archive/xpath-category-queries-ancestor-axis/m-p/22924#M11053</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;(Apologies in advance - I think this is going to be a long one…)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;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…&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;A typical kind of query is:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;&lt;BR /&gt;"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"&lt;BR /&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;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.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;So, question 1: how do I do category queries using XPath?&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;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:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;&lt;BR /&gt;//*[@myNamespace:myCategory='workspace://SpacesStore/414c42b3-2226-11db-86ce-1f31bf652f1c']&lt;BR /&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;and &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;&lt;BR /&gt;//*[@myNamespace:myCategory='414c42b3-2226-11db-86ce-1f31bf652f1c']&lt;BR /&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;both with and without single quotes.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;where myCategory is a single-valued property of type d:category and 414c42b3-2226-11db-86ce-1f31bf652f1c is the guid of a category node.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What am I doing wrong? do I need to deref() the property? do I need to use a different delimiter, or some function?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Once I've solved that, there's the slightly knottier problem of specifying criteria about ancestors. So:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;Question 2: Would it be feasible for me to implement the &lt;EM&gt;ancestor::&lt;/EM&gt; axis in the XPath search? Any pointers? Jaxen seems to support it. Was it not implemented for performance reasons or something more fundamental? &lt;BR /&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;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:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;&lt;BR /&gt;all ancestors of&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;– just analyse the nodes returned by Lucene?&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;(all nodes of type B in category x)&amp;nbsp; &amp;lt;– Lucene query&lt;BR /&gt;with type B&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;intersection&lt;BR /&gt;&lt;BR /&gt;all descendants of &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;(all nodes of type C in category y) &amp;lt;– Lucene query&lt;BR /&gt;with type A &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Bit of a kludge though.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hope this makes some kind of sense and (even more) that you can help!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Many thanks in advance.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Dominic&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 02 Aug 2006 14:31:26 GMT</pubDate>
    <dc:creator>dbevacqua</dc:creator>
    <dc:date>2006-08-02T14:31:26Z</dc:date>
    <item>
      <title>XPath category queries + ancestor axis</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/xpath-category-queries-ancestor-axis/m-p/22924#M11053</link>
      <description>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</description>
      <pubDate>Wed, 02 Aug 2006 14:31:26 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/xpath-category-queries-ancestor-axis/m-p/22924#M11053</guid>
      <dc:creator>dbevacqua</dc:creator>
      <dc:date>2006-08-02T14:31:26Z</dc:date>
    </item>
    <item>
      <title>Re: XPath category queries + ancestor axis</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/xpath-category-queries-ancestor-axis/m-p/22925#M11054</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;sorry just noticed a typo in the last bit of the above. Should read &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;&lt;BR /&gt;all ancestors of&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;– just analyse the nodes returned by Lucene?&lt;BR /&gt;&amp;nbsp;&amp;nbsp; (all nodes of type B in category x)&amp;nbsp; &amp;lt;– Lucene query&lt;BR /&gt;with type A &lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;intersection&lt;BR /&gt;&lt;BR /&gt;all descendants of&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp; (all nodes of type C in category y) &amp;lt;– Lucene query&lt;BR /&gt;with type A&amp;nbsp; &lt;BR /&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Aug 2006 16:40:00 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/xpath-category-queries-ancestor-axis/m-p/22925#M11054</guid>
      <dc:creator>dbevacqua</dc:creator>
      <dc:date>2006-08-02T16:40:00Z</dc:date>
    </item>
    <item>
      <title>Re: XPath category queries + ancestor axis</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/xpath-category-queries-ancestor-axis/m-p/22926#M11055</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You are right, you can not use lucene for this.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;We do not do joins or support predicates at the moment.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You should be able to use the ancestor:: axis in XPATH queries - using the default Jaxen implementation. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The XPATH category stuff should have a property that contains the nodeRef of the linked category. Your example should work. There may be an issue with multivalued properties in XPATH searches. I will have a look at this when time allows. Also remember that categories are in a tree so you would have to check for membership of a category and all its sub categories. This si where the lucene stuff will win.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Your suggestion is probably the best way at the moment.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Andy&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Aug 2006 14:25:01 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/xpath-category-queries-ancestor-axis/m-p/22926#M11055</guid>
      <dc:creator>andy</dc:creator>
      <dc:date>2006-08-03T14:25:01Z</dc:date>
    </item>
  </channel>
</rss>

