Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical
    • Resolution: Invalid
    • Affects Version/s: 1.0.1
    • Fix Version/s: None
    • Component/s: query
    • Labels:
      None

      Description

      INTRODUCTION:
      According to JSR-170-ch.4.6"Path Syntax" a syntactically valid path is:
      ...
      name ::= [prefix ':'] simplename
      simplename ::= onecharsimplename | twocharsimplename | threeormorecharname
      onecharsimplename ::= /* Any Unicode character except: '.', '/', ':', '[', ']', '*', ''', '"', '|' or any whitespace character */
      ...
      So, any "digit' name (e.g. "my:777") sould be valid.

      WHAT I DO:
      import org.apache.jackrabbit.core.query.*;
      ...
      String q = "/jcr:root / 2 / ( *, mytype)";
      QueryParser.parse( q, "xpath", nsRegistry);

      WHAT I EXPECT TO HAVE:
      Succesfully parsed query.

      WHAT I GET:
      javax.jcr.query.InvalidQueryException: Parse error: data is not a RelationQueryNode
      at org.apache.jackrabbit.core.query.xpath.XPathQueryBuilder.visit(XPathQueryBuilder.java:434)
      at org.apache.jackrabbit.core.query.xpath.SimpleNode.jjtAccept(SimpleNode.java:79)
      at org.apache.jackrabbit.core.query.xpath.SimpleNode.childrenAccept(SimpleNode.java:88)
      at org.apache.jackrabbit.core.query.xpath.XPathQueryBuilder.visit(XPathQueryBuilder.java:469)
      at org.apache.jackrabbit.core.query.xpath.SimpleNode.jjtAccept(SimpleNode.java:79)
      at org.apache.jackrabbit.core.query.xpath.SimpleNode.childrenAccept(SimpleNode.java:88)
      at org.apache.jackrabbit.core.query.xpath.XPathQueryBuilder.visit(XPathQueryBuilder.java:469)
      at org.apache.jackrabbit.core.query.xpath.SimpleNode.jjtAccept(SimpleNode.java:79)
      at org.apache.jackrabbit.core.query.xpath.SimpleNode.childrenAccept(SimpleNode.java:88)
      at org.apache.jackrabbit.core.query.xpath.XPathQueryBuilder.visit(XPathQueryBuilder.java:469)
      at org.apache.jackrabbit.core.query.xpath.SimpleNode.jjtAccept(SimpleNode.java:79)
      at org.apache.jackrabbit.core.query.xpath.SimpleNode.childrenAccept(SimpleNode.java:88)
      at org.apache.jackrabbit.core.query.xpath.XPathQueryBuilder.visit(XPathQueryBuilder.java:469)
      at org.apache.jackrabbit.core.query.xpath.SimpleNode.jjtAccept(SimpleNode.java:79)
      at org.apache.jackrabbit.core.query.xpath.SimpleNode.childrenAccept(SimpleNode.java:88)
      at org.apache.jackrabbit.core.query.xpath.XPathQueryBuilder.visit(XPathQueryBuilder.java:469)
      at org.apache.jackrabbit.core.query.xpath.SimpleNode.jjtAccept(SimpleNode.java:79)
      at org.apache.jackrabbit.core.query.xpath.SimpleNode.childrenAccept(SimpleNode.java:88)
      at org.apache.jackrabbit.core.query.xpath.XPathQueryBuilder.visit(XPathQueryBuilder.java:469)
      at org.apache.jackrabbit.core.query.xpath.SimpleNode.jjtAccept(SimpleNode.java:79)
      at org.apache.jackrabbit.core.query.xpath.SimpleNode.childrenAccept(SimpleNode.java:88)
      at org.apache.jackrabbit.core.query.xpath.XPathQueryBuilder.visit(XPathQueryBuilder.java:469)
      at org.apache.jackrabbit.core.query.xpath.SimpleNode.jjtAccept(SimpleNode.java:79)
      at org.apache.jackrabbit.core.query.xpath.SimpleNode.childrenAccept(SimpleNode.java:88)
      at org.apache.jackrabbit.core.query.xpath.XPathQueryBuilder.createPathQueryNode(XPathQueryBuilder.java:612)
      at org.apache.jackrabbit.core.query.xpath.XPathQueryBuilder.visit(XPathQueryBuilder.java:317)
      at org.apache.jackrabbit.core.query.xpath.SimpleNode.jjtAccept(SimpleNode.java:79)
      at org.apache.jackrabbit.core.query.xpath.XPathQueryBuilder.<init>(XPathQueryBuilder.java:244)
      at org.apache.jackrabbit.core.query.xpath.XPathQueryBuilder.createQuery(XPathQueryBuilder.java:275)
      at org.apache.jackrabbit.core.query.xpath.QueryBuilder.createQueryTree(QueryBuilder.java:36)
      at org.apache.jackrabbit.core.query.QueryParser.parse(QueryParser.java:53)
      ...

      P.S. The same result we have on "/jcr:root /( 2, mytype)" XPath query parsing:
      javax.jcr.query.InvalidQueryException: Parse error: data is not a RelationQueryNode
      at org.apache.jackrabbit.core.query.xpath.XPathQueryBuilder.visit(XPathQueryBuilder.java:434)
      at org.apache.jackrabbit.core.query.xpath.SimpleNode.jjtAccept(SimpleNode.java:79)
      at org.apache.jackrabbit.core.query.xpath.SimpleNode.childrenAccept(SimpleNode.java:88)
      at org.apache.jackrabbit.core.query.xpath.XPathQueryBuilder.visit(XPathQueryBuilder.java:469)
      at org.apache.jackrabbit.core.query.xpath.SimpleNode.jjtAccept(SimpleNode.java:79)
      at org.apache.jackrabbit.core.query.xpath.SimpleNode.childrenAccept(SimpleNode.java:88)
      at org.apache.jackrabbit.core.query.xpath.XPathQueryBuilder.visit(XPathQueryBuilder.java:469)
      at org.apache.jackrabbit.core.query.xpath.SimpleNode.jjtAccept(SimpleNode.java:79)
      at org.apache.jackrabbit.core.query.xpath.SimpleNode.childrenAccept(SimpleNode.java:88)
      at org.apache.jackrabbit.core.query.xpath.XPathQueryBuilder.visit(XPathQueryBuilder.java:469)
      at org.apache.jackrabbit.core.query.xpath.SimpleNode.jjtAccept(SimpleNode.java:79)
      at org.apache.jackrabbit.core.query.xpath.SimpleNode.childrenAccept(SimpleNode.java:88)
      at org.apache.jackrabbit.core.query.xpath.XPathQueryBuilder.visit(XPathQueryBuilder.java:469)
      at org.apache.jackrabbit.core.query.xpath.SimpleNode.jjtAccept(SimpleNode.java:79)
      at org.apache.jackrabbit.core.query.xpath.SimpleNode.childrenAccept(SimpleNode.java:88)
      at org.apache.jackrabbit.core.query.xpath.XPathQueryBuilder.visit(XPathQueryBuilder.java:469)
      at org.apache.jackrabbit.core.query.xpath.SimpleNode.jjtAccept(SimpleNode.java:79)
      at org.apache.jackrabbit.core.query.xpath.SimpleNode.childrenAccept(SimpleNode.java:88)
      at org.apache.jackrabbit.core.query.xpath.XPathQueryBuilder.visit(XPathQueryBuilder.java:469)
      at org.apache.jackrabbit.core.query.xpath.SimpleNode.jjtAccept(SimpleNode.java:79)
      at org.apache.jackrabbit.core.query.xpath.SimpleNode.childrenAccept(SimpleNode.java:88)
      at org.apache.jackrabbit.core.query.xpath.XPathQueryBuilder.visit(XPathQueryBuilder.java:469)
      at org.apache.jackrabbit.core.query.xpath.SimpleNode.jjtAccept(SimpleNode.java:79)
      at org.apache.jackrabbit.core.query.xpath.SimpleNode.childrenAccept(SimpleNode.java:88)
      at org.apache.jackrabbit.core.query.xpath.XPathQueryBuilder.visit(XPathQueryBuilder.java:469)
      at org.apache.jackrabbit.core.query.xpath.SimpleNode.jjtAccept(SimpleNode.java:79)
      at org.apache.jackrabbit.core.query.xpath.SimpleNode.childrenAccept(SimpleNode.java:88)
      at org.apache.jackrabbit.core.query.xpath.XPathQueryBuilder.visit(XPathQueryBuilder.java:469)
      at org.apache.jackrabbit.core.query.xpath.SimpleNode.jjtAccept(SimpleNode.java:79)
      at org.apache.jackrabbit.core.query.xpath.SimpleNode.childrenAccept(SimpleNode.java:88)
      at org.apache.jackrabbit.core.query.xpath.XPathQueryBuilder.createPathQueryNode(XPathQueryBuilder.java:612)
      at org.apache.jackrabbit.core.query.xpath.XPathQueryBuilder.visit(XPathQueryBuilder.java:317)
      at org.apache.jackrabbit.core.query.xpath.SimpleNode.jjtAccept(SimpleNode.java:79)
      at org.apache.jackrabbit.core.query.xpath.XPathQueryBuilder.<init>(XPathQueryBuilder.java:244)
      at org.apache.jackrabbit.core.query.xpath.XPathQueryBuilder.createQuery(XPathQueryBuilder.java:275)
      at org.apache.jackrabbit.core.query.xpath.QueryBuilder.createQueryTree(QueryBuilder.java:36)
      at org.apache.jackrabbit.core.query.QueryParser.parse(QueryParser.java:53)
      ...

        Activity

        Hide
        ckiehl Christoph Kiehl added a comment -

        We ran into this problem as well. The problem is that digits are not allowed as a first character of an element name by xml spec (http://www.w3.org/TR/REC-xml-names/#NT-QName). This means you can't create xpath queries for a path that contains an element starting with a digit. But you can execute a sql query on such a path. I think the the JCR spec should have used the same definition for element names as the xml spec.

        Show
        ckiehl Christoph Kiehl added a comment - We ran into this problem as well. The problem is that digits are not allowed as a first character of an element name by xml spec ( http://www.w3.org/TR/REC-xml-names/#NT-QName ). This means you can't create xpath queries for a path that contains an element starting with a digit. But you can execute a sql query on such a path. I think the the JCR spec should have used the same definition for element names as the xml spec.
        Hide
        jukkaz Jukka Zitting added a comment -

        Resolved as Invalid as explained by Christoph.

        Show
        jukkaz Jukka Zitting added a comment - Resolved as Invalid as explained by Christoph.
        Hide
        mreutegg Marcel Reutegger added a comment -

        > This means you can't create xpath queries for a path that contains an element starting with a digit.

        This statement is not correct. It is possible to create xpath queries for such elements. The
        encoding scheme as described section 6.4.3 of the specification must be used.

        e.g. if you have a node named '123', you can query for that node using the following query:

        //_x0031_23

        Show
        mreutegg Marcel Reutegger added a comment - > This means you can't create xpath queries for a path that contains an element starting with a digit. This statement is not correct. It is possible to create xpath queries for such elements. The encoding scheme as described section 6.4.3 of the specification must be used. e.g. if you have a node named '123', you can query for that node using the following query: //_x0031_23
        Hide
        epox_spb Eugene Porubaev added a comment -

        [[ Old comment, sent by email on Mon, 25 Sep 2006 16:45:24 +0400 ]]

        Oh, really it is!
        JSR-170 spec. allows having "digit" names (chapter 4.6),
        but it blocks to access those by XPath (see rule n.13 of 6.6.6"XPath
        Grammar" chapter).
        Don't you still believe in number magic?

        Well, ... have to use sql then (thank you for advice).
        And what about my previous bug report (jcr-578)?

        Thank you anyway for you quick response
        Regargs/eugene.

        Show
        epox_spb Eugene Porubaev added a comment - [[ Old comment, sent by email on Mon, 25 Sep 2006 16:45:24 +0400 ]] Oh, really it is! JSR-170 spec. allows having "digit" names (chapter 4.6), but it blocks to access those by XPath (see rule n.13 of 6.6.6"XPath Grammar" chapter). Don't you still believe in number magic? Well, ... have to use sql then (thank you for advice). And what about my previous bug report (jcr-578)? Thank you anyway for you quick response Regargs/eugene.
        Hide
        mreutegg Marcel Reutegger added a comment -

        > JSR-170 spec. allows having "digit" names (chapter 4.6),
        > but it blocks to access those by XPath (see rule n.13 of 6.6.6"XPath
        > Grammar" chapter).

        As I said before, your statement is not correct. In JCR, an XPath statement
        is executed against a mapping of the JCR nodes and properties to XML elements
        and attributes. It's kind of a virtual XML document.

        If you have a JCR node with a name 123 that node will appear as XML
        element named _x0031_23 for the JCR XPath query.

        There is no syntactic limitation when using XPath in JCR.

        > Well, ... have to use sql then (thank you for advice).

        No, you don't have to

        Show
        mreutegg Marcel Reutegger added a comment - > JSR-170 spec. allows having "digit" names (chapter 4.6), > but it blocks to access those by XPath (see rule n.13 of 6.6.6"XPath > Grammar" chapter). As I said before, your statement is not correct. In JCR, an XPath statement is executed against a mapping of the JCR nodes and properties to XML elements and attributes. It's kind of a virtual XML document. If you have a JCR node with a name 123 that node will appear as XML element named _x0031_23 for the JCR XPath query. There is no syntactic limitation when using XPath in JCR. > Well, ... have to use sql then (thank you for advice). No, you don't have to
        Hide
        ckiehl Christoph Kiehl added a comment -

        Hi Marcel,

        ok, my statement was wrong. But I think it's easier to use SQL because otherwise you probably end up with a lot of places in your code where you have to escape node or property names.

        Show
        ckiehl Christoph Kiehl added a comment - Hi Marcel, ok, my statement was wrong. But I think it's easier to use SQL because otherwise you probably end up with a lot of places in your code where you have to escape node or property names.
        Hide
        mreutegg Marcel Reutegger added a comment -

        Hi Christoph,

        I agree with you. Specifically with jackrabbit where the version storage is exposed with two hex digits for the intermediate nodes to the version history this encoding caused confusion several times already.

        The jackrabbit commons jar file contains an encoding utility that you can use: o.a.j.util.ISO9075. It takes away the pain, but it still itches, I know ...

        Show
        mreutegg Marcel Reutegger added a comment - Hi Christoph, I agree with you. Specifically with jackrabbit where the version storage is exposed with two hex digits for the intermediate nodes to the version history this encoding caused confusion several times already. The jackrabbit commons jar file contains an encoding utility that you can use: o.a.j.util.ISO9075. It takes away the pain, but it still itches, I know ...

          People

          • Assignee:
            jukkaz Jukka Zitting
            Reporter:
            epox_spb Eugene Porubaev
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development