[Laszlo-checkins] r9455 - openlaszlo/trunk/WEB-INF/lps/lfc/data

bargull@openlaszlo.org bargull at openlaszlo.org
Wed Jun 4 10:08:46 PDT 2008


Author: bargull
Date: 2008-06-04 10:08:44 -0700 (Wed, 04 Jun 2008)
New Revision: 9455

Modified:
   openlaszlo/trunk/WEB-INF/lps/lfc/data/LzDatapointer.lzs
Log:
Change 20080604-bargull-qQa by bargull at dell--p4--2-53 on 2008-06-04 00:31:31
    in /home/Admin/src/svn/openlaszlo/trunk
    for http://svn.openlaszlo.org/openlaszlo/trunk

Summary: xpath curiosities

New Features:

Bugs Fixed: LPP-5316, LPP-5318

Technical Reviewer: hminsky
QA Reviewer: promanik
Doc Reviewer: (pending)

Documentation:

Release Notes:

Details:
Added Nullpointer-check in "__LZgetLast" and "__LZgetPosition" to address LPP-5316, 
changed xpath-processing in "xpathQuery" to fix LPP-5318. 
    

Tests:
alldata passes, testcases at bugreports



Modified: openlaszlo/trunk/WEB-INF/lps/lfc/data/LzDatapointer.lzs
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/data/LzDatapointer.lzs	2008-06-04 16:46:07 UTC (rev 9454)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/data/LzDatapointer.lzs	2008-06-04 17:08:44 UTC (rev 9455)
@@ -74,7 +74,8 @@
   * @see LzDataset
   */
 class LzDatapointer extends LzNode {
-
+  #pragma "warnUndefinedReferences=true"
+  
 /** @access private
   * @modifiers override 
   */
@@ -235,7 +236,24 @@
             if (nodes is Array) {
                 return nodes.length;
             } else {
-                return this.__LZgetLast();
+                if (!ppcontext && nodes === this.p) {
+                    // @devnote: if we supplied the current datanode 'this.p' to __LZgetNodes(..), 
+                    // but __LZgetNodes(..) didn't actually do any processing, the user expects that 
+                    // the xpath will be evaluated against this datanode, but we need to 
+                    // protect against special cases because of replication:
+                    // n datanodes are replicated, this datanode is at x, x=[1..n], 
+                    // "last()" should return n, but "../*[x]/last()" should return 1!
+                    if (pp.selectors && pp.selectors.length > 0) {
+                        var sel:Array = pp.selectors;
+                        var i:int = 0;
+                        while (sel[i] == "." && i < sel.length) { ++i; }
+                        return i != sel.length ? 1 : this.__LZgetLast();
+                    } else {
+                        return this.__LZgetLast();
+                    }
+                } else {
+                    return 1;
+                }
             }
         } else if (pp.aggOperator == 'position') {
             if (nodes is Array) {
@@ -245,7 +263,19 @@
                 }
                 return rarr;
             } else {
-                return this.__LZgetPosition();
+                if (!ppcontext && nodes === this.p) {
+                    // @devnote: see comment for "last()"
+                    if (pp.selectors && pp.selectors.length > 0) {
+                        var sel:Array = pp.selectors;
+                        var i:int = 0;
+                        while (sel[i] == "." && i < sel.length) { ++i; }
+                        return i != sel.length ? 1 : this.__LZgetPosition();
+                    } else {
+                        return this.__LZgetPosition();
+                    }
+                } else {
+                    return 1;
+                }
             }
         }
     } else if ( pp.operator != null  ){
@@ -463,13 +493,13 @@
 
 /** @access private */
 function __LZgetLast () :int { 
-    if ( this.context === this ) return 1;
+    if ( this.context == null || this.context === this ) return 1;
     return this.context.__LZgetLast() || 1;
 }
 
 /** @access private */
 function __LZgetPosition () :int { 
-    if ( this.context === this ) return 1;
+    if ( this.context == null || this.context === this ) return 1;
     return this.context.__LZgetPosition() || 1;
 }
 



More information about the Laszlo-checkins mailing list