jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r1380251 - in /jackrabbit/oak/trunk/oak-core/src: main/java/org/apache/jackrabbit/oak/query/XPathToSQL2Converter.java test/resources/org/apache/jackrabbit/oak/query/sql2.txt test/resources/org/apache/jackrabbit/oak/query/xpath.txt
Date Mon, 03 Sep 2012 14:36:39 GMT
Author: thomasm
Date: Mon Sep  3 14:36:39 2012
New Revision: 1380251

URL: http://svn.apache.org/viewvc?rev=1380251&view=rev
Log:
OAK-28 Query implementation - improved XPath support (WIP)

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/XPathToSQL2Converter.java
    jackrabbit/oak/trunk/oak-core/src/test/resources/org/apache/jackrabbit/oak/query/sql2.txt
    jackrabbit/oak/trunk/oak-core/src/test/resources/org/apache/jackrabbit/oak/query/xpath.txt

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/XPathToSQL2Converter.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/XPathToSQL2Converter.java?rev=1380251&r1=1380250&r2=1380251&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/XPathToSQL2Converter.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/XPathToSQL2Converter.java
Mon Sep  3 14:36:39 2012
@@ -47,6 +47,8 @@ public class XPathToSQL2Converter {
     private String currentToken;
     private boolean currentTokenQuoted;
     private ArrayList<String> expected;
+    private Selector currentSelector = new Selector();
+    private ArrayList<Selector> selectors = new ArrayList<Selector>();
 
     /**
      * Convert the query to SQL2.
@@ -67,19 +69,38 @@ public class XPathToSQL2Converter {
         initialize(query);
         expected = new ArrayList<String>();
         read();
+
         String path = "";
         String nodeName = null;
         Expression condition = null;
-        String from = "nt:base";
+
+        currentSelector.name = "a";
+        currentSelector.nodeType = "nt:base";
+        selectors.add(currentSelector);
+
         ArrayList<Expression> columnList = new ArrayList<Expression>();
+
+        // queries of the type
+        // jcr:root/*
+        // jcr:root/test/*
+        // jcr:root/element()
+        // jcr:root/element(*)
         boolean children = false;
+
+        // queries of the type
+        // /jcr:root//...
+        // /jcr:root/test//...
+        // /jcr:root[...]
+        // /jcr:root (just by itself)
         boolean descendants = false;
+
         // TODO support one node matcher ('*' wildcard), example:
         // /jcr:root/content/acme/*/jcr:content[@template='/apps/acme']
+
         // TODO verify '//' is behaving correctly, as specified, example:
         // /jcr:root/content/acme//jcr:content[@template='/apps/acme']
+
         while (true) {
-            String nodeType;
             if (readIf("/")) {
                 if (nodeName != null) {
                     throw getSyntaxError("non-path condition");
@@ -106,8 +127,7 @@ public class XPathToSQL2Converter {
                     descendants = false;
                 }
                 if (readIf("*")) {
-                    nodeType = "nt:base";
-                    from = nodeType;
+                    currentSelector.nodeType = "nt:base";
                     children = true;
                 } else if (readIf("text")) {
                     read("(");
@@ -132,11 +152,9 @@ public class XPathToSQL2Converter {
                             path = PathUtils.concat(path, name);
                         }
                         if (readIf(",")) {
-                            nodeType = readIdentifier();
-                            from = nodeType;
+                            currentSelector.nodeType = readIdentifier();
                         } else {
-                            nodeType = "nt:base";
-                            from = nodeType;
+                            currentSelector.nodeType = "nt:base";
                         }
                         read(")");
                     }
@@ -175,23 +193,30 @@ public class XPathToSQL2Converter {
             }
             if (descendants) {
                 Function c = new Function("isdescendantnode");
+                c.params.add(new SelectorExpr(currentSelector));
                 c.params.add(Literal.newString(path));
                 condition = add(condition, c);
             } else if (children) {
-                Function f = new Function("ischildnode");
-                f.params.add(Literal.newString(path));
-                condition = add(condition, f);
+                Function c = new Function("ischildnode");
+                c.params.add(new SelectorExpr(currentSelector));
+                c.params.add(Literal.newString(path));
+                condition = add(condition, c);
             } else {
                 Function c = new Function("issamenode");
+                c.params.add(new SelectorExpr(currentSelector));
                 c.params.add(Literal.newString(path));
                 condition = add(condition, c);
             }
             if (nodeName != null) {
                 Function f = new Function("name");
+                f.params.add(new SelectorExpr(currentSelector));
                 Condition c = new Condition(f, "=", Literal.newString(nodeName));
                 condition = add(condition, c);
             }
         }
+        if (selectors.size() == 1) {
+            currentSelector.onlySelector = true;
+        }
         ArrayList<Order> orderList = new ArrayList<Order>();
         if (readIf("order")) {
             read("by");
@@ -214,19 +239,29 @@ public class XPathToSQL2Converter {
             buff.append("explain ");
         }
         buff.append("select ");
-        buff.append("[jcr:path], [jcr:score], ");
+        buff.append(new Property(currentSelector, "jcr:path").toString());
+        buff.append(", ");
+        buff.append(new Property(currentSelector, "jcr:score").toString());
         if (columnList.isEmpty()) {
-            buff.append('*');
+            buff.append(", ");
+            buff.append(new Property(currentSelector, "*").toString());
         } else {
             for (int i = 0; i < columnList.size(); i++) {
-                if (i > 0) {
-                    buff.append(", ");
-                }
+                buff.append(", ");
                 buff.append(columnList.get(i).toString());
             }
         }
         buff.append(" from ");
-        buff.append('[' + from + ']');
+        for (int i = 0; i < selectors.size(); i++) {
+            Selector s = selectors.get(i);
+            if (i > 0) {
+                buff.append(" inner join ");
+            }
+            buff.append('[' + s.nodeType + ']').append(" as ").append(s.name);
+            if (s.joinCondition != null) {
+                buff.append(" on ").append(s.joinCondition);
+            }
+        }
         if (condition != null) {
             buff.append(" where ").append(removeParens(condition.toString()));
         }
@@ -267,7 +302,7 @@ public class XPathToSQL2Converter {
 
     private Expression parseCondition() throws ParseException {
         Expression a;
-        if (readIf("not")) {
+        if (readIf("fn:not") || readIf("not")) {
             read("(");
             a = parseConstraint();
             if (a instanceof Condition && ((Condition) a).operator.equals("is not
null")) {
@@ -372,7 +407,7 @@ public class XPathToSQL2Converter {
                 } else {
                     buff.append(readIdentifier());
                 }
-                return new Property(buff.toString());
+                return new Property(currentSelector, buff.toString());
             } else {
                 break;
             }
@@ -393,7 +428,7 @@ public class XPathToSQL2Converter {
             } else {
                 buff.append("/*");
             }
-            return new Property(buff.toString());
+            return new Property(currentSelector, buff.toString());
         }
         throw getSyntaxError();
     }
@@ -414,7 +449,7 @@ public class XPathToSQL2Converter {
             return f;
         } else if ("jcr:score".equals(functionName)) {
             Function f = new Function("score");
-            // TODO score: support parameters?
+            f.params.add(new SelectorExpr(currentSelector));
             read(")");
             return f;
         } else if ("xs:dateTime".equals(functionName)) {
@@ -434,16 +469,17 @@ public class XPathToSQL2Converter {
                 read(".");
                 read(")");
             }
+            f.params.add(new SelectorExpr(currentSelector));
             return f;
         } else if ("fn:upper-case".equals(functionName)) {
             Function f = new Function("upper");
             f.params.add(parseExpression());
             read(")");
             return f;
-         } else if ("jcr:deref".equals(functionName)) {
+        } else if ("jcr:deref".equals(functionName)) {
              // TODO support jcr:deref
              throw getSyntaxError("jcr:deref is not supported");
-         } else if ("rep:similar".equals(functionName)) {
+        } else if ("rep:similar".equals(functionName)) {
              // TODO support rep:similar
              throw getSyntaxError("rep:similar is not supported");
         } else {
@@ -477,9 +513,9 @@ public class XPathToSQL2Converter {
 
     private Property readProperty() throws ParseException {
         if (readIf("*")) {
-            return new Property("*");
+            return new Property(currentSelector, "*");
         }
-        return new Property(readIdentifier());
+        return new Property(currentSelector, readIdentifier());
     }
 
     private String readIdentifier() throws ParseException {
@@ -789,6 +825,18 @@ public class XPathToSQL2Converter {
     }
 
     /**
+     * A selector.
+     */
+    static class Selector {
+
+        String name;
+        boolean onlySelector;
+        String nodeType;
+        Expression joinCondition;
+
+    }
+
+    /**
      * An expression.
      */
     abstract static class Expression {
@@ -800,6 +848,24 @@ public class XPathToSQL2Converter {
     }
 
     /**
+     * A selector parameter.
+     */
+    static class SelectorExpr extends Expression {
+
+        private final Selector selector;
+
+        SelectorExpr(Selector selector) {
+            this.selector = selector;
+        }
+
+        @Override
+        public String toString() {
+            return selector.name;
+        }
+
+    }
+
+    /**
      * A literal expression.
      */
     static class Literal extends Expression {
@@ -834,18 +900,26 @@ public class XPathToSQL2Converter {
      */
     static class Property extends Expression {
 
+        final Selector selector;
         final String name;
 
-        Property(String name) {
+        Property(Selector selector, String name) {
+            this.selector = selector;
             this.name = name;
         }
 
         @Override
         public String toString() {
+            StringBuilder buff = new StringBuilder();
+            if (!selector.onlySelector) {
+                buff.append(selector.name).append('.');
+            }
             if (name.equals("*")) {
-                return name;
+                buff.append('*');
+            } else {
+                buff.append('[').append(name).append(']');
             }
-            return '[' + name + ']';
+            return buff.toString();
         }
 
     }

Modified: jackrabbit/oak/trunk/oak-core/src/test/resources/org/apache/jackrabbit/oak/query/sql2.txt
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/resources/org/apache/jackrabbit/oak/query/sql2.txt?rev=1380251&r1=1380250&r2=1380251&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/resources/org/apache/jackrabbit/oak/query/sql2.txt
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/resources/org/apache/jackrabbit/oak/query/sql2.txt
Mon Sep  3 14:36:39 2012
@@ -326,6 +326,9 @@ select * from [nt:base] where [c1/p] = '
 select * from [nt:base] as p where p.[jcr:path] = '/parents'
 /parents
 
+select * from [nt:base] as [p] where [p].[jcr:path] = '/parents'
+/parents
+
 select * from [nt:base] as p inner join [nt:base] as p2 on ischildnode(p2, p) where p.[jcr:path]
= '/'
 /, /children
 /, /jcr:system

Modified: jackrabbit/oak/trunk/oak-core/src/test/resources/org/apache/jackrabbit/oak/query/xpath.txt
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/resources/org/apache/jackrabbit/oak/query/xpath.txt?rev=1380251&r1=1380250&r2=1380251&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/resources/org/apache/jackrabbit/oak/query/xpath.txt
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/resources/org/apache/jackrabbit/oak/query/xpath.txt
Mon Sep  3 14:36:39 2012
@@ -25,32 +25,38 @@
 
 # jackrabbit test queries
 
+# xpath2sql //testRoot/*[@text = 'foo']
+# select b.[jcr:path], b.[jcr:score], b.* from [nt:base] as a inner join [nt:base] as
b on ischildnode(b, a) where name(a) = 'testRoot' and b.[text] = 'foo'
+
+xpath2sql /testRoot/*[@jcr:primaryType='nt:unstructured' and fn:not(@mytext)]
+select [jcr:path], [jcr:score], * from [nt:base] as a where (([jcr:primaryType] = 'nt:unstructured')
and ([mytext] is null)) and ischildnode(a, '/testRoot')
+
 xpath2sql /jcr:root/testroot/*[jcr:contains(., '"quick brown" -cat')]
-select [jcr:path], [jcr:score], * from [nt:base] where contains(*, '"quick brown" -cat')
and ischildnode('/testroot')
+select [jcr:path], [jcr:score], * from [nt:base] as a where contains(*, '"quick brown" -cat')
and ischildnode(a, '/testroot')
 
 xpath2sql //element(*,rep:Authorizable)[(((jcr:contains(profile/givenName,'**') or jcr:contains(profile/familyName,'**'))
or jcr:contains(profile/email,'**')) or (jcr:like(rep:principalName,'%%') or jcr:like(fn:name(.),'%%')))]
order by rep:principalName ascending
-select [jcr:path], [jcr:score], * from [rep:Authorizable] where ((contains([profile/givenName/*],
'**') or contains([profile/familyName/*], '**')) or contains([profile/email/*], '**')) or
(([rep:principalName/*] like '%%') or (name() like '%%')) order by [rep:principalName/*]
+select [jcr:path], [jcr:score], * from [rep:Authorizable] as a where ((contains([profile/givenName/*],
'**') or contains([profile/familyName/*], '**')) or contains([profile/email/*], '**')) or
(([rep:principalName/*] like '%%') or (name(a) like '%%')) order by [rep:principalName/*]
 
 xpath2sql //element(*,rep:Authorizable)[(((jcr:contains(profile/@givenName,'**') or jcr:contains(profile/@familyName,'**'))
or jcr:contains(profile/@email,'**')) or (jcr:like(@rep:principalName,'%%') or jcr:like(fn:name(.),'%%')))]
order by @rep:principalName ascending
-select [jcr:path], [jcr:score], * from [rep:Authorizable] where ((contains([profile/givenName],
'**') or contains([profile/familyName], '**')) or contains([profile/email], '**')) or (([rep:principalName]
like '%%') or (name() like '%%')) order by [rep:principalName]
+select [jcr:path], [jcr:score], * from [rep:Authorizable] as a where ((contains([profile/givenName],
'**') or contains([profile/familyName], '**')) or contains([profile/email], '**')) or (([rep:principalName]
like '%%') or (name(a) like '%%')) order by [rep:principalName]
 
 xpath2sql /jcr:root/testroot//*[jcr:contains(@jcr:data, 'lazy')]
-select [jcr:path], [jcr:score], * from [nt:base] where contains([jcr:data], 'lazy') and isdescendantnode('/testroot')
+select [jcr:path], [jcr:score], * from [nt:base] as a where contains([jcr:data], 'lazy')
and isdescendantnode(a, '/testroot')
 
 xpath2sql /jcr:root/testroot/*[jcr:contains(jcr:content, 'lazy')]
-select [jcr:path], [jcr:score], * from [nt:base] where contains([jcr:content/*], 'lazy')
and ischildnode('/testroot')
+select [jcr:path], [jcr:score], * from [nt:base] as a where contains([jcr:content/*], 'lazy')
and ischildnode(a, '/testroot')
 
 xpath2sql /jcr:root/testroot/*[jcr:contains(*, 'lazy')]
-select [jcr:path], [jcr:score], * from [nt:base] where contains([*/*], 'lazy') and ischildnode('/testroot')
+select [jcr:path], [jcr:score], * from [nt:base] as a where contains([*/*], 'lazy') and ischildnode(a,
'/testroot')
 
 xpath2sql /jcr:root/testroot/*[jcr:contains(*/@jcr:data, 'lazy')]
-select [jcr:path], [jcr:score], * from [nt:base] where contains([*/jcr:data], 'lazy') and
ischildnode('/testroot')
+select [jcr:path], [jcr:score], * from [nt:base] as a where contains([*/jcr:data], 'lazy')
and ischildnode(a, '/testroot')
 
 xpath2sql /jcr:root/testroot/*[jcr:contains(*/@*, 'lazy')]
-select [jcr:path], [jcr:score], * from [nt:base] where contains([*/*], 'lazy') and ischildnode('/testroot')
+select [jcr:path], [jcr:score], * from [nt:base] as a where contains([*/*], 'lazy') and ischildnode(a,
'/testroot')
 
 xpath2sql /jcr:root/testroot/*[@prop1 = 1 and jcr:like(fn:name(), 'F%')]
-select [jcr:path], [jcr:score], * from [nt:base] where (([prop1] = 1) and (name() like 'F%'))
and ischildnode('/testroot')
+select [jcr:path], [jcr:score], * from [nt:base] as a where (([prop1] = 1) and (name(a) like
'F%')) and ischildnode(a, '/testroot')
 
 # TODO support rep:excerpt() and rep:similar()? how?
 xpath2sql /jcr:root/testroot/*[jcr:contains(., 'jackrabbit')]/rep:excerpt(.)
@@ -66,228 +72,228 @@ xpath2sql /jcr:root/testroot/people/jcr:
 invalid: Query: /jcr:root/testroot/people/jcr:deref((*)@worksfor, '*'); expected: <end>
 
 xpath2sql /jcr:root[@foo = 'does-not-exist']
-select [jcr:path], [jcr:score], * from [nt:base] where ([foo] = 'does-not-exist') and isdescendantnode('/')
+select [jcr:path], [jcr:score], * from [nt:base] as a where ([foo] = 'does-not-exist') and
isdescendantnode(a, '/')
 
 xpath2sql //*[@jcr:primaryType='nt:unstructured' and jcr:like(@foo,"%ar'ba%")]
-select [jcr:path], [jcr:score], * from [nt:base] where ([jcr:primaryType] = 'nt:unstructured')
and ([foo] like '%ar''ba%')
+select [jcr:path], [jcr:score], * from [nt:base] as a where ([jcr:primaryType] = 'nt:unstructured')
and ([foo] like '%ar''ba%')
 
 xpath2sql /jcr:root/testroot/*[fn:lower-case(@prop1) = 'foo']
-select [jcr:path], [jcr:score], * from [nt:base] where (lower([prop1]) = 'foo') and ischildnode('/testroot')
+select [jcr:path], [jcr:score], * from [nt:base] as a where (lower([prop1]) = 'foo') and
ischildnode(a, '/testroot')
 
 xpath2sql /jcr:root/testroot/*[fn:lower-case(@prop1) != 'foo']
-select [jcr:path], [jcr:score], * from [nt:base] where (lower([prop1]) <> 'foo') and
ischildnode('/testroot')
+select [jcr:path], [jcr:score], * from [nt:base] as a where (lower([prop1]) <> 'foo')
and ischildnode(a, '/testroot')
 
 xpath2sql /jcr:root/testroot/*[fn:lower-case(@prop1) <= 'foo']
-select [jcr:path], [jcr:score], * from [nt:base] where (lower([prop1]) <= 'foo') and ischildnode('/testroot')
+select [jcr:path], [jcr:score], * from [nt:base] as a where (lower([prop1]) <= 'foo')
and ischildnode(a, '/testroot')
 
 xpath2sql /jcr:root/testroot/*[fn:lower-case(@prop1) >= 'foo']
-select [jcr:path], [jcr:score], * from [nt:base] where (lower([prop1]) >= 'foo') and ischildnode('/testroot')
+select [jcr:path], [jcr:score], * from [nt:base] as a where (lower([prop1]) >= 'foo')
and ischildnode(a, '/testroot')
 
 xpath2sql /jcr:root/testroot/*[fn:lower-case(@prop1) < 'foo']
-select [jcr:path], [jcr:score], * from [nt:base] where (lower([prop1]) < 'foo') and ischildnode('/testroot')
+select [jcr:path], [jcr:score], * from [nt:base] as a where (lower([prop1]) < 'foo') and
ischildnode(a, '/testroot')
 
 xpath2sql /jcr:root/testroot/*[fn:lower-case(@prop1) > 'foo']
-select [jcr:path], [jcr:score], * from [nt:base] where (lower([prop1]) > 'foo') and ischildnode('/testroot')
+select [jcr:path], [jcr:score], * from [nt:base] as a where (lower([prop1]) > 'foo') and
ischildnode(a, '/testroot')
 
 xpath2sql /jcr:root/testroot/*[fn:lower-case(@prop1) <> 'foo']
-select [jcr:path], [jcr:score], * from [nt:base] where (lower([prop1]) <> 'foo') and
ischildnode('/testroot')
+select [jcr:path], [jcr:score], * from [nt:base] as a where (lower([prop1]) <> 'foo')
and ischildnode(a, '/testroot')
 
 xpath2sql /jcr:root/testroot/*[@prop1 = 1 and fn:name() = 'node1']
-select [jcr:path], [jcr:score], * from [nt:base] where (([prop1] = 1) and (name() = 'node1'))
and ischildnode('/testroot')
+select [jcr:path], [jcr:score], * from [nt:base] as a where (([prop1] = 1) and (name(a) =
'node1')) and ischildnode(a, '/testroot')
 
 # sling queries
 
 xpath2sql //element(*,mix:language)[fn:lower-case(@jcr:language)='en']//element(*,sling:Message)[@sling:message]/(@sling:key|@sling:message)
-select [jcr:path], [jcr:score], [sling:key], [sling:message] from [sling:Message] where (lower([jcr:language])
= 'en') and ([sling:message] is not null)
+select [jcr:path], [jcr:score], [sling:key], [sling:message] from [sling:Message] as a where
(lower([jcr:language]) = 'en') and ([sling:message] is not null)
 
 xpath2sql //element(*,mix:language)[fn:upper-case(@jcr:language)='en']//element(*,sling:Message)[@sling:message]/(@sling:key|@sling:message)
-select [jcr:path], [jcr:score], [sling:key], [sling:message] from [sling:Message] where (upper([jcr:language])
= 'en') and ([sling:message] is not null)
+select [jcr:path], [jcr:score], [sling:key], [sling:message] from [sling:Message] as a where
(upper([jcr:language]) = 'en') and ([sling:message] is not null)
 
 # jboss example queries
 
 xpath2sql //*
-select [jcr:path], [jcr:score], * from [nt:base]
+select [jcr:path], [jcr:score], * from [nt:base] as a
 
 xpath2sql //element(*,my:type)
-select [jcr:path], [jcr:score], * from [my:type]
+select [jcr:path], [jcr:score], * from [my:type] as a
 
 xpath2sql //element(*,my:type)/@my:title
-select [jcr:path], [jcr:score], [my:title] from [my:type]
+select [jcr:path], [jcr:score], [my:title] from [my:type] as a
 
 xpath2sql //element(*,my:type)/(@my:title | @my:text)
-select [jcr:path], [jcr:score], [my:title], [my:text] from [my:type]
+select [jcr:path], [jcr:score], [my:title], [my:text] from [my:type] as a
 
 # other queries
 
 xpath2sql /jcr:root/testdata/node[@jcr:primaryType]
-select [jcr:path], [jcr:score], * from [nt:base] where ([jcr:primaryType] is not null) and
issamenode('/testdata/node')
+select [jcr:path], [jcr:score], * from [nt:base] as a where ([jcr:primaryType] is not null)
and issamenode(a, '/testdata/node')
 
 xpath2sql //testroot/*[@jcr:primaryType='nt:unstructured'] order by @prop2, @prop1
 invalid: Query: //testroot/*(*)[@jcr:primaryType='nt:unstructured'] order by @prop2, @prop1;
expected: non-path condition
 
 xpath2sql /jcr:root/test//jcr:xmltext
-select [jcr:path], [jcr:score], * from [nt:base] where isdescendantnode('/test') and (name()
= 'jcr:xmltext')
+select [jcr:path], [jcr:score], * from [nt:base] as a where isdescendantnode(a, '/test')
and (name(a) = 'jcr:xmltext')
 
 xpath2sql /jcr:root/test//text()
-select [jcr:path], [jcr:score], * from [nt:base] where isdescendantnode('/test') and (name()
= 'jcr:xmltext')
+select [jcr:path], [jcr:score], * from [nt:base] as a where isdescendantnode(a, '/test')
and (name(a) = 'jcr:xmltext')
 
 xpath2sql /jcr:root/test/jcr:xmltext
-select [jcr:path], [jcr:score], * from [nt:base] where issamenode('/test/jcr:xmltext')
+select [jcr:path], [jcr:score], * from [nt:base] as a where issamenode(a, '/test/jcr:xmltext')
 
 xpath2sql /jcr:root/test/text()
-select [jcr:path], [jcr:score], * from [nt:base] where issamenode('/test/jcr:xmltext')
+select [jcr:path], [jcr:score], * from [nt:base] as a where issamenode(a, '/test/jcr:xmltext')
 
 xpath2sql /jcr:root
-select [jcr:path], [jcr:score], * from [nt:base] where isdescendantnode('/')
+select [jcr:path], [jcr:score], * from [nt:base] as a where isdescendantnode(a, '/')
 
 xpath2sql //*[@name='Hello']
-select [jcr:path], [jcr:score], * from [nt:base] where [name] = 'Hello'
+select [jcr:path], [jcr:score], * from [nt:base] as a where [name] = 'Hello'
 
 xpath2sql /jcr:root//*[@name='Hello']
-select [jcr:path], [jcr:score], * from [nt:base] where ([name] = 'Hello') and isdescendantnode('/')
+select [jcr:path], [jcr:score], * from [nt:base] as a where ([name] = 'Hello') and isdescendantnode(a,
'/')
 
 xpath2sql content/*
-select [jcr:path], [jcr:score], * from [nt:base] where ischildnode('/content')
+select [jcr:path], [jcr:score], * from [nt:base] as a where ischildnode(a, '/content')
 
 xpath2sql content//*
-select [jcr:path], [jcr:score], * from [nt:base] where isdescendantnode('/content')
+select [jcr:path], [jcr:score], * from [nt:base] as a where isdescendantnode(a, '/content')
 
 xpath2sql content//*[@name='Hello']
-select [jcr:path], [jcr:score], * from [nt:base] where ([name] = 'Hello') and isdescendantnode('/content')
+select [jcr:path], [jcr:score], * from [nt:base] as a where ([name] = 'Hello') and isdescendantnode(a,
'/content')
 
 xpath2sql /jcr:root/content//*[@name='Hello']
-select [jcr:path], [jcr:score], * from [nt:base] where ([name] = 'Hello') and isdescendantnode('/content')
+select [jcr:path], [jcr:score], * from [nt:base] as a where ([name] = 'Hello') and isdescendantnode(a,
'/content')
 
 xpath2sql //*[jcr:contains(., 'test')] order by @jcr:score
-select [jcr:path], [jcr:score], * from [nt:base] where contains(*, 'test') order by [jcr:score]
+select [jcr:path], [jcr:score], * from [nt:base] as a where contains(*, 'test') order by
[jcr:score]
 
 xpath2sql /jcr:root//*[jcr:contains(., 'test')] order by @jcr:score
-select [jcr:path], [jcr:score], * from [nt:base] where contains(*, 'test') and isdescendantnode('/')
order by [jcr:score]
+select [jcr:path], [jcr:score], * from [nt:base] as a where contains(*, 'test') and isdescendantnode(a,
'/') order by [jcr:score]
 
 xpath2sql /jcr:root//element(*, test)
-select [jcr:path], [jcr:score], * from [test] where isdescendantnode('/')
+select [jcr:path], [jcr:score], * from [test] as a where isdescendantnode(a, '/')
 
 xpath2sql /jcr:root//element(*, user)[test/@jcr:primaryType]
-select [jcr:path], [jcr:score], * from [user] where ([test/jcr:primaryType] is not null)
and isdescendantnode('/')
+select [jcr:path], [jcr:score], * from [user] as a where ([test/jcr:primaryType] is not null)
and isdescendantnode(a, '/')
 
 xpath2sql /jcr:root/content//*[(@sling:resourceType = 'start')]
-select [jcr:path], [jcr:score], * from [nt:base] where ([sling:resourceType] = 'start') and
isdescendantnode('/content')
+select [jcr:path], [jcr:score], * from [nt:base] as a where ([sling:resourceType] = 'start')
and isdescendantnode(a, '/content')
 
 xpath2sql /jcr:root/content//*[(@sling:resourceType = 'page')]
-select [jcr:path], [jcr:score], * from [nt:base] where ([sling:resourceType] = 'page') and
isdescendantnode('/content')
+select [jcr:path], [jcr:score], * from [nt:base] as a where ([sling:resourceType] = 'page')
and isdescendantnode(a, '/content')
 
 xpath2sql /jcr:root/content//*[@offTime > xs:dateTime('2012-03-28T15:56:18.327+02:00')
or @onTime > xs:dateTime('2012-03-28T15:56:18.327+02:00')]
-select [jcr:path], [jcr:score], * from [nt:base] where (([offTime] > cast('2012-03-28T15:56:18.327+02:00'
as date)) or ([onTime] > cast('2012-03-28T15:56:18.327+02:00' as date))) and isdescendantnode('/content')
+select [jcr:path], [jcr:score], * from [nt:base] as a where (([offTime] > cast('2012-03-28T15:56:18.327+02:00'
as date)) or ([onTime] > cast('2012-03-28T15:56:18.327+02:00' as date))) and isdescendantnode(a,
'/content')
 
 xpath2sql /jcr:root/content/campaigns//*[@jcr:primaryType='Page'] order by jcr:content/@lastModified
descending
-select [jcr:path], [jcr:score], * from [nt:base] where ([jcr:primaryType] = 'Page') and isdescendantnode('/content/campaigns')
order by [jcr:content/lastModified] desc
+select [jcr:path], [jcr:score], * from [nt:base] as a where ([jcr:primaryType] = 'Page')
and isdescendantnode(a, '/content/campaigns') order by [jcr:content/lastModified] desc
 
 xpath2sql /jcr:root/content/campaigns//element(*, PageContent)[(@sling:resourceType = 'teaser'
or @sling:resourceType = 'newsletter' or @teaserPageType = 'newsletter' or @teaserPageType
= 'tweet') and ((@onTime < xs:dateTime('2012-04-01T00:00:00.000+02:00')) or not(@onTime))
and ((@offTime >= xs:dateTime('2012-02-26T00:00:00.000+01:00')) or not(@offTime))] order
by @onTime
-select [jcr:path], [jcr:score], * from [PageContent] where (((((([sling:resourceType] = 'teaser')
or ([sling:resourceType] = 'newsletter')) or ([teaserPageType] = 'newsletter')) or ([teaserPageType]
= 'tweet')) and (([onTime] < cast('2012-04-01T00:00:00.000+02:00' as date)) or ([onTime]
is null))) and (([offTime] >= cast('2012-02-26T00:00:00.000+01:00' as date)) or ([offTime]
is null))) and isdescendantnode('/content/campaigns') order by [onTime]
+select [jcr:path], [jcr:score], * from [PageContent] as a where (((((([sling:resourceType]
= 'teaser') or ([sling:resourceType] = 'newsletter')) or ([teaserPageType] = 'newsletter'))
or ([teaserPageType] = 'tweet')) and (([onTime] < cast('2012-04-01T00:00:00.000+02:00'
as date)) or ([onTime] is null))) and (([offTime] >= cast('2012-02-26T00:00:00.000+01:00'
as date)) or ([offTime] is null))) and isdescendantnode(a, '/content/campaigns') order by
[onTime]
 
 xpath2sql /jcr:root/content/dam//element(*, asset)
-select [jcr:path], [jcr:score], * from [asset] where isdescendantnode('/content/dam')
+select [jcr:path], [jcr:score], * from [asset] as a where isdescendantnode(a, '/content/dam')
 
 xpath2sql /jcr:root/content/dam//element(*, asset)[jcr:content/metadata/@dam:scene]
-select [jcr:path], [jcr:score], * from [asset] where ([jcr:content/metadata/dam:scene] is
not null) and isdescendantnode('/content/dam')
+select [jcr:path], [jcr:score], * from [asset] as a where ([jcr:content/metadata/dam:scene]
is not null) and isdescendantnode(a, '/content/dam')
 
 xpath2sql /jcr:root/etc/cloud//*[(@sling:resourceType = 'framework')]
-select [jcr:path], [jcr:score], * from [nt:base] where ([sling:resourceType] = 'framework')
and isdescendantnode('/etc/cloud')
+select [jcr:path], [jcr:score], * from [nt:base] as a where ([sling:resourceType] = 'framework')
and isdescendantnode(a, '/etc/cloud')
 
 xpath2sql /jcr:root/etc/cloud//*[(@sling:resourceType = 'analytics')]
-select [jcr:path], [jcr:score], * from [nt:base] where ([sling:resourceType] = 'analytics')
and isdescendantnode('/etc/cloud')
+select [jcr:path], [jcr:score], * from [nt:base] as a where ([sling:resourceType] = 'analytics')
and isdescendantnode(a, '/etc/cloud')
 
 xpath2sql /jcr:root/etc/reports//*[@jcr:primaryType='Page'] order by jcr:content/@lastModified
descending
-select [jcr:path], [jcr:score], * from [nt:base] where ([jcr:primaryType] = 'Page') and isdescendantnode('/etc/reports')
order by [jcr:content/lastModified] desc
+select [jcr:path], [jcr:score], * from [nt:base] as a where ([jcr:primaryType] = 'Page')
and isdescendantnode(a, '/etc/reports') order by [jcr:content/lastModified] desc
 
 xpath2sql /jcr:root/etc/segment//*[@jcr:primaryType='Page'] order by jcr:content/@lastModified
descending
-select [jcr:path], [jcr:score], * from [nt:base] where ([jcr:primaryType] = 'Page') and isdescendantnode('/etc/segment')
order by [jcr:content/lastModified] desc
+select [jcr:path], [jcr:score], * from [nt:base] as a where ([jcr:primaryType] = 'Page')
and isdescendantnode(a, '/etc/segment') order by [jcr:content/lastModified] desc
 
 xpath2sql /jcr:root/etc/workflow//element(*,Item)[not(meta/@archived) and not(meta/@archived
= true)]
-select [jcr:path], [jcr:score], * from [Item] where (([meta/archived] is null) and not([meta/archived]
= true)) and isdescendantnode('/etc/workflow')
+select [jcr:path], [jcr:score], * from [Item] as a where (([meta/archived] is null) and not([meta/archived]
= true)) and isdescendantnode(a, '/etc/workflow')
 
 xpath2sql /jcr:root/home//element()
-select [jcr:path], [jcr:score], * from [nt:base] where isdescendantnode('/home')
+select [jcr:path], [jcr:score], * from [nt:base] as a where isdescendantnode(a, '/home')
 
 xpath2sql /jcr:root/home//element(*)
-select [jcr:path], [jcr:score], * from [nt:base] where isdescendantnode('/home')
+select [jcr:path], [jcr:score], * from [nt:base] as a where isdescendantnode(a, '/home')
 
 # other queries
 
 xpath2sql //*
-select [jcr:path], [jcr:score], * from [nt:base]
+select [jcr:path], [jcr:score], * from [nt:base] as a
 
 xpath2sql //element(*, my:type)
-select [jcr:path], [jcr:score], * from [my:type]
+select [jcr:path], [jcr:score], * from [my:type] as a
 
 xpath2sql //element(*, my:type)/@my:title
-select [jcr:path], [jcr:score], [my:title] from [my:type]
+select [jcr:path], [jcr:score], [my:title] from [my:type] as a
 
 xpath2sql //element(*, my:type)/(@my:title | @my:text)
-select [jcr:path], [jcr:score], [my:title], [my:text] from [my:type]
+select [jcr:path], [jcr:score], [my:title], [my:text] from [my:type] as a
 
 xpath2sql /jcr:root/nodes//element(*, my:type)
-select [jcr:path], [jcr:score], * from [my:type] where isdescendantnode('/nodes')
+select [jcr:path], [jcr:score], * from [my:type] as a where isdescendantnode(a, '/nodes')
 
 xpath2sql /jcr:root/some/element(nodes, my:type)
-select [jcr:path], [jcr:score], * from [my:type] where issamenode('/some/nodes')
+select [jcr:path], [jcr:score], * from [my:type] as a where issamenode(a, '/some/nodes')
 
 xpath2sql /jcr:root/some/nodes/element(*, my:type)
-select [jcr:path], [jcr:score], * from [my:type] where ischildnode('/some/nodes')
+select [jcr:path], [jcr:score], * from [my:type] as a where ischildnode(a, '/some/nodes')
 
 xpath2sql /jcr:root/some/nodes//element(*, my:type)
-select [jcr:path], [jcr:score], * from [my:type] where isdescendantnode('/some/nodes')
+select [jcr:path], [jcr:score], * from [my:type] as a where isdescendantnode(a, '/some/nodes')
 
 xpath2sql //element(*, my:type)[@my:title = 'JSR 170']
-select [jcr:path], [jcr:score], * from [my:type] where [my:title] = 'JSR 170'
+select [jcr:path], [jcr:score], * from [my:type] as a where [my:title] = 'JSR 170'
 
 xpath2sql //element(*, my:type)[jcr:like(@title,'%Java%')]
-select [jcr:path], [jcr:score], * from [my:type] where [title] like '%Java%'
+select [jcr:path], [jcr:score], * from [my:type] as a where [title] like '%Java%'
 
 xpath2sql //element(*, my:type)[jcr:contains(., 'JSR 170')]
-select [jcr:path], [jcr:score], * from [my:type] where contains(*, 'JSR 170')
+select [jcr:path], [jcr:score], * from [my:type] as a where contains(*, 'JSR 170')
 
 xpath2sql //element(*, my:type)[@my:title]
-select [jcr:path], [jcr:score], * from [my:type] where [my:title] is not null
+select [jcr:path], [jcr:score], * from [my:type] as a where [my:title] is not null
 
 xpath2sql //element(*, my:type)[not(@my:title)]
-select [jcr:path], [jcr:score], * from [my:type] where [my:title] is null
+select [jcr:path], [jcr:score], * from [my:type] as a where [my:title] is null
 
 xpath2sql //element(*, my:type)[@my:value < -1.0]
-select [jcr:path], [jcr:score], * from [my:type] where [my:value] < -1.0
+select [jcr:path], [jcr:score], * from [my:type] as a where [my:value] < -1.0
 
 xpath2sql //element(*, my:type)[@my:value > +10123123123]
-select [jcr:path], [jcr:score], * from [my:type] where [my:value] > 10123123123
+select [jcr:path], [jcr:score], * from [my:type] as a where [my:value] > 10123123123
 
 xpath2sql //element(*, my:type)[@my:value <= 10.3e-3]
-select [jcr:path], [jcr:score], * from [my:type] where [my:value] <= 10.3e-3
+select [jcr:path], [jcr:score], * from [my:type] as a where [my:value] <= 10.3e-3
 
 xpath2sql //element(*, my:type)[@my:value >= 0e3]
-select [jcr:path], [jcr:score], * from [my:type] where [my:value] >= 0e3
+select [jcr:path], [jcr:score], * from [my:type] as a where [my:value] >= 0e3
 
 xpath2sql //element(*, my:type)[@my:value <> 'Joe''s Caffee']
-select [jcr:path], [jcr:score], * from [my:type] where [my:value] <> 'Joe''s Caffee'
+select [jcr:path], [jcr:score], * from [my:type] as a where [my:value] <> 'Joe''s Caffee'
 
 xpath2sql //element(*, my:type)[(not(@my:title) and @my:subject)]
-select [jcr:path], [jcr:score], * from [my:type] where ([my:title] is null) and ([my:subject]
is not null)
+select [jcr:path], [jcr:score], * from [my:type] as a where ([my:title] is null) and ([my:subject]
is not null)
 
 xpath2sql //element(*, my:type)[not(@my:title) or @my:subject]
-select [jcr:path], [jcr:score], * from [my:type] where ([my:title] is null) or ([my:subject]
is not null)
+select [jcr:path], [jcr:score], * from [my:type] as a where ([my:title] is null) or ([my:subject]
is not null)
 
 xpath2sql //element(*, my:type)[not(@my:value > 0 and @my:value < 100)]
-select [jcr:path], [jcr:score], * from [my:type] where not(([my:value] > 0) and ([my:value]
< 100))
+select [jcr:path], [jcr:score], * from [my:type] as a where not(([my:value] > 0) and ([my:value]
< 100))
 
 xpath2sql //element(*, my:type) order by @jcr:lastModified
-select [jcr:path], [jcr:score], * from [my:type] order by [jcr:lastModified]
+select [jcr:path], [jcr:score], * from [my:type] as a order by [jcr:lastModified]
 
 xpath2sql //element(*, my:type) order by @my:date descending, @my:title ascending
-select [jcr:path], [jcr:score], * from [my:type] order by [my:date] desc, [my:title]
+select [jcr:path], [jcr:score], * from [my:type] as a order by [my:date] desc, [my:title]
 
 xpath2sql //element(*, my:type)[jcr:contains(., 'jcr')] order by jcr:score() descending
-select [jcr:path], [jcr:score], * from [my:type] where contains(*, 'jcr') order by score()
desc
+select [jcr:path], [jcr:score], * from [my:type] as a where contains(*, 'jcr') order by score(a)
desc
 
 xpath2sql //element(*, my:type)[jcr:contains(@my:title, 'jcr')] order by jcr:score() descending
-select [jcr:path], [jcr:score], * from [my:type] where contains([my:title], 'jcr') order
by score() desc
+select [jcr:path], [jcr:score], * from [my:type] as a where contains([my:title], 'jcr') order
by score(a) desc
 
 xpath2sql [invalid/query
 invalid: Query: /jcr:root/[(*)invalid/query; expected: identifier
@@ -311,7 +317,7 @@ xpath2sql //element(*, my:type)[jcr:stri
 invalid: Query: //element(*, my:type)[jcr:strike(@(*)title,'%Java%')]; expected: jcr:like
| jcr:contains | jcr:score | jcr:deref | fn:lower-case | fn:upper-case
 
 xpath2sql //element(*, my:type)[
-invalid: Query: //element(*, my:type)(*)[; expected: not, (, @, true, false, -, +, *, .,
@, (
+invalid: Query: //element(*, my:type)(*)[; expected: fn:not, not, (, @, true, false, -, +,
*, ., @, (
 
 xpath2sql //element(*, my:type)[@my:value >= %]
 invalid: Query: //element(*, my:type)[@my:value >= %(*)]; expected: @, true, false, -,
+, *, ., @, (



Mime
View raw message