<datapointer>
               
A cursor in a dataset.
            
          
         
            JavaScript: lz.datapointer
            
 
         
                A datapointer is an object that represents a pointer to a node in a
                lz.dataset. The datapointer can be repositioned
                using either cursor movements calls such as 
                LzDatapointer.selectNext(), or by running an XPath 
                request via LzDatapointer.setXPath().
                
            
            
                Datapointers support a subset of the XPath specification, which uses
                a notation similar to the UNIX file-system to refer to nodes within a
                dataset. Once a datapointer is bound to a node in a dataset it will
                keep pointing to that node until it is moved. If the dataset is edited,
                the behavior of the datapointer will be controlled by its rerunxpath attribute. If this attribute is
                true, it will continue pointing to its current
                node as long as it is valid.
            
            The example below demonstrates the use of some of the
                features of datapaths to retrieve data from a dataset.
            
            Example 11. Using a datapointer to retrieve data from a dataset
               
                  <canvas height="80">
   <simplelayout spacing="5"/>
   <dataset name="mydata">
     <record> This is some text 
       <deeper>
         <deeprecord> This is a deeper level </deeprecord>
         <deeprecord> It's dark down here! </deeprecord>
         <deeprecord> Last deep record </deeprecord>
       </deeper>
     </record>
     <record> This is more text </record>
     <record> Exciting no? </record>
     <record> The final line of text </record>
   </dataset>
 
   <view>
     <simplelayout/>
     <datapointer id="mydp" xpath="mydata:/record[1]"/>
     <button> Move forward with select
       <handler name="onclick">
         if (mydp.selectNext()) var s = mydp.getNodeText();
         else var s = "hit last record; reset with xpath";
         output.setText(s);
       </handler>
     </button>
     <button> Set with XPath
       <handler name="onclick">
           if (mydp.getNodeName() == "record")
             var xp = "mydata:/record[1]/deeper/deeprecord[1]";
           else var xp = "mydata:/record[1]";
           mydp.setXPath( xp ); output.setText(mydp.getNodeText());
       </handler>
     </button>
   </view>
 
   <text name="output" width="200">Data will appear here.</text>
 </canvas>
                  
                  
                
            
            Attributes inherited from <node>
                  
               
               
                  classroot, cloneManager, data, datapath, defaultplacement, id, ignoreplacement, immediateparent, inited, initstage, name, nodeLevel, options, parent, placement, styleclass, subnodes, transition
                  
               
            
               Methods
               
                  - 
                        
                        
                        
                        
- 
                     datapointer.addNode(name : String, text : String, attrs : Dictionary);
                         
Adds a new child node below the current context
                      
 
- 
                        
                        
                        
                        
- 
                     datapointer.addNodeFromPointer(dp : lz.datapointer);
                         
Duplicates the node that  dp is pointing to, and appends it
                         it to the node pointed to by this datapointer, making the added node the last on the list.
                      
 
- 
                        
                        
                        
                        
- 
                     datapointer.comparePointer(ptr : lz.datapointer);
                         
Determines whether this pointer is pointing to the same node as  ptr.
                      
 
- 
                        
                        
                        
                        
- 
                     datapointer.deleteNode();
                         
Removes the node pointed to by the datapointer. If
                          rerunxpath is true and  xpath
                         has been set, it will be re-evaluated. Otherwise, if the deleted node
                         has a following sibling, the pointer is repositioned at that sibling.
                         Otherwise the pointer is set to  null.
                      
 
- 
                        
                        
                        
                        
- 
                     datapointer.deleteNodeAttribute(name : String);
                         
Removes the  name attribute from the current node.
                      
 
- 
                        
                        
                        
                        
- 
                     datapointer.dupePointer();
                         
Return a new datapointer that points to the same node, has a
                         null  xpath and a
                         false  rerunxpath attribute.
                      
 
- 
                        
                        
                        
                        
- 
                     datapointer.getDataset();
                         
Returns a reference to the datapointer's dataset.
                      
 
- 
                        
                        
                        
                        
- 
                     datapointer.getNodeAttribute(name : String);
                         
Returns the value of the current node's  name attribute.
                      
 
- 
                        
                        
                        
                        
- 
                     datapointer.getNodeAttributes();
                         
