Jackrabbit Content Repository
  1. Jackrabbit Content Repository
  2. JCR-740

Support for the decendant-or-self axis in XPath predicates

    Details

    • Type: Improvement Improvement
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 1.2.1
    • Fix Version/s: None
    • Component/s: jackrabbit-core, xpath
    • Labels:
      None

      Description

      For example,
      I want to find the root of a node tree that contains a node with a specified id. The child node may be n layers deep in the node tree. In my specific case, I know how deep it is so

      //element(*, my:foo)[bar/*/*/*/*/@jcr:uuid = 'abc']

      finds the node of type my:foo that contains the child node with id 'abc'.

      Now, I would like to generalize this so I thought i could simply do the following.
      //element(*, my:foo)[bar//*/@jcr:uuid = 'abc']

      but this does not work.

      1. patch.txt
        6 kB
        Christoph Kiehl

        Issue Links

          Activity

          Hide
          Christoph Kiehl added a comment -

          This patch is a prototype for supporting jcr:contains calls that use descendent-or-self-axis as their root:

          /foo/bar/*[jcr:contains(//*, term)]

          It does not support queries which use descendent-or-self-axis on childnodes:

          NOT SUPPORTED: /foo/bar/*[jcr:contains(test//*, term)]

          Right now it uses a keyword to recognize descendent-or-self-axis queries:

          /foo/bar/*[jcr:contains(DESCENDENT_OR_SELF, term)]

          We used to have queries like this:

          /foo/bar/*[jcr:contains(., term) or jcr:contains(*, term) or jcr:contains(*/*, term)]

          In this construct the term query is executed three times which leads to long execution times whereas the query above is much faster because the term query is only executed once.

          This is just a prototype and I would like to know what you think about it. The patch needs better integration with the query builder so that we don't need to use a keyword but can use "//*" instead.

          Show
          Christoph Kiehl added a comment - This patch is a prototype for supporting jcr:contains calls that use descendent-or-self-axis as their root: /foo/bar/* [jcr:contains(//*, term)] It does not support queries which use descendent-or-self-axis on childnodes: NOT SUPPORTED: /foo/bar/* [jcr:contains(test//*, term)] Right now it uses a keyword to recognize descendent-or-self-axis queries: /foo/bar/* [jcr:contains(DESCENDENT_OR_SELF, term)] We used to have queries like this: /foo/bar/* [jcr:contains(., term) or jcr:contains(*, term) or jcr:contains(*/*, term)] In this construct the term query is executed three times which leads to long execution times whereas the query above is much faster because the term query is only executed once. This is just a prototype and I would like to know what you think about it. The patch needs better integration with the query builder so that we don't need to use a keyword but can use "//*" instead.
          Hide
          Marcel Reutegger added a comment -

          Well, the problem with the current implementation is how the path is stored in the abstract query tree. Because it uses a Path instance in RelationQueryNode other axis than child are not possible currently. The correct solution is probably to replace the Path with a full fledged PathQueryNode. Anything else is rather a hack.

          Show
          Marcel Reutegger added a comment - Well, the problem with the current implementation is how the path is stored in the abstract query tree. Because it uses a Path instance in RelationQueryNode other axis than child are not possible currently. The correct solution is probably to replace the Path with a full fledged PathQueryNode. Anything else is rather a hack.

            People

            • Assignee:
              Unassigned
              Reporter:
              Randy Simon
            • Votes:
              5 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:

                Development