gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] gnash ChangeLog server/asobj/xml.cpp server/aso...


From: Sandro Santilli
Subject: [Gnash-commit] gnash ChangeLog server/asobj/xml.cpp server/aso...
Date: Wed, 04 Apr 2007 15:47:22 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Sandro Santilli <strk>  07/04/04 15:47:22

Modified files:
        .              : ChangeLog 
        server/asobj   : xml.cpp xmlnode.cpp xmlnode.h 
        testsuite/actionscript.all: XML.as 

Log message:
                * server/asobj/xml.cpp: fix parsing of text nodes
                * server/asobj/xmlnode.{cpp,h}: use std::string, not
                  C strings for name and value. Add an enum for NodeType.
                * testsuite/actionscript.all/XML.as: more tests for
                  the memory-parsed XML.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.2780&r2=1.2781
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/xml.cpp?cvsroot=gnash&r1=1.33&r2=1.34
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/xmlnode.cpp?cvsroot=gnash&r1=1.25&r2=1.26
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/xmlnode.h?cvsroot=gnash&r1=1.9&r2=1.10
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/actionscript.all/XML.as?cvsroot=gnash&r1=1.23&r2=1.24

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.2780
retrieving revision 1.2781
diff -u -b -r1.2780 -r1.2781
--- ChangeLog   4 Apr 2007 14:22:11 -0000       1.2780
+++ ChangeLog   4 Apr 2007 15:47:21 -0000       1.2781
@@ -1,5 +1,13 @@
 2007-04-04 Sandro Santilli <address@hidden>
 
+       * server/asobj/xml.cpp: fix parsing of text nodes
+       * server/asobj/xmlnode.{cpp,h}: use std::string, not
+         C strings for name and value. Add an enum for NodeType.
+       * testsuite/actionscript.all/XML.as: more tests for
+         the memory-parsed XML.
+
+2007-04-04 Sandro Santilli <address@hidden>
+
        * server/asobj/xmlnode.cpp: don't attacy XMLNode interface
          to XMLNode instances.
        * server/asobj/xml.{h,cpp}: override get_member and set_member

