incubator-xap-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmarga...@apache.org
Subject svn commit: r488939 - /incubator/xap/trunk/src/google/xpath.js
Date Wed, 20 Dec 2006 07:26:48 GMT
Author: jmargaris
Date: Tue Dec 19 23:26:47 2006
New Revision: 488939

URL: http://svn.apache.org/viewvc?view=rev&rev=488939
Log:
fixing the id() function which didn't work at all, newer
google code fixed the problem parsing the id function itself
but still doesn't fix using the id function as the first
part of a path. Clearly using the id() function was never
tested at all as it had obvious problems in parsing the 
arguments...

Modified:
    incubator/xap/trunk/src/google/xpath.js

Modified: incubator/xap/trunk/src/google/xpath.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/google/xpath.js?view=diff&rev=488939&r1=488938&r2=488939
==============================================================================
--- incubator/xap/trunk/src/google/xpath.js (original)
+++ incubator/xap/trunk/src/google/xpath.js Tue Dec 19 23:26:47 2006
@@ -852,7 +852,7 @@
 
   'id': function(ctx) {
     assert(this.args.length == 1);
-    var e = this.args.evaluate(ctx);
+    var e = this.args[0].evaluate(ctx);
     var ret = [];
     var ids;
     if (e.type == 'node-set') {
@@ -864,7 +864,7 @@
         }
       }
     } else {
-      ids = e.split(/\s+/);
+      ids = e.stringValue().split(/\s+/);
     }
     var d = ctx.node.ownerDocument;
     for (var i = 0; i < ids.length; ++i) {
@@ -1944,6 +1944,32 @@
    [ XPathPathExpr,
      [ XPathFilterExpr, TOK_DSLASH, XPathRelativeLocationPath ], 20,
      makePathExpr2 ],
+     
+     
+	//added by JMargaris
+	//We had a problem trying to parse id(...)/...
+	//In that case the stack would read [XPathFunctionCall TOK_SLASH  XPathRelativeLocationPath]
+	//What *should* happen is that since FunctionCall is a FilterExpr that should pass the 
+	//above tests. However the TOK_SLASH has precedence 30 and the rule that turns FunctionCall
+	//into a supertype is precedence 20, so it isn't invoked. We could raise the precedence
of 
+	//those rules that promote subtypes to supertypes, but I'm not sure what the impact of that
would be.
+	//This change is very small in scope and appears to make id()/ and id()// work correctly.
+	//
+	//Really the way this should work is that because FunctionCall is a FilterExpr the existing
rules
+	//above should take effect, but that just isn't how this code is written. In general ALL
the rules
+	//should work for all the types given including all sub-types of those types. That would
probably
+	//fix the need for precedence levels as well...but again this is a small scope change that
gets
+	//the job done in this case, although things like $x/blah probably still wont work as we
scoped
+	//this change ONLY to function call.
+   [ XPathPathExpr, 
+     [ XPathFunctionCall, TOK_SLASH, XPathRelativeLocationPath ], 20,
+     makePathExpr1 ],
+   
+    [ XPathPathExpr,
+     [ XPathFunctionCall, TOK_DSLASH, XPathRelativeLocationPath ], 20,
+     makePathExpr2 ],
+    //end added by JMargaris 
+    
 
    [ XPathFilterExpr, [ XPathPrimaryExpr, XPathPredicate, Q_MM ], 20,
      makeFilterExpr ], 



Mime
View raw message