Returns the attributes of the node pointed to by the datapointer in an
                         Object whose keys are the attribute names and whose values are the attribute
                         values
                      
 
- 
                        
                        
                        
                        
- 
                     datapointer.getNodeCount();
                         
Counts the number of element nodes that are children of the node that the
                         datapointer is pointing to.
                      
 
- 
                        
                        
                        
                        
- 
                     datapointer.getNodeName();
                         
Gets the name of the node that the datapointer is pointing to.
                      
 
- 
                        
                        
                        
                        
- 
                     datapointer.getNodeText();
                         
Returns a string that represents a concatenation of the text nodes
                         beneath the current element.  getNodeText and
                          getOtherNodeText are the only way to access
                         non-element data nodes.
                      
 
- 
                        
                        
                        
                        
- 
                     datapointer.getNodeType();
                         
Gets the nodeType of the node that the datapointer is pointing to.
                      
 
- 
                        
                        
                        
                        
- 
                     datapointer.getXPathIndex();
                         
Returns the number of the node that the datapointer is pointing to.
                         If the datapointer does not point to a valid node, 0 is returned.
                         Note that XPath indices are 1-based.
                      
 
- 
                        
                        
                        
                        
- 
                     
                     Tests whether or not this datapointer is pointing to a valid node.
                      
 
- 
                        
                        
                        
                        
- 
                     datapointer.selectChild(amnt : Number);
                         
Moves down the data hierarchy to  the next child node in the dataset if 
                         possible.
                      
 
- 
                        
                        
                        
                        
- 
                     datapointer.selectNext(amnt : Number);
                         
Selects the next sibling node in the dataset if possible.
                      
 
- 
                        
                        
                        
                        
- 
                     datapointer.selectParent(amnt : Number);
                         
Moves up the data hierarchy to the next parent node in the dataset if
                         possible.
                      
 
- 
                        
                        
                        
                        
- 
                     datapointer.selectPrev(amnt : Number);
                         
Selects the previous sibling node in the dataset if possible.
                      
 
- 
                        
                        
                        
                        
- 
                     
                     Serialize the current element and its children to an XML string. Note that
                         even if this datapointer's XPath ends in a terminal selector (such
                         as  @attribute or  text()) this method will
                         return the serialized text of the element that the datapointer
                         points to.
                      
 
- 
                        
                        
                        
                        
- 
                     datapointer.setFromPointer(dp : lz.datapointer);
                         
Sets this datapointer to the location of the given datapointer
                      
 
- 
                        
                        
                        
                        
- 
                     datapointer.setNodeAttribute(name : String, val : String);
                         
Set the  name attribute of the current node to the
                          val.
                      
 
- 
                        
                        
                        
                        
- 
                     datapointer.setNodeName(name : String);
                         
Sets the name of the current element to the  name.
                      
 
- 
                        
                        
                        
                        
- 
                     datapointer.setNodeText(val : String);
                         
Sets the current node's text to  value.
                         When this node is serialized, the text will be
                         represented as the first child node of this node. If the node
                         already has one or more text children, the value of the first text
                         node is set to the  val.
                      
 
- 
                        
                        
                        
                        
- 
                     datapointer.setPointer(p : lz.DataNodeMixin);
                         
Points this datapointer at p.
                      
 
- 
                        
                        
                        
                        
- 
                     datapointer.setXPath(p : String);
                         
Sets the  xpath attribute to
                          param, and sets the current node to the node that it
                         refers to.
                         
                         If the XPath contains a terminal selector such as
                          text(), the datapointer's  data
                         property is set to that value. It is error to set a datapointer to
                         an XPath that matches multiple nodes.
                      
 
- 
                        
                        
                        
                        
- 
                     datapointer.xpathQuery(p : Object);
                         
Returns the result of an XPath query without changing the pointer.
                      
 
 
            Methods inherited from <node>
                  
               
               
                  animate, applyConstraintMethod, applyData, childOf, completeInstantiation, construct, createChildren, dataBindAttribute, destroy, determinePlacement, getOption, getUID, init, lookupSourceLocator, releaseConstraint, releaseConstraintMethod, searchImmediateSubnodes, searchSubnodes, setOption, setSelected, updateData