Index: server/asobj/xml.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/xml.cpp,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -b -r1.33 -r1.34
--- server/asobj/xml.cpp        4 Apr 2007 14:22:11 -0000       1.33
+++ server/asobj/xml.cpp        4 Apr 2007 15:47:22 -0000       1.34
@@ -14,7 +14,7 @@
 // along with this program; if not, write to the Free Software
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
-/* $Id: xml.cpp,v 1.33 2007/04/04 14:22:11 strk Exp $ */
+/* $Id: xml.cpp,v 1.34 2007/04/04 15:47:22 strk Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -150,7 +150,11 @@
 void
 XML::set_member(const std::string& name, const as_value& val)
 {
-        if ( name == "status" ) return;
+        if ( name == "status" )
+       {
+               _status = XML::Status(val.to_number());
+               return;
+       }
         else if ( name == "loaded" )
         {
                 bool b = val.to_bool();
@@ -230,10 +234,8 @@
 XML::extractNode(XMLNode& element, xmlNodePtr node, bool mem)
 {
     xmlAttrPtr attr;
-    xmlNodePtr childnode;
     xmlChar *ptr = NULL;
     boost::intrusive_ptr<XMLNode> child;
-    int len;
 
 //    log_msg("Created new element for %s at %p\n", node->name, element);
 
@@ -248,43 +250,33 @@
         XMLAttr attrib(reinterpret_cast<const char*>(attr->name),
                        reinterpret_cast<const char*>(attr->children->content));
 
-#if 0
-        len = memadjust(strlen(reinterpret_cast<const char *>(attr->name))+1);
-        attrib->_name = (char *)new char[len];
-        memset(attrib->_name, 0, len);
-        strcpy(attrib->_name, reinterpret_cast<const char *>(attr->name));
-
-        len = memadjust(strlen(reinterpret_cast<const char 
*>(attr->children->content))+1);
-        attrib->_value = (char *)new char[len];
-        memset(attrib->_value, 0, len);
-        strcpy(attrib->_value, reinterpret_cast<const char 
*>(attr->children->content));
-#endif
-
         //log_msg("\tPushing attribute %s for element %s has value %s\n",
         //        attr->name, node->name, attr->children->content);
         element._attributes.push_back(attrib);
         attr = attr->next;
     }
 
-    len = memadjust(strlen(reinterpret_cast<const char *>(node->name))+1);
-    element._name = (char *)new char[len];
-    memset(element._name, 0, len);
-    strcpy(element._name, reinterpret_cast<const char *>(node->name));
-    //element._name = reinterpret_cast<const char *>(node->name);
-    if (node->children) {
-        //ptr = node->children->content;
-        ptr = xmlNodeGetContent(node->children);
-        if (ptr != NULL) {
-            if ((strchr((const char *)ptr, '\n') == 0) && (ptr[0] != 0)) {
-                if (node->children->content == NULL) {
-                    //log_msg("Node %s has no contents\n", node->name);
-                } else {
-                    //log_msg("extractChildNode from text for %s has contents 
%s\n", node->name, ptr);
-                    len = memadjust(strlen(reinterpret_cast<const char 
*>(ptr))+1);
-                    element._value = (char *)new char[len];
-                    memset(element._value, 0, len);
-                    strcpy(element._value, reinterpret_cast<const char 
*>(ptr));
-                    //element->_value = reinterpret_cast<const char *>(ptr);
+    if (node->type == XML_ELEMENT_NODE)
+    {
+            element.nodeTypeSet(tElement);
+
+            std::string name(reinterpret_cast<const char*>(node->name));
+            element.nodeNameSet(name);
+    }
+    else if ( node->type == XML_TEXT_NODE )
+    {
+            element.nodeTypeSet(tText);
+
+            ptr = xmlNodeGetContent(node);
+            if (ptr != NULL)
+            {
+                if ((strchr((const char *)ptr, '\n') == 0) && (ptr[0] != 0))
+                {
+                    if (node->content)
+                    {
+                        log_msg("extractChildNode from text for %s has 
contents %s\n", node->name, ptr);
+                        std::string val(reinterpret_cast<const char*>(ptr));
+                        element.nodeValueSet(val);
                 }
             }
             xmlFree(ptr);
@@ -292,16 +284,13 @@
     }
     
     // See if we have any data (content)
-    childnode = node->children;
+    xmlNodePtr childnode = node->children;
 
-    while (childnode != NULL)
-    {
-        if (childnode->type == XML_ELEMENT_NODE)
+    while (childnode)
         {
             child = new XMLNode();
             extractNode(*child, childnode, mem);
             element._children.push_back(child);
-        }
         childnode = childnode->next;
     }
 
@@ -614,7 +603,8 @@
 /// the XML.createTextNode() method are the constructor methods for
 /// creating nodes for an XML object. 
 
-as_value xml_createelement(const fn_call& fn)
+static as_value
+xml_createelement(const fn_call& fn)
 {
 //    GNASH_REPORT_FUNCTION;
     
@@ -623,7 +613,7 @@
        XMLNode *xml_obj = new XMLNode();
 //     cerr << "create new child XMLNode is at " << (void *)xml_obj << endl;
        xml_obj->nodeNameSet(text);
-       xml_obj->nodeTypeSet(XML_ELEMENT_NODE);
+       xml_obj->nodeTypeSet(XMLNode::tText);
 //     ptr->set_member(text, xml_obj); // FIXME: use a getter/setter !
        // no return code from this method
        return as_value(xml_obj);
@@ -643,7 +633,8 @@
 /// XML.createElement() method are the constructor methods for
 /// creating nodes for an XML object.
 
-as_value xml_createtextnode(const fn_call& fn)
+as_value
+xml_createtextnode(const fn_call& fn)
 {
 //    GNASH_REPORT_FUNCTION;
 
@@ -654,7 +645,7 @@
        text = fn.arg(0).to_string(); 
        xml_obj = new XMLNode;
        xml_obj->nodeValueSet(text);
-       xml_obj->nodeTypeSet(XML_TEXT_NODE);
+       xml_obj->nodeTypeSet(XMLNode::tText);
        return as_value(xml_obj);
 //     log_msg("%s: xml obj is %p\n", __PRETTY_FUNCTION__, xml_obj);
     } else {

Index: server/asobj/xmlnode.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/xmlnode.cpp,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -b -r1.25 -r1.26
--- server/asobj/xmlnode.cpp    4 Apr 2007 14:22:11 -0000       1.25
+++ server/asobj/xmlnode.cpp    4 Apr 2007 15:47:22 -0000       1.26
@@ -14,7 +14,7 @@
 // along with this program; if not, write to the Free Software
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
-/* $Id: xmlnode.cpp,v 1.25 2007/04/04 14:22:11 strk Exp $ */
+/* $Id: xmlnode.cpp,v 1.26 2007/04/04 15:47:22 strk Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -73,10 +73,8 @@
 XMLNode::XMLNode()
     :
     as_object(getXMLNodeInterface()),
-    _name(0),
-    _value(0),
-    _type(XML_ELEMENT_NODE),
-    _parent(0)
+    _parent(0),
+    _type(tElement)
 {
     //log_msg("%s: %p \n", __PRETTY_FUNCTION__, this);
 #ifdef DEBUG_MEMORY_ALLOCATION
@@ -87,10 +85,8 @@
 XMLNode::XMLNode(as_object* overridden_interface)
     :
     as_object(overridden_interface),
-    _name(0),
-    _value(0),
-    _type(XML_ELEMENT_NODE),
-    _parent(0)
+    _parent(0),
+    _type(tElement)
 {
     //log_msg("%s: %p \n", __PRETTY_FUNCTION__, this);
 #ifdef DEBUG_MEMORY_ALLOCATION
@@ -101,10 +97,10 @@
 XMLNode::XMLNode(const XMLNode& tpl, bool deep)
     :
     as_object(getXMLNodeInterface()),
+    _parent(tpl._parent),
     _name(tpl._name),
     _value(tpl._value),
-    _type(tpl._type),
-    _parent(tpl._parent)
+    _type(tpl._type)
 {
     if ( ! deep )
     {
@@ -123,37 +119,11 @@
 
 XMLNode::~XMLNode()
 {
-    unsigned int i;
     //log_msg("%s: %p \n", __PRETTY_FUNCTION__, this);
 #ifdef DEBUG_MEMORY_ALLOCATION
-    log_msg("\tDeleting XMLNode data %s at %p\n", this->_name, this);
+    log_msg("\tDeleting XMLNode data %s at %p", this->_name.c_str(), this);
 #endif
   
-    for (i=0; i<_children.size(); i++) {
-       if (_children[i]->_name) {
-           delete [] _children[i]->_name;
-       }
-       if (_children[i]->_value) {
-           delete [] _children[i]->_value;
-       }
-    }
-
-    for (i=0; i<_attributes.size(); i++)
-    {
-            // shouldn't we delete attributes here ??
-            // TODO: plug this leak somehow !!
-    }
-
-    _children.clear();
-    _attributes.clear();
-
-    if (_name) {
-        delete [] _name;
-    }
-    if (_value) {
-        delete [] _value;
-    }
-    //  _value.set_undefined();
 }
 
 bool
@@ -186,54 +156,6 @@
        return _children.back();
 }
 
-void
-XMLNode::nodeNameSet(const char *name)
-{
-    int len = strlen(name) + 1;
- 
-    if (!_name) {
-       _name = (char *)new char[len];
-       memset(_name, 0, len);
-       strcpy(_name, name);
-    }
-}
-
-void
-XMLNode::nodeValueSet(const char *value)
-{
-    int len = strlen(value) + 1;
- 
-    // Should we use std::string here ?
-    delete [] _value;
-    _value = new char[len];
-    memset(_value, 0, len);
-    strcpy(_value, value);
-}
-
-/// \brief Get the type of an XML Node.
-///
-
-/// Read-only property; a nodeType value, either 1 for an XML element
-/// or 3 for a text node. The nodeType is a numeric value from the
-/// NodeType enumeration in the W3C DOM Level 1 recommendation:
-/// www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html.
-/// The following table lists the values.
-int
-XMLNode::nodeType() 
-{
-    switch (_type) {
-      case XML_TEXT_NODE:
-         return 3;
-         break;
-      case XML_ELEMENT_NODE:
-         return 1;
-         break;
-      default:
-         return 0;
-    }
-    // you should never get here
-    return -1;
-}
 
 void
 XMLNode::appendChild(boost::intrusive_ptr<XMLNode> node)
@@ -336,8 +258,9 @@
 XMLNode::stringify(const XMLNode& xml, std::ostream& xmlout) 
 {
 //    GNASH_REPORT_FUNCTION;
-    const char* nodevalue = xml.nodeValue();
-    const char* nodename = xml.nodeName();
+    const std::string& nodevalue = xml.nodeValue();
+    const std::string& nodename = xml.nodeName();
+    NodeType type = xml.nodeType();
 
 
 //    log_msg("%s: processing for object %s <%p>\n", __PRETTY_FUNCTION__, 
nodename, xml);
@@ -348,7 +271,7 @@
 #endif
 
     // Create the beginning of the tag
-    if (nodename)
+    if ( nodename.size() )
     {
         xmlout << "<" << nodename;
     
@@ -365,7 +288,7 @@
     }
 
     // Node value first, then childs
-    if ( nodevalue )
+    if ( type == tText )
     {
            xmlout << nodevalue;
     }
@@ -374,17 +297,15 @@
     ChildList::const_iterator itx;
     for (itx = xml._children.begin(); itx != xml._children.end(); itx++)
     {
-//      log_msg("Found One XMLNode child !!!! %s <%p>\n", (*itx)->nodeName(), 
(void*)*itx);
+//      log_msg("Found One XMLNode child !!!! %s <%p>\n", 
(*itx)->nodeName().c_str(), (void*)*itx);
 //      cerr << "<" << (*it)->nodeName() << ">" << endl;
         (*itx)->toString(xmlout);
     }
 
-    if (nodename)
+    if ( nodename.size() )
     {
-           assert(nodename);
            xmlout << "</" << nodename << ">";
     }
-
 }
 
 void
@@ -470,11 +391,12 @@
 //    GNASH_REPORT_FUNCTION;
     
     XMLNode *xml_obj = new XMLNode;
-    if ( fn.nargs > 0 )        {
-       xml_obj->nodeTypeSet(static_cast<xmlElementType>(
-                                static_cast<int>(fn.arg(0).to_number())));
-       if (fn.nargs > 1)       {
-           xml_obj->nodeValueSet(fn.arg(1).to_string());
+    if ( fn.nargs > 0 )
+    {
+        xml_obj->nodeTypeSet(XMLNode::NodeType(int(fn.arg(0).to_number())));
+        if (fn.nargs > 1)
+        {
+            xml_obj->nodeValueSet(fn.arg(1).to_std_string(&(fn.env())));
        }
     }
     
@@ -508,30 +430,6 @@
        ptr->appendChild(xml_obj);
        return as_value(); // undefined
 
-#if 0
-       if (xml_obj->nodeType() == XML_ELEMENT_NODE) {
-           ptr->appendChild(xml_obj.get());
-       } else {
-           ptr->nodeValueSet(xml_obj->nodeValue());
-       }
-       
-//    log_msg("%s: %p \n", __PRETTY_FUNCTION__, xml_obj);
-       int length = ptr->length();
-       if (length > 0) {
-           XMLNode *ass = xml_obj->previousSibling(); // or is it 'ptr' ??
-// FIXME: This shouldn't always be NULL
-//     log_msg("%s: ASS is %p, length is %d\n", __PRETTY_FUNCTION__,
-//             ass, length);
-           ptr->set_member("previousSibling", ass); // FIXME: don't do this, 
rely on getter/setter
-//     ptr->set_member("nextSibling", 
xml_obj->obj.nextSibling(ptr->obj.length()));
-       }
-       // The last child in the list is always the one we just appended
-       ptr->set_member("lastChild", xml_obj.get()); // FIXME: don't do this, 
rely on getter/setter
-    } else {
-        log_msg("ERROR: no child XMLNode paramaters!\\n");
-    }
-    return as_value();
-#endif
 }
 
 static as_value
@@ -607,14 +505,14 @@
     //log_msg("xmlnode_nodevalue called with %d args against 'this' = %p", 
fn.nargs, ptr);
     if ( fn.nargs == 0 )
     {
-           //log_msg("  nodeValue() returns '%s'", ptr->nodeValue());
-        const char* val = ptr->nodeValue();
-        if ( val ) rv = val;
+           //log_msg("  nodeValue() returns '%s'", ptr->nodeValue().c_str());
+        const std::string& val = ptr->nodeValue();
+        if ( ! val.empty() ) rv = val;
     }
     else
     {
         //log_msg(" arg(0) == '%s'", fn.arg(0).to_string());
-        ptr->nodeValueSet(fn.arg(0).to_string());
+        ptr->nodeValueSet(fn.arg(0).to_std_string(&(fn.env())));
     }
     return rv;
 }
@@ -629,8 +527,8 @@
     rv.set_null();
 
     if ( fn.nargs == 0 ) {
-        const char* val = ptr->nodeName();
-        if ( val ) rv = val;
+        const std::string& val = ptr->nodeName();
+        if ( ! val.empty() ) rv = val;
     }
     else
     {

Index: server/asobj/xmlnode.h
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/xmlnode.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- server/asobj/xmlnode.h      3 Apr 2007 13:22:24 -0000       1.9
+++ server/asobj/xmlnode.h      4 Apr 2007 15:47:22 -0000       1.10
@@ -47,10 +47,55 @@
 
 namespace gnash {  
  
-/// XML Node 
+/// XMLNode  ActionScript class
+//
+/// This is the base class for the XML ActionScript class
+///
 class DSOLOCAL XMLNode : public gnash::as_object
 {
 public:
+
+
+    typedef enum {
+
+        /// Element
+        tElement = 1,
+
+        /// Attribute
+        tAttribute = 2,
+
+        /// Text
+        tText = 3,
+
+        /// CDATA section 
+        tCdata = 4,
+
+        /// Entity reference
+        tEntityRef = 5,
+        
+        /// Entity
+        tEntity = 6,
+        
+        /// Processing instruction
+        tProcInstr = 7,
+                
+        /// Comment
+        tComment = 8,
+
+        /// Document
+        tDocument = 9,
+
+        /// Document type
+        tDocType = 10,
+
+        /// Document fragment
+        tDocFgarment = 11,
+
+        /// Notation
+        tNotation = 12
+
+    } NodeType;
+
     XMLNode();
 
     // This constructor is used by the XML class
@@ -61,25 +106,27 @@
 
     size_t length() const { return _children.size(); }
 
-    const char* nodeName() const { return _name; }
+    const std::string& nodeName() const { return _name; }
+
+    const std::string& nodeValue() const { return _value; }
 
-    const char* nodeValue() const { return _value; }
+    /// Get the type of an XML Node.
+    NodeType nodeType() const { return _type; }
 
-    int nodeType();
-    void nodeTypeSet(xmlElementType type) {
+    /// Set the type of an XML Node.
+    void nodeTypeSet(NodeType type)
+    {
            _type = type;
     }
 
-    //    char *valueGet();
-  
     /// Set name of this node, but only if it doesn't have a name yet
     //
     /// TODO: check if this is the correct behaviour
     ///
-    void nodeNameSet(const char *name);
+    void nodeNameSet(const std::string& name) { _name = name; }
 
     /// Set value of this node, overriding any previous value
-    void nodeValueSet(const char *value);
+    void nodeValueSet(const std::string& value) { _value = value; }
     //  nodeType       XML.nodeType
 
     ///  Returns true if the specified node has child nodes; otherwise, 
returns false.
@@ -172,13 +219,6 @@
 
     void  change_stack_frame(int frame, gnash::as_object *xml, 
gnash::as_environment *env);
 
-
-    // why don't we use std::strings here ?
-    // code would be much simpler and safer!
-    char                *_name;
-    char                *_value;
-
-    xmlElementType      _type;
     XMLNode            *_parent;
     ChildList          _children;
     AttribList      _attributes;
@@ -187,6 +227,12 @@
 
     // TODO: make a lot more things private !
 
+    std::string _name;
+
+    std::string _value;
+
+    NodeType     _type;
+
     static void stringify(const XMLNode& xml, std::ostream& xmlout);
 
 };

Index: testsuite/actionscript.all/XML.as
===================================================================
RCS file: /sources/gnash/gnash/testsuite/actionscript.all/XML.as,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -b -r1.23 -r1.24
--- testsuite/actionscript.all/XML.as   4 Apr 2007 14:33:32 -0000       1.23
+++ testsuite/actionscript.all/XML.as   4 Apr 2007 15:47:22 -0000       1.24
@@ -20,7 +20,7 @@
 // compile this test case with Ming makeswf, and then
 // execute it like this gnash -1 -r 0 -v out.swf
 
-rcsid="$Id: XML.as,v 1.23 2007/04/04 14:33:32 strk Exp $";
+rcsid="$Id: XML.as,v 1.24 2007/04/04 15:47:22 strk Exp $";
 
 #include "dejagnu.as"
 #include "utils.as"
@@ -256,37 +256,84 @@
     this.childNodes = 5;
        check(this.childNodes instanceof Array);
 
-        with (this.firstChild) {
-            //trace("FIXME: firstChild found: " + nodeName);
-            if (nodeName == 'TOPNODE') {
-                //trace("FIXME: topnode found: "+ childNodes.length);
-                childa = 0;
-                while (childa < childNodes.length) {
-                    //trace("FIXME: children found");
-                    check(childNodes[childa] != undefined);
-                    with (childNodes[childa]) {
-                        if (nodeName == 'SUBNODE1') {
-                            childb = 0;
-                            while (childb < childNodes.length) {
-                                with (childNodes[childb]) {
-                                    if (nodeName == 'SUBSUBNODE1') {
-                                        _global.child1 = firstChild.nodeValue;
-note("Set _global.child1 to "+_global.child1);
-                                    } else {
-                                        if (nodeName == 'SUBNODE2') {
-                                            _global.child2 = 
firstChild.nodeValue;
-                                        } else {
-                                            if (nodeName == 'SUBSUBNODE1') {
-                                                _global.child3 = 
firstChild.nodeValue;
+        with (this.firstChild)
+       {
+               check_equals(nodeName, 'TOPNODE');
+               check_equals(typeof(nodeValue), 'null');
+
+               // Check that nodeValue is overridable
+               nodeValue = 4;
+               check_equals(typeof(nodeValue), 'string');
+               check_equals(nodeValue, '4');
+
+               check_equals(nodeType, 1); // element
+               check_equals(childNodes.length, 2);
+
+               with (firstChild)
+               {
+                       check_equals(nodeName, 'SUBNODE1');
+                       check_equals(typeof(nodeValue), 'null');
+                       check_equals(nodeType, 1); // element
+                       check_equals(childNodes.length, 2);
+                       with (firstChild)
+                       {
+                               check_equals(nodeName, 'SUBSUBNODE1');
+                               check_equals(typeof(nodeValue), 'null');
+                               check_equals(nodeType, 1); // element
+                               check_equals(childNodes.length, 1);
+                               with (firstChild)
+                               {
+                                       check_equals(typeof(nodeName), 'null')
+                                       check_equals(nodeValue, 'sub sub1 node 
data 1')
+                                       check_equals(nodeType, 3); // text
                                             }
                                         }
+                       with (lastChild)
+                       {
+                               check_equals(nodeName, 'SUBSUBNODE2');
+                               check_equals(typeof(nodeValue), 'null');
+                               check_equals(nodeType, 1); // element
+                               check_equals(childNodes.length, 1);
+                               with (firstChild)
+                               {
+                                       check_equals(typeof(nodeName), 'null')
+                                       check_equals(nodeValue, 'sub sub1 node 
data 2')
+                                       check_equals(nodeType, 3); // text
                                     }
                                 }
-                                ++childb;
+               }
+
+               with (lastChild)
+               {
+                       check_equals(nodeName, 'SUBNODE2');
+                       check_equals(typeof(nodeValue), 'null');
+                       check_equals(nodeType, 1); // element
+                       check_equals(childNodes.length, 2);
+                       with (firstChild)
+                       {
+                               check_equals(nodeName, 'SUBSUBNODE1');
+                               check_equals(typeof(nodeValue), 'null');
+                               check_equals(nodeType, 1); // element
+                               check_equals(childNodes.length, 1);
+                               with (firstChild)
+                               {
+                                       check_equals(typeof(nodeName), 'null')
+                                       check_equals(nodeValue, 'sub sub2 node 
data 1')
+                                       check_equals(nodeType, 3); // text
                             }
                         }
+                       with (lastChild)
+                       {
+                               check_equals(nodeName, 'SUBSUBNODE2');
+                               check_equals(typeof(nodeValue), 'null');
+                               check_equals(nodeType, 1); // element
+                               check_equals(childNodes.length, 1);
+                               with (firstChild)
+                               {
+                                       check_equals(typeof(nodeName), 'null')
+                                       check_equals(nodeValue, 'sub sub2 node 
data 2')
+                                       check_equals(nodeType, 3); // text
                     }
-                    ++childa;
                 }
             }
         }
@@ -457,7 +504,8 @@
        var status_backup = myxml.status;
        myxml.status = 'a string';
        check_equals(typeof(myxml.status), 'number');
-       xcheck(myxml.status != status_backup);
+       check(myxml.status != status_backup);
+       note("myxml.status is == "+myxml.status+" after being set to 'a 
string'");
        myxml.status = status_backup;
 
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]