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 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 (this.currentstep++) {
         case 0:
           this.n = new lz.DataElement('numbers');
           this.setAttribute('text', 'Add some children');
           break;
         case 1:
           for (var i = 1; i < 11; i++) {
             this.n.appendChild(new lz.DataElement('number', {value : i}));
           }
           this.setAttribute('text', 'Add linebreaks');
           break;
         case 2:
           var dp = new lz.datapointer();
           dp.setPointer(this.n.getFirstChild());
           do {
             dp.p.parentNode.insertBefore(new lz.DataText('\n'), dp.p);
           } while (dp.selectNext())
           dp.p.parentNode.appendChild(new lz.DataText('\n'));
           this.setAttribute('visible', false);
           break;
       }
       canvas.display.setAttribute('text', canvas.display.escapeText(n.serialize()));
       
     ]]></handler>
   </button>
 </canvas>

Attributes

Name (CSS property) Type (tag) Type (js) Default Category
childNodes   [lz.DataNodeMixin]   read/write
  An array of children of this node
nodeType   int   readonly
  The type of this node -- one of lz.DataElement.DOCUMENT_NODE, lz.DataElement.ELEMENT_NODE or lz.DataElement.TEXT_NODE
ownerDocument   lz.DataElementMixin   readonly
  The owner document for this node.
parentNode   lz.DataElementMixin   readonly
  The parent of this node
sel       read/write
  Selection state of this node, used by dataselectionmanager

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 in this node's parentNodes list of children
Returns Type Description
  lz.DataNodeMixin The node immediately succeeding this node

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 in this node's parentNodes list of children
Returns Type Description
  lz.DataNodeMixin The node immediately preceeding this node

getUserData()
lz.DataNodeMixin.getUserData(key : String);
Retrieves the object associated to a key on a this node. The object must first have been set to this node by calling setUserData with the same key. (See getUserData (DOM Level 3))
Parameter Name Type Description
key String The key the object is associated to.
Returns Type Description
  Object the user data associated to the given key on this node, or null if there was none.

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

setUserData()
lz.DataNodeMixin.setUserData(key : String, data : Object, handler : Object);
Associate an object to a key on this node. The object can later be retrieved from this node by calling getUserData with the same key. (See setUserData (DOM Level 3))
Parameter Name Type Description
key String The key to associate the object to.
data Object The object to associate to the given key, or null to remove any existing association to that key.
handler Object (optional) The handler to associate to that key, or null.
Returns Type Description
  Object the user data previously associated to the given key on this node, or null if there was none.

Events

Name Description
onattributes  
onchildNode  
onchildNodes  
onDocumentChange  
onnodeName  
onownerDocument  
onparentNode