lz.DataNodeMixin
The base class for a node of hierarchical data.

JavaScript: lz.DataNodeMixin

lz.DataNode is the base class for the classes that represent OpenLaszlo's hierarchical data format.

<canvas width="300" height="300">
   <simplelayout axis="y"/>
 
   <text width="300" height="250" bgcolor="silver" multiline="true" name="display"/>
   <button>Make some data
     <attribute name="currentstep" value="0"/>
 
     <handler name="onclick"><![CDATA[
        
       switch(currentstep ++){
         case 0:
           this.n = new LzDataElement('numbers');
           setAttribute('text', 'Add some children');
           break;
         case 1:
           for (var i = 1; i < 11 ; i++){
             this.n.appendChild(new LzDataElement('number' , 
                                                      {value : i}));
 
           }
           setAttribute('text', 'Add linebreaks');
           break;
         case 2:
           var dp = new LzDatapointer();
           dp.setPointer(this.n.getFirstChild());
           do {
             dp.p.parentNode.insertBefore(new LzDataText('\n'), 
                                              dp.p);
           } while (dp.selectNext())
           dp.p.parentNode.appendChild(new LzDataText('\n')); 
           setAttribute('visible', false);
           break;
       }
       display.setText(display.escapeText(n.serialize()));
       
     ]]></handler>
   </button>
 </canvas>
edit

Attributes

Name Type (tag) Type (js) Default Category
childNodes   lz.DataNodeMixin   read/write
  An array of children of this node
nodeType   int   read/write
  The type of this node -- ELEMENT_NODE or TEXT_NODE
ownerDocument       read/write
   
parentNode       read/write
   

Methods

childOf()
lz.DataNodeMixin.childOf(el : lz.DataElement, allowself : Boolean);
Tells whether the given node is above this one in the node hierarchy.
Parameter Name Type Description
el lz.DataElement The LzDataElement to test to see if it is above this one
allowself Boolean If true, this function returns true if the given node is the same as this node.

cloneNode()
lz.DataNodeMixin.cloneNode(deep : Boolean);
Returns a copy of this node.
Parameter Name Type Description
deep Boolean If true, the children of this node will be part of the new node
Returns Type Description
  lz.DataNodeMixin A copy of this node.

getNextSibling()
lz.DataNodeMixin.getNextSibling();
Returns the sibling after this one this node's parentNodes List of children
Returns Type Description
  lz.DataNodeMixin The node succeeding this one in this node's childNodes

getOffset()
lz.DataNodeMixin.getOffset();
gets offset of node in parent's childNodes array
Returns Type Description
  int  

getParent()
lz.DataNodeMixin.getParent();
Returns the parent of this node
Returns Type Description
  lz.DataElementMixin the parent of this node

getPreviousSibling()
lz.DataNodeMixin.getPreviousSibling();
Returns the sibling before this one this node's parentNodes List of children
Returns Type Description
  lz.DataNodeMixin The node preceeding this one in this node's childNodes

serialize()
lz.DataNodeMixin.serialize(len);
Returns this node as a string of xml.
Parameter Name Type Description
len    
Returns Type Description
  String The string serialization of this node.

setOwnerDocument()
lz.DataNodeMixin.setOwnerDocument(ownerDoc : lz.DataNodeMixin);
[Caution] This method is deprecated
Use setAttribute('ownerDocument', ...) instead.
Sets the LzDataNodeMixin which is the ownerDocument for this node.
Parameter Name Type Description
ownerDoc lz.DataNodeMixin The LzDataNodeMixin to act as the ownerDocument for this node.

Events

Name Description
onattributes  
onchildNode  
onchildNodes  
onDocumentChange  
onnodeName  
onownerDocument  
onparentNode