Uploaded image for project: 'ModeShape'
  1. ModeShape
  2. MODE-686

XPath queries with path and attribute criteria are not converted to JCR-SQL2 with the right criteria

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Critical Critical
    • 1.1.0.Final
    • 1.0.0.Final
    • JCR, Query
    • None

      An XPath query such as the following:

      //NodeA[@foo:bar='value']

      does not find nodes that are immediately under the root, but it does find nodes that match that criteria in any location other than right under the root. However, the following query:

      //NodeA

      does work correctly (because it is translated into different criteria that uses a name match, where the first query results in a path constraint, namely "...PATH(nodeSet) LIKE '%/NodeA'...").

      There are several simple workarounds (depending upon the exact situation):

      1) When nodes exist right under the root (and nowhere else), the query can be constrained a bit more (resulting in different constraints that are processed correctly for all nodes):

      /jcr:root/odl:odelia-technologies[@odl:url='http://www.odelia-technologies.com']

      2) In the case where the location of the nodes is more variable (or unknown) but you know the name, you can use the 'element(name)' function to constrain the name of the node:

      //element(odl:odelia-technologies)[@odl:url='http://www.odelia-technologies.com']

              rhauch Randall Hauch (Inactive)
              rhauch Randall Hauch (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved: