Diff for /parser3/src/classes/xnode.C between versions 1.71 and 1.87

version 1.71, 2005/08/09 08:14:48 version 1.87, 2012/03/16 09:24:08
Line 1 Line 1
 /** @file  /** @file
         Parser: @b dom parser class.          Parser: @b dom parser class.
   
         Copyright (c) 2001-2005 ArtLebedev Group (http://www.artlebedev.com)          Copyright (c) 2001-2012 Art. Lebedev Studio (http://www.artlebedev.com)
         Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru)          Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru)
 */  */
 #include "classes.h"  #include "classes.h"
 #ifdef XML  #ifdef XML
   
 static const char * const IDENT_XNODE_C="$Date$";  
   
 #include "pa_vmethod_frame.h"  #include "pa_vmethod_frame.h"
   
 #include "pa_charset.h"  #include "pa_charset.h"
Line 17  static const char * const IDENT_XNODE_C= Line 15  static const char * const IDENT_XNODE_C=
 #include "pa_vxdoc.h"  #include "pa_vxdoc.h"
 #include "pa_vvoid.h"  #include "pa_vvoid.h"
 #include "pa_xml_exception.h"  #include "pa_xml_exception.h"
   #include "pa_vbool.h"
   
 #include "xnode.h"  #include "xnode.h"
 #include "libxml/xpath.h"  #include "libxml/xpath.h"
 #include "libxml/xpathInternals.h"  #include "libxml/xpathInternals.h"
   
   volatile const char * IDENT_XNODE_C="$Id$" IDENT_XNODE_H;
   
 // global variable  // global variable
   
 DECLARE_CLASS_VAR(xnode, new MXnode, 0);  DECLARE_CLASS_VAR(xnode, new MXnode, 0);
Line 96  private: Line 97  private:
   
 // helpers  // helpers
   
 GdomeNode* as_node(MethodParams& params,   xmlNode& as_node(MethodParams& params, int index, const char* msg) {
                    int index, const char* msg) {  
         GdomeNode* result;  
         Value& value=params.as_no_junction(index, msg);          Value& value=params.as_no_junction(index, msg);
         if(Value* vxnode=value.as(VXNODE_TYPE, false))          if(Value* vxnode=value.as(VXNODE_TYPE))
                 result=static_cast<VXnode*>(vxnode)->get_node();                  return static_cast<VXnode*>(vxnode)->get_xmlnode();
         else {          else
                 throw Exception("parser.runtime",                  throw Exception(PARSER_RUNTIME,
                         0,                          0,
                         msg);                          msg);
         }  }
   
         return result;  xmlChar* as_xmlchar(Request& r, MethodParams& params, int index, const char* msg) {
           return r.transcode(params.as_string(index, msg));
 }  }
   
 // helpers  xmlChar* as_xmlqname(Request& r, MethodParams& params, int index, const char* msg) {
           xmlChar* qname=r.transcode(params.as_string(index, msg ? msg : XML_QUALIFIED_NAME_MUST_BE_STRING));
           if(xmlValidateQName(qname, 0))
                   throw XmlException(0, XML_INVALID_QUALIFIED_NAME, qname);
           return qname;
   }
   
 GdomeAttr* as_attr(MethodParams& params,   xmlChar* as_xmlncname(Request& r, MethodParams& params, int index, const char* msg) {
                    int index, const char* msg) {          xmlChar* ncname=r.transcode(params.as_string(index, msg ? msg : XML_NC_NAME_MUST_BE_STRING));
         GdomeNode* node=as_node(params, index, msg);          if(xmlValidateNCName(ncname, 0))
         GdomeException exc;                  throw XmlException(0, XML_INVALID_NC_NAME, ncname);
         if(gdome_n_nodeType(node, &exc)!=GDOME_ATTRIBUTE_NODE)          return ncname;
                 throw Exception("parser.runtime",  }
   
   xmlChar* as_xmlname(Request& r, MethodParams& params, int index, const char* msg) {
           xmlChar* localName=r.transcode(params.as_string(index, msg ? msg : XML_LOCAL_NAME_MUST_BE_STRING));
           if(xmlValidateName(localName, 0))
                   throw XmlException(0, XML_INVALID_LOCAL_NAME, localName);
           return localName;
   }
   
   xmlChar* as_xmlnsuri(Request& r, MethodParams& params, int index) {
           return r.transcode(params.as_string(index, XML_NAMESPACEURI_MUST_BE_STRING));
   }
   
   xmlAttr& as_attr(MethodParams& params, int index, const char* msg) {
           xmlNode& xmlnode=as_node(params, index, msg);
           if(xmlnode.type!=XML_ATTRIBUTE_NODE)
                   throw Exception(PARSER_RUNTIME,
                         0,                          0,
                         msg);                          msg);
   
         return GDOME_A(node);          return *(xmlAttr*)&xmlnode;
 }  }
   
   static void writeNode(Request& r, VXdoc& xdoc, xmlNode* node) {
           if(!node|| xmlHaveGenericErrors())
                   throw XmlException(0); // OOM, bad name, things like that
   
           // write out result
           r.write_no_lang(xdoc.wrap(*node));
   }
   
   static xmlNode* pa_getAttributeNodeNS(xmlNode& selfNode, 
                                                                             const xmlChar* localName,
                                                                             const xmlChar* namespaceURI) 
   {
           for(xmlNode* currentNode=(xmlNode*)selfNode.properties;
                   currentNode;
                   currentNode=currentNode->next)
           {
                   if(!namespaceURI || currentNode->ns && xmlStrEqual(currentNode->ns->href, namespaceURI))
                           if(!localName || xmlStrEqual(currentNode->name, localName))
                                   return currentNode;
           }
           return 0;
   }
   
   xmlNs& pa_xmlMapNs(xmlDoc& doc, const xmlChar *href, const xmlChar *prefix) {
           assert(href);
           // prefix can be null
   
           xmlNs *cur=doc.oldNs;
           while (cur != NULL &&
                                    ((cur->prefix == NULL && prefix != NULL) ||
                                           (cur->prefix != NULL && prefix == NULL) ||
                                           !xmlStrEqual (cur->prefix, prefix)) &&
                                    !xmlStrEqual (cur->href, href))
                   cur = cur->next;
   
           if (cur == NULL) {
                   cur = xmlNewNs (NULL, href, prefix);
                   if(!cur || xmlHaveGenericErrors())
                           throw XmlException(0);
                   cur->next = doc.oldNs;
                   doc.oldNs = cur;
           }
   
           return *cur;
   }
   
   /// @todo: проверить, обновляется ли parent!
   static void pa_addAttributeNode(xmlNode& selfNode, xmlAttr& attrNode) 
   {
           if(attrNode.type!=XML_ATTRIBUTE_NODE)
                   throw Exception(PARSER_RUNTIME,
                           0,
                           "must be ATTRIBUTE_NODE");
   
       /*
        * Add it at the end to preserve parsing order ...
        */
       if (selfNode.properties == NULL) {
           selfNode.properties = &attrNode;
       } else {
           xmlAttrPtr prev = selfNode.properties;
   
           while (prev->next != NULL)
               prev = prev->next;
           prev->next = &attrNode;
           attrNode.prev = prev;
       }
   
       if (xmlIsID(selfNode.doc, &selfNode, &attrNode) == 1)
           xmlAddID(NULL, selfNode.doc, xmlNodeGetContent((xmlNode*)&attrNode), &attrNode);
   }
   
   static const xmlChar *
   pa_xmlGetNsURI(xmlNode *node) {
           if (node == NULL || node->ns == NULL)
                   return NULL;
   
           return node->ns->href;
   }
   
   #ifndef DOXYGEN
   struct AccumulateFoundInfo
   {
           HashStringValue* hash;
           VXdoc* vdoc;
           int index;
   };
   #endif
   static void AccumulateFound(xmlNode& node, AccumulateFoundInfo* info)
   {
           info->hash->put(
                   String::Body::Format(info->index++), 
                   &info->vdoc->wrap(node));
   }
   template<typename I> static void
   pa_xmlNamedPreorderTraversal (
                                                             xmlNode *root, 
                                                             xmlChar *tagURI, 
                                                             xmlChar *tagName, 
                                                             void callback(xmlNode& node, I info),
                                                             I info) 
   {
           for(xmlNode *iter=root->children; iter; iter = iter->next) {
                   if(iter->type == XML_ELEMENT_NODE &&
                           (xmlStrEqual(iter->name, tagName) ||
                           xmlStrEqual(tagName, (const xmlChar*)"*"))) {
                                   if(tagURI != NULL &&
                                           (xmlStrEqual(pa_xmlGetNsURI(iter), tagURI) ||
                                           xmlStrEqual(tagURI, (const xmlChar*)"*")))
                                           callback(*iter, info);
                                   else if(tagURI == NULL)
                                           callback(*iter, info);
                           }
                           pa_xmlNamedPreorderTraversal(iter, tagURI, tagName, callback, info);
           }
   
           return;
   }
   
   
 // methods  // methods
   
 // DOM1 node  // DOM1 node
   
 // Node insertBefore(in Node newChild,in Node refChild) raises(DOMException);  // Node insertBefore(in Node newChild,in Node refChild) raises(DOMException);
 static void _insertBefore(Request& r, MethodParams& params) {  static void _insertBefore(Request& r, MethodParams& params) {
           xmlNode& newChild=as_node(params, 0, "newChild must be node");
           xmlNode& refChild=as_node(params, 1, "refChild must be node");
   
         VXnode& vnode=GET_SELF(r, VXnode);          VXnode& vnode=GET_SELF(r, VXnode);
         GdomeNode* selfNode=vnode.get_node();          VXdoc& vxdoc=vnode.get_vxdoc();
         GdomeNode* newChild=as_node(params, 0, "newChild must be node");  
         GdomeNode* refChild=as_node(params, 1, "refChild must be node");          //xmlNode& selfNode=vnode.get_xmlnode();
                   
         GdomeException exc;          xmlNode* retNode=xmlAddPrevSibling(&refChild, &newChild);
         if(GdomeNode* retNode=gdome_n_insertBefore(selfNode, newChild, refChild, &exc)) {          // write out result
                 // write out result          writeNode(r, vxdoc, retNode);
                 r.write_no_lang(*new VXnode(&r.charsets, vnode.get_xdoc(), retNode));  
         } else  
                 throw XmlException(0, exc);  
 }  }
   
 // Node replaceChild(in Node newChild,in Node oldChild) raises(DOMException);  // Node replaceChild(in Node newChild,in Node oldChild) raises(DOMException);
 static void _replaceChild(Request& r, MethodParams& params) {  static void _replaceChild(Request& r, MethodParams& params) {
           xmlNode& newChild=as_node(params, 0, "newChild must be node");
           xmlNode& oldChild=as_node(params, 1, "oldChild must be node");
   
         VXnode& vnode=GET_SELF(r, VXnode);          VXnode& vnode=GET_SELF(r, VXnode);
         GdomeNode* selfNode=vnode.get_node();          VXdoc& vxdoc=vnode.get_vxdoc();
         GdomeNode* newChild=as_node(params, 0, "newChild must be node");          xmlDoc& xmldoc=vxdoc.get_xmldoc();
         GdomeNode* oldChild=as_node(params, 1, "oldChild must be node");          xmlNode& selfNode=vnode.get_xmlnode();
           
         GdomeException exc;          if(newChild.doc!=&xmldoc)
         if(GdomeNode* retNode=gdome_n_replaceChild(selfNode, newChild, oldChild, &exc)) {                  throw Exception("xml.dom",
                 // write out result                          0,
                 r.write_no_lang(*new VXnode(&r.charsets, vnode.get_xdoc(), retNode));                          "WRONG_DOCUMENT_ERR");
         } else          if(oldChild.doc!=&xmldoc)
                 throw XmlException(0, exc);                  throw Exception("xml.dom",
                           0,
                           "WRONG_DOCUMENT_ERR");
   
           if(oldChild.parent!=&selfNode)
                   throw Exception("xml.dom",
                           0,
                           "NOT_FOUND_ERR");
   
           xmlNode* refChild=oldChild.next;
           xmlUnlinkNode(&oldChild);
           xmlNode* retNode;
           if(refChild)
                   retNode=xmlAddPrevSibling(refChild, &newChild);
           else
                   retNode=xmlAddChild(&selfNode, &newChild);
   
           // write out result
           writeNode(r, vxdoc, retNode);
 }  }
   
 // Node removeChild(in Node oldChild) raises(DOMException);  // Node removeChild(in Node oldChild) raises(DOMException);
 static void _removeChild(Request& r, MethodParams& params) {  static void _removeChild(Request& r, MethodParams& params) {
           xmlNode& oldChild=as_node(params, 0, "refChild must be node");
   
         VXnode& vnode=GET_SELF(r, VXnode);          VXnode& vnode=GET_SELF(r, VXnode);
         GdomeNode* selfNode=vnode.get_node();          VXdoc& vxdoc=vnode.get_vxdoc();
         GdomeNode* oldChild=as_node(params, 0, "oldChild must be node");          xmlDoc& xmldoc=vxdoc.get_xmldoc();
   //      xmlNode& selfNode=vnode.get_xmlnode();
                   
         GdomeException exc;          if(oldChild.doc!=&xmldoc)
         if(GdomeNode* retNode=gdome_n_removeChild(selfNode, oldChild, &exc)) {                  throw Exception("xml.dom",
                 // write out result                          0,
                 r.write_no_lang(*new VXnode(&r.charsets, vnode.get_xdoc(), retNode));                          "WRONG_DOCUMENT_ERR");
         } else  
                 throw XmlException(0, exc);          xmlUnlinkNode(&oldChild);
           // write out result
           writeNode(r, vxdoc, &oldChild);
 }  }
   
 // Node appendChild(in Node newChild) raises(DOMException);  // Node appendChild(in Node newChild) raises(DOMException);
 static void _appendChild(Request& r, MethodParams& params) {  static void _appendChild(Request& r, MethodParams& params) {
           xmlNode& newChild=as_node(params, 0, "newChild must be node");
   
         VXnode& vnode=GET_SELF(r, VXnode);          VXnode& vnode=GET_SELF(r, VXnode);
         GdomeNode* selfNode=vnode.get_node();          VXdoc& vxdoc=vnode.get_vxdoc();
         GdomeNode* newChild=as_node(params, 0, "newChild must be node");          xmlNode& selfNode=vnode.get_xmlnode();
                   
         GdomeException exc;          xmlNode* retNode=xmlAddChild(&selfNode, &newChild);
         if(GdomeNode* retNode=gdome_n_appendChild(selfNode, newChild, &exc)) {          // write out result
                 // write out result          writeNode(r, vxdoc, retNode);
                 r.write_no_lang(*new VXnode(&r.charsets, vnode.get_xdoc(), retNode));  
         }  else  
                 throw XmlException(0, exc);  
 }  }
   
 // boolean hasChildNodes();  // boolean hasChildNodes();
 static void _hasChildNodes(Request& r, MethodParams&) {  static void _hasChildNodes(Request& r, MethodParams&) {
         VXnode& vnode=GET_SELF(r, VXnode);          VXnode& vnode=GET_SELF(r, VXnode);
         GdomeNode* node=vnode.get_node();          xmlNode& node=vnode.get_xmlnode();
   
         GdomeException exc;  
         // write out result          // write out result
         bool result=gdome_n_hasChildNodes(node, &exc)!=0;          r.write_no_lang(VBool::get(node.children!=0));
         r.write_no_lang(*new VBool(result));  
 }  }
   
 // Node cloneNode(in boolean deep);  // Node cloneNode(in boolean deep);
 static void _cloneNode(Request& r, MethodParams& params) {  static void _cloneNode(Request& r, MethodParams& params) {
         VXnode& vnode=GET_SELF(r, VXnode);  
         GdomeNode* node=vnode.get_node();  
   
         bool deep=params.as_bool(0, "deep must be bool", r);          bool deep=params.as_bool(0, "deep must be bool", r);
   
         GdomeException exc;          VXnode& vnode=GET_SELF(r, VXnode);
           xmlNode& selfNode=vnode.get_xmlnode();
           VXdoc& vxdoc=vnode.get_vxdoc();
           xmlDoc& xmldoc=vxdoc.get_xmldoc();
   
           xmlNode* retNode=xmlDocCopyNode(&selfNode, &xmldoc, deep?1: 0);
         // write out result          // write out result
         r.write_no_lang(*new VXnode(&r.charsets, vnode.get_xdoc(), gdome_n_cloneNode(node, deep, &exc)));          writeNode(r, vxdoc, retNode);
 }  }
   
 // DOM1 element  // DOM1 element
   
 GdomeElement* get_self_element(VXnode& vnode) {  xmlNode& get_self_element(VXnode& vnode) {
         GdomeNode* node=vnode.get_node();          xmlNode& node=vnode.get_xmlnode();
   
         GdomeException exc;          if(node.type!=XML_ELEMENT_NODE)
         if(gdome_n_nodeType(node, &exc)!=GDOME_ELEMENT_NODE)                  throw Exception(PARSER_RUNTIME,
                 throw Exception("parser.runtime",  
                         0,                          0,
                         "method can only be called on nodes of ELEMENT type");                          "method can only be called on nodes of ELEMENT type");
   
         return GDOME_EL(node);          return node;
 }  }
   
   // DOMString getAttribute(in DOMString name);
   
 /// @bug attribute_value must be freed!  [// DOMString getAttribute(in DOMString name);  
 static void _getAttribute(Request& r, MethodParams& params) {  static void _getAttribute(Request& r, MethodParams& params) {
           const xmlChar* name=as_xmlname(r, params, 0);
   
         VXnode& vnode=GET_SELF(r, VXnode);          VXnode& vnode=GET_SELF(r, VXnode);
         GdomeElement* element=get_self_element(vnode);          xmlNode& element=get_self_element(vnode);
         const String& name=params.as_string(0, "name must be string");  
   
         GdomeException exc;          // @todo: when name="xmlns"
         GdomeDOMString *attribute_value=          xmlChar* attribute_value=xmlGetProp(&element, name);
                 gdome_el_getAttribute(element, r.transcode(name).use(), &exc);  
         // write out result          // write out result
         r.write_pass_lang(r.transcode(attribute_value));          r.write_pass_lang(r.transcode(attribute_value));
 }  }
   
 // void setAttribute(in DOMString name, in DOMString value) raises(DOMException);  // void setAttribute(in DOMString name, in DOMString value) raises(DOMException);
 static void _setAttribute(Request& r, MethodParams& params) {  static void _setAttribute(Request& r, MethodParams& params) {
           const xmlChar* name=as_xmlname(r, params, 0);
           const xmlChar* attribute_value=as_xmlchar(r, params, 1, XML_VALUE_MUST_BE_STRING);
   
         VXnode& vnode=GET_SELF(r, VXnode);          VXnode& vnode=GET_SELF(r, VXnode);
         GdomeElement* element=get_self_element(vnode);          xmlNode& element=get_self_element(vnode);
         const String& name=params.as_string(0, "name must be string");  
         const String& attribute_value=params.as_string(1, "value must be string");          // @todo: when name="xmlns"
           if(!xmlSetProp(&element, name,  attribute_value))
         GdomeException exc;                  throw XmlException(0);
         gdome_el_setAttribute(element,  
                 r.transcode(name).use(),   
                 r.transcode(attribute_value).use(),  
                 &exc);  
         if(exc)  
                 throw XmlException(0, exc);  
 }  }
   
 // void removeAttribute(in DOMString name) raises(DOMException);  // void removeAttribute(in DOMString name) raises(DOMException);
 static void _removeAttribute(Request& r, MethodParams& params) {  static void _removeAttribute(Request& r, MethodParams& params) {
           const xmlChar* name=as_xmlname(r, params, 0);
   
         VXnode& vnode=GET_SELF(r, VXnode);          VXnode& vnode=GET_SELF(r, VXnode);
         GdomeElement* element=get_self_element(vnode);          xmlNode& element=get_self_element(vnode);
         const String& name=params.as_string(0, "name must be string");  
   
         GdomeException exc;          // @todo: when name="xmlns"
         gdome_el_removeAttribute(element, r.transcode(name).use(), &exc);          xmlUnsetProp(&element, name);
         if(exc)  
                 throw XmlException(0, exc);  
 }  }
   
 // Attr getAttributeNode(in DOMString name);  // Attr getAttributeNode(in DOMString name);
 static void _getAttributeNode(Request& r, MethodParams& params) {  static void _getAttributeNode(Request& r, MethodParams& params) {
           const xmlChar* localName=as_xmlname(r, params, 0);
   
         VXnode& vnode=GET_SELF(r, VXnode);          VXnode& vnode=GET_SELF(r, VXnode);
         GdomeElement* element=get_self_element(vnode);          VXdoc& vxdoc=vnode.get_vxdoc();
         const String& name=params.as_string(0, "name must be string");          xmlNode& element=get_self_element(vnode);
   
         GdomeException exc;          if(xmlNode* retNode=pa_getAttributeNodeNS(element, localName, 0)){
         if(GdomeAttr *attr=gdome_el_getAttributeNode(element,   
                 r.transcode(name).use(), &exc)) {  
                 // write out result                  // write out result
                 r.write_no_lang(*new VXnode(&r.charsets, vnode.get_xdoc(), (GdomeNode* )attr));                  writeNode(r, vxdoc, retNode);
         } else if(exc)          }
                 throw XmlException(0, exc);  
 }         }       
   
 // Attr setAttributeNode(in Attr newAttr) raises(DOMException);  // Attr setAttributeNode(in Attr newAttr) raises(DOMException);
   // Attr setAttributeNodeNS(in Attr newAttr) raises(DOMException);
 static void _setAttributeNode(Request& r, MethodParams& params) {  static void _setAttributeNode(Request& r, MethodParams& params) {
         VXnode& vnode=GET_SELF(r, VXnode);          VXnode& vnode=GET_SELF(r, VXnode);
         GdomeElement* element=get_self_element(vnode);          VXdoc& vxdoc=vnode.get_vxdoc();
         GdomeAttr * newAttr=as_attr(params, 0, "newAttr must be ATTRIBUTE node");          xmlNode& element=get_self_element(vnode);
           xmlDoc& xmldoc=vxdoc.get_xmldoc();
   
         GdomeException exc;          xmlAttr& newAttr=as_attr(params, 0, "newAttr must be ATTRIBUTE node");
         if(GdomeAttr *returnAttr=gdome_el_setAttributeNode(element, newAttr, &exc)) {  
           if(newAttr.doc!=&xmldoc)
                   throw Exception("xml.dom",
                           0,
                           "WRONG_DOCUMENT_ERR");
   
           if(newAttr.parent)
                   throw Exception("xml.dom",
                           0,
                           "INUSE_ATTRIBUTE_ERR");
           
           if(xmlNode* retNode=pa_getAttributeNodeNS(element, newAttr.name, pa_xmlGetNsURI((xmlNode*)&newAttr))) {
                 // write out result                  // write out result
                 r.write_no_lang(*new VXnode(&r.charsets, vnode.get_xdoc(), (GdomeNode* )returnAttr));                  writeNode(r, vxdoc, retNode);
         } else                  xmlUnlinkNode(retNode);
                 throw XmlException(0, exc);          }
   
           pa_addAttributeNode(element, newAttr);
 }         }       
   
 // Attr removeAttributeNode(in Attr oldAttr) raises(DOMException);  // Attr removeAttributeNode(in Attr oldAttr) raises(DOMException);
 static void _removeAttributeNode(Request& r, MethodParams& params) {  static void _removeAttributeNode(Request& r, MethodParams& params) {
           xmlAttr& oldAttr=as_attr(params, 0, "oldAttr must be ATTRIBUTE node");
   
         VXnode& vnode=GET_SELF(r, VXnode);          VXnode& vnode=GET_SELF(r, VXnode);
         GdomeElement* element=get_self_element(vnode);          VXdoc& vxdoc=vnode.get_vxdoc();
         GdomeAttr * oldAttr=as_attr(params, 0, "oldAttr must be ATTRIBUTE node");          xmlNode& element=get_self_element(vnode);
   
         GdomeException exc;          if(oldAttr.parent!=&element)
         gdome_el_removeAttributeNode(element, oldAttr, &exc);                  throw Exception("xml.dom",
         if(exc)                          0,
                 throw XmlException(0, exc);                          "NOT_FOUND_ERR");
   
           xmlUnlinkNode((xmlNode*)&oldAttr);
   
           // write out result
           writeNode(r, vxdoc, (xmlNode*)&oldAttr);
 }         }       
   
 // NodeList getElementsByTagName(in DOMString name);  // NodeList getElementsByTagName(in DOMString name);
   // '*' means all tags
 static void _getElementsByTagName(Request& r, MethodParams& params) {  static void _getElementsByTagName(Request& r, MethodParams& params) {
         VXnode& vnode=GET_SELF(r, VXnode);          xmlChar* tagName=as_xmlchar(r, params, 0, XML_LOCAL_NAME_MUST_BE_STRING);
         GdomeElement* element=get_self_element(vnode);          if(xmlValidateName(tagName, 0) != 0 && strcmp((const char*)tagName, "*") != 0)
                   throw XmlException(0, XML_INVALID_LOCAL_NAME, tagName);
   
         const String& name=params.as_string(0, "name must be string");          VXnode& vnode=GET_SELF(r, VXnode);
           VXdoc& vxdoc=vnode.get_vxdoc();
           xmlNode& xmlnode=vnode.get_xmlnode();
   
         VHash& result=*new VHash;          VHash& result=*new VHash;
         GdomeException exc;          AccumulateFoundInfo info={&result.hash(), &vxdoc, 0};
         if(GdomeNodeList *nodes=          pa_xmlNamedPreorderTraversal(&xmlnode, 
                 gdome_el_getElementsByTagName(element, r.transcode(name).use(), &exc)) {                                                            0, 
                 gulong length=gdome_nl_length(nodes, &exc);                                                            tagName, 
                 for(gulong i=0; i<length; i++)                                                            AccumulateFound,
                         result.hash().put(                                                            &info);
                                 String::Body::Format(i),   
                                 new VXnode(&r.charsets, vnode.get_xdoc(), gdome_nl_item(nodes, i, &exc)));  
         } else if(exc)  
                 throw XmlException(0, exc);  
   
         // write out result          // write out result
         r.write_no_lang(result);          r.write_no_lang(result);
Line 335  static void _getElementsByTagName(Reques Line 515  static void _getElementsByTagName(Reques
   
 // DOMString getAttributeNS(in DOMString namespaceURI, in DOMString localName);  // DOMString getAttributeNS(in DOMString namespaceURI, in DOMString localName);
 static void _getAttributeNS(Request& r, MethodParams& params) {  static void _getAttributeNS(Request& r, MethodParams& params) {
           xmlChar* namespaceURI=as_xmlnsuri(r, params, 0);
           xmlChar* localName=as_xmlname(r, params, 1);
   
         VXnode& vnode=GET_SELF(r, VXnode);          VXnode& vnode=GET_SELF(r, VXnode);
         GdomeElement* element=get_self_element(vnode);          xmlNode& element=get_self_element(vnode);
                   
         const String& namespaceURI=params.as_string(0, "namespaceURI must be string");          // todo: when name="xmlns"
         const String& localName=params.as_string(0, "localName must be string");          xmlChar* attribute_value=xmlGetNsProp(&element, localName, namespaceURI);
   
         GdomeException exc;  
         GdomeDOMString *attribute_value=  
                 gdome_el_getAttributeNS(element,   
                         r.transcode(namespaceURI).use(),  
                         r.transcode(localName).use(), &exc);  
         // write out result          // write out result
         r.write_pass_lang(r.transcode(attribute_value));          r.write_pass_lang(r.transcode(attribute_value));
 }  }
   
   
 // void setAttributeNS(in DOMString namespaceURI, in DOMString qualifiedName, in DOMString value) raises(DOMException);  // void setAttributeNS(in DOMString namespaceURI, in DOMString qualifiedName, in DOMString value) raises(DOMException);
 static void _setAttributeNS(Request& r, MethodParams& params) {  static void _setAttributeNS(Request& r, MethodParams& params) {
         VXnode& vnode=GET_SELF(r, VXnode);          const xmlChar* namespaceURI=as_xmlnsuri(r, params, 0);
         GdomeElement* element=get_self_element(vnode);          const xmlChar* qualifiedName=as_xmlqname(r, params, 1);
         const String& namespaceURI=params.as_string(0, "namespaceURI must be string");          const xmlChar* attribute_value=as_xmlchar(r, params, 2, XML_VALUE_MUST_BE_STRING);
         const String& qualifiedName=params.as_string(1, "qualifiedName must be string");  
         const String& attribute_value=params.as_string(2, "value must be string");          VXnode& vnode=GET_SELF(r, VXnode);
           xmlNode& element=get_self_element(vnode);
         GdomeException exc;          VXdoc& vxdoc=vnode.get_vxdoc();
         gdome_el_setAttributeNS(element,          xmlDoc& xmldoc=vxdoc.get_xmldoc();
                 r.transcode(namespaceURI).use(),  
                 r.transcode(qualifiedName).use(),           xmlChar* prefix=0;
                 r.transcode(attribute_value).use(),          xmlChar* localName=xmlSplitQName2(qualifiedName, &prefix);
                 &exc);  
         if(exc)          // @todo: name=xmlns
                 throw XmlException(0, exc);          xmlAttr* attrNode;
           if(localName) {
                   xmlNs& ns=pa_xmlMapNs(xmldoc, namespaceURI, prefix);
                   
                   attrNode=xmlSetNsProp(&element, &ns,
                           localName,
                           attribute_value);
           } else {
                   attrNode=xmlSetProp(&element, 
                           qualifiedName/*unqualified, actually*/,
                           attribute_value);
           }
   
           if(!attrNode)
                   throw XmlException(0);
 }  }
   
 // void removeAttributeNS(in DOMString namespaceURI, in DOMString localName) raises(DOMException);  // void removeAttributeNS(in DOMString namespaceURI, in DOMString localName) raises(DOMException);
 static void _removeAttributeNS(Request& r, MethodParams& params) {  static void _removeAttributeNS(Request& r, MethodParams& params) {
           const xmlChar* namespaceURI=as_xmlnsuri(r, params, 0);
           const xmlChar* localName=as_xmlname(r, params, 1);
   
         VXnode& vnode=GET_SELF(r, VXnode);          VXnode& vnode=GET_SELF(r, VXnode);
         GdomeElement* element=get_self_element(vnode);          xmlNode& element=get_self_element(vnode);
         const String& namespaceURI=params.as_string(0, "namespaceURI must be string");          VXdoc& vxdoc=vnode.get_vxdoc();
         const String& localName=params.as_string(1, "localName must be string");          xmlDoc& xmldoc=vxdoc.get_xmldoc();
   
         GdomeException exc;          // @todo: when name="xmlns"
         gdome_el_removeAttributeNS(element,           xmlNs& ns=pa_xmlMapNs(xmldoc, namespaceURI, 0);
         r.transcode(namespaceURI).use(),          xmlUnsetNsProp(&element, &ns, localName);
         r.transcode(localName).use(),   
         &exc);  
         if(exc)  
                 throw XmlException(0, exc);  
 }  }
   
 // Attr getAttributeNodeNS(in DOMString namespaceURI, in DOMString localName);  // Attr getAttributeNodeNS(in DOMString namespaceURI, in DOMString localName);
 static void _getAttributeNodeNS(Request& r, MethodParams& params) {  static void _getAttributeNodeNS(Request& r, MethodParams& params) {
         VXnode& vnode=GET_SELF(r, VXnode);          const xmlChar* namespaceURI=as_xmlnsuri(r, params, 0);
         GdomeElement* element=get_self_element(vnode);          const xmlChar* localName=as_xmlname(r, params, 1);
         const String& namespaceURI=params.as_string(0, "namespaceURI must be string");  
         const String& name=params.as_string(1, "name must be string");  
   
         GdomeException exc;  
         if(GdomeAttr *attr=gdome_el_getAttributeNodeNS(element,   
                 r.transcode(namespaceURI).use(), r.transcode(name).use(), &exc)) {  
                 // write out result  
                 r.write_no_lang(*new VXnode(&r.charsets, vnode.get_xdoc(), (GdomeNode* )attr));  
         } else if(exc)  
                 throw XmlException(0, exc);  
 }  
   
 // Attr setAttributeNodeNS(in Attr newAttr) raises(DOMException);  
 static void _setAttributeNodeNS(Request& r, MethodParams& params) {  
         VXnode& vnode=GET_SELF(r, VXnode);          VXnode& vnode=GET_SELF(r, VXnode);
         GdomeElement* element=get_self_element(vnode);          VXdoc& vxdoc=vnode.get_vxdoc();
         GdomeAttr * newAttr=as_attr(params, 0, "newAttr must be ATTRIBUTE node");          xmlNode& element=get_self_element(vnode);
   
         GdomeException exc;          if(xmlNode* retNode=pa_getAttributeNodeNS(element, localName, namespaceURI)){
         if(GdomeAttr *returnAttr=gdome_el_setAttributeNodeNS(element, newAttr, &exc)) {  
                 // write out result                  // write out result
                 r.write_no_lang(*new VXnode(&r.charsets, vnode.get_xdoc(), (GdomeNode* )returnAttr));                  writeNode(r, vxdoc, retNode);
         } else          }
                 throw XmlException(0, exc);  }       
 }  
   
 // boolean hasAttribute(in DOMString name) raises(DOMException);  // boolean hasAttribute(in DOMString name) raises(DOMException);
 static void _hasAttribute(Request& r, MethodParams& params) {  static void _hasAttribute(Request& r, MethodParams& params) {
         VXnode& vnode=GET_SELF(r, VXnode);          const xmlChar* name=as_xmlname(r, params, 0);
         GdomeElement* element=get_self_element(vnode);  
   
         const String& name=params.as_string(0, "name must be string");          VXnode& vnode=GET_SELF(r, VXnode);
           xmlNode& element=get_self_element(vnode);
   
         GdomeException exc;          // @todo: when name="xmlns"
         // write out result          // write out result
         bool result=gdome_el_hasAttribute(element,           r.write_no_lang(VBool::get(xmlHasProp(&element, name)!=0));
         r.transcode(name).use(),  
         &exc)!=0;  
         r.write_no_lang(*new VBool(result));  
 }  }
   
 // boolean hasAttributeNS(n DOMString namespaceURI, in DOMString localName) raises(DOMException);  // boolean hasAttributeNS(n DOMString namespaceURI, in DOMString localName) raises(DOMException);
 static void _hasAttributeNS(Request& r, MethodParams& params) {  static void _hasAttributeNS(Request& r, MethodParams& params) {
           const xmlChar* namespaceURI=as_xmlnsuri(r, params, 0);
           const xmlChar* localName=as_xmlname(r, params, 1);
   
         VXnode& vnode=GET_SELF(r, VXnode);          VXnode& vnode=GET_SELF(r, VXnode);
         GdomeElement* element=get_self_element(vnode);          xmlNode& element=get_self_element(vnode);
   
         const String& namespaceURI=params.as_string(0, "namespaceURI must be string");          // write out result
         const String& localName=params.as_string(1, "localName must be string");          r.write_no_lang(VBool::get(xmlHasNsProp(&element, localName, namespaceURI)!=0));
   }
   
   // boolean hasAttributes
   static void _hasAttributes(Request& r, MethodParams&) {
           VXnode& vnode=GET_SELF(r, VXnode);
           xmlNode& element=get_self_element(vnode);
   
         GdomeException exc;  
         // write out result          // write out result
         bool result=gdome_el_hasAttributeNS(element,           r.write_no_lang(VBool::get(element.properties!=0));
         r.transcode(namespaceURI).use(),  
         r.transcode(localName).use(),  
         &exc)!=0;  
         r.write_no_lang(*new VBool(result));  
 }  }
   
   // NodeList getElementsByTagNameNS(in DOMString namespaceURI, in DOMString localName);
   // '*' as namespaceURI means get all namespaces
   // '*' as localName means get all tags
 static void _getElementsByTagNameNS(Request& r, MethodParams& params) {  static void _getElementsByTagNameNS(Request& r, MethodParams& params) {
         VXnode& vnode=GET_SELF(r, VXnode);          xmlChar* namespaceURI=as_xmlchar(r, params, 0, XML_NAMESPACEURI_MUST_BE_STRING);
         GdomeElement* element=get_self_element(vnode);  
   
         // namespaceURI;localName          xmlChar* localName=as_xmlchar(r, params, 1, XML_LOCAL_NAME_MUST_BE_STRING);
         const String& namespaceURI=params.as_string(0, "namespaceURI must be string");          if(xmlValidateName(localName, 0) != 0 && strcmp((const char*)localName, "*") != 0)
         const String& localName=params.as_string(1, "localName must be string");                  throw XmlException(0, XML_INVALID_LOCAL_NAME, localName);
   
           VXnode& vnode=GET_SELF(r, VXnode);
           VXdoc& vdoc=vnode.get_vxdoc();
           xmlDoc& xmldoc=vdoc.get_xmldoc();
   
         GdomeException exc;  
         VHash& result=*new VHash;          VHash& result=*new VHash;
         if(GdomeNodeList *nodes=          AccumulateFoundInfo info={&result.hash(), &vdoc, 0};
                 gdome_el_getElementsByTagNameNS(          pa_xmlNamedPreorderTraversal((xmlNode*)&xmldoc, 
                         element,                                                             namespaceURI, 
                         r.transcode(namespaceURI).use(),                                                            localName, 
                         r.transcode(localName).use(),                                                            AccumulateFound,
                         &exc)) {                                                            &info);
                 gulong length=gdome_nl_length(nodes, &exc);  
                 for(gulong i=0; i<length; i++)  
                         result.hash().put(  
                                 String::Body::Format(i),   
                                 new VXnode(&r.charsets, vnode.get_xdoc(), gdome_nl_item(nodes, i, &exc)));  
         }  
   
         // write out result          // write out result
         r.write_no_lang(result);          r.write_no_lang(result);
 }  }
   
   
 // void normalize();  // void normalize();
 static void _normalize(Request& r, MethodParams&) {  static void _normalize(Request&, MethodParams&) {
   /*maybe someday
         VXnode& vnode=GET_SELF(r, VXnode);          VXnode& vnode=GET_SELF(r, VXnode);
         GdomeNode* selfNode=vnode.get_node();          xmlNode& selfNode=vnode.get_xmlnode();
   
         GdomeException exc;  
         gdome_n_normalize(selfNode, &exc);          gdome_n_normalize(selfNode, &exc);
         if(exc)          if(exc)
                 throw XmlException(0, exc);                  throw XmlException(0, exc);
   */
 }  }
   
 #ifndef DOXYGEN  #ifndef DOXYGEN
Line 496  static void register_one_ns( Line 674  static void register_one_ns(
                                                                   Register_one_ns_info* info) {                                                                    Register_one_ns_info* info) {
         if(const String* svalue=value->get_string())          if(const String* svalue=value->get_string())
                 xmlXPathRegisterNs(info->ctxt,                   xmlXPathRegisterNs(info->ctxt, 
                         BAD_CAST info->r->transcode(key)->str,                           info->r->transcode(key), 
                         BAD_CAST info->r->transcode(*svalue)->str);                          info->r->transcode(*svalue));
         else          else
                 throw Exception("parser.runtime",                  throw Exception(PARSER_RUNTIME,
                         new String(key, String::L_TAINTED),                          new String(key, String::L_TAINTED),
                         "value is %s, must be string or number", value->type());                          "value is %s, must be string or number", value->type());
 }  }
Line 508  static void _selectX(Request& r, MethodP Line 686  static void _selectX(Request& r, MethodP
                                                           const String& expression,                                                             const String& expression, 
                                                           xmlXPathObject_auto_ptr res,                                                            xmlXPathObject_auto_ptr res,
                                                           VXdoc& xdoc,                                                            VXdoc& xdoc,
                                                           Value*& result)) {                                                            Value*& result)) 
   {
         VXnode& vnode=GET_SELF(r, VXnode);          VXnode& vnode=GET_SELF(r, VXnode);
           xmlNode& xmlnode=vnode.get_xmlnode();
           VXdoc& vdoc=vnode.get_vxdoc();
           xmlDoc& xmldoc=vdoc.get_xmldoc();
   
         // expression          // expression
         const String& expression=params.as_string(0, "expression must be string");          const String& expression=params.as_string(0, "expression must be string");
         GdomeException exc;          xmlXPathContext_auto_ptr ctxt(xmlXPathNewContext(&xmldoc));
         GdomeNode* dome_node=vnode.get_node();  
         GdomeDocument *dome_document=gdome_n_ownerDocument(dome_node, &exc);  
         if(!dome_document) // document does not own itself, so ownerDocument = 0  
                 dome_document=GDOME_DOC(dome_node); // and we need downcast  
         xmlDoc *xml_document=gdome_xml_doc_get_xmlDoc(dome_document);  
         xmlXPathContext_auto_ptr ctxt(xmlXPathNewContext(xml_document));  
         {          {
                 Register_one_ns_info info={&r, ctxt.get()};                  Register_one_ns_info info={&r, ctxt.get()};
                 vnode.get_xdoc().search_namespaces.hash().for_each(register_one_ns, &info);                  vdoc.search_namespaces.hash().for_each<Register_one_ns_info*>(register_one_ns, &info);
         }          }
         ctxt->node=gdome_xml_n_get_xmlNode(dome_node);          ctxt->node=&xmlnode;
         /*error to stderr for now*/          /*error to stderr for now*/
         xmlXPathObject_auto_ptr res(          xmlXPathObject_auto_ptr res(
                 xmlXPathEvalExpression(BAD_CAST r.transcode(expression)->str, ctxt.get()));                  xmlXPathEvalExpression(r.transcode(expression), ctxt.get()));
   
         if(xmlHaveGenericErrors()) {          if(xmlHaveGenericErrors())
                 GdomeException exc=0;                  throw XmlException(0);
                 throw XmlException(&expression, exc);  
         }  
   
         Value* result=0;          Value* result=0;
         if(res.get())          if(res.get())
                 handler(r, expression, res, vnode.get_xdoc(), result);                  handler(r, expression, res, vdoc, result);
         if(result)          if(result)
                 r.write_no_lang(*result);                  r.write_no_lang(*result);
 }  }
   
 static void selectNodesHandler(Request& r,  static void selectNodesHandler(Request&,
                                const String& expression,                                 const String& expression,
                                xmlXPathObject_auto_ptr res,                                 xmlXPathObject_auto_ptr res,
                                    VXdoc& xdoc,                                     VXdoc& xdoc,
Line 557  static void selectNodesHandler(Request& Line 731  static void selectNodesHandler(Request&
                                 for(int i=0; i<size; i++)                                  for(int i=0; i<size; i++)
                                         hash.put(                                          hash.put(
                                                 String::Body::Format(i),                                                   String::Body::Format(i), 
                                                 new VXnode(                                                  &xdoc.wrap(*res->nodesetval->nodeTab[i]));
                                                         &r.charsets,   
                                                         xdoc,  
                                                         gdome_xml_n_mkref(res->nodesetval->nodeTab[i])));  
                         }                          }
                 break;                  break;
         default:           default: 
                 throw Exception(0,                  throw Exception(PARSER_RUNTIME,
                         &expression,                          &expression,
                         "wrong xmlXPathEvalExpression result type (%d)", res->type);                          "wrong xmlXPathEvalExpression result type (%d)", res->type);
                 break; // never                  break; // never
Line 580  static void selectNodeHandler(Request& r Line 751  static void selectNodeHandler(Request& r
         case XPATH_UNDEFINED:           case XPATH_UNDEFINED: 
                 break;                  break;
         case XPATH_NODESET:           case XPATH_NODESET: 
                 if(res->nodesetval && res->nodesetval->nodeNr) { // empty result strangly has NODESET  res->type                  if(res->nodesetval && res->nodesetval->nodeNr) { // empty result strangely has NODESET  res->type
                         if(res->nodesetval->nodeNr>1)                          if(res->nodesetval->nodeNr>1)
                                 throw Exception("parser.runtime",                                  throw Exception(PARSER_RUNTIME,
                                         &expression,                                          &expression,
                                         "resulted not in a single node (%d)", res->nodesetval->nodeNr);                                          "resulted not in a single node (%d)", res->nodesetval->nodeNr);
                                                   
                         result=new VXnode(                          result=&xdoc.wrap(*res->nodesetval->nodeTab[0]);
                                 &r.charsets,   
                                 xdoc,  
                                 gdome_xml_n_mkref(res->nodesetval->nodeTab[0]));  
                 }                  }
                 break;                  break;
         case XPATH_BOOLEAN:           case XPATH_BOOLEAN: 
                 result=new VBool(res->boolval!=0);                  result=&VBool::get(res->boolval!=0);
                 break;                  break;
         case XPATH_NUMBER:           case XPATH_NUMBER: 
                 result=new VDouble(res->floatval);                  result=new VDouble(res->floatval);
Line 602  static void selectNodeHandler(Request& r Line 770  static void selectNodeHandler(Request& r
                 result=new VString(r.transcode((xmlChar*)res->stringval));                  result=new VString(r.transcode((xmlChar*)res->stringval));
                 break;                  break;
         default:           default: 
                 throw Exception("parser.runtime",                  throw Exception(PARSER_RUNTIME,
                         &expression,                          &expression,
                         "wrong xmlXPathEvalExpression result type (%d)", res->type);                          "wrong xmlXPathEvalExpression result type (%d)", res->type);
                 // result=0;  
                 break; // never  
         }          }
 }  }
   
Line 617  static void selectBoolHandler(Request&, Line 783  static void selectBoolHandler(Request&,
                               Value*& result) {                                Value*& result) {
         switch(res->type) {          switch(res->type) {
         case XPATH_BOOLEAN:           case XPATH_BOOLEAN: 
                 result=new VBool(res->boolval!=0);                  result=&VBool::get(res->boolval!=0);
                 break;                  break;
         case XPATH_NODESET:           case XPATH_NODESET: 
                 if(!(res->nodesetval && res->nodesetval->nodeNr))                  if(!(res->nodesetval && res->nodesetval->nodeNr))
                         break;                          break;
                 // else[nodeset] fall down to default                  // else[nodeset] fall down to default
         default:           default: 
                 throw Exception("parser.runtime",                  throw Exception(PARSER_RUNTIME,
                         &expression,                          &expression,
                         "wrong xmlXPathEvalExpression result type (%d)", res->type);                          "wrong xmlXPathEvalExpression result type (%d)", res->type);
                 break; // never                  break; // never
Line 645  static void selectNumberHandler(Request& Line 811  static void selectNumberHandler(Request&
                         break;                          break;
                 // else[nodeset] fall down to default                  // else[nodeset] fall down to default
         default:           default: 
                 throw Exception("parser.runtime",                  throw Exception(PARSER_RUNTIME,
                         &expression,                          &expression,
                         "wrong xmlXPathEvalExpression result type (%d)", res->type);                          "wrong xmlXPathEvalExpression result type (%d)", res->type);
                 break; // never                  break; // never
Line 668  static void selectStringHandler(Request& Line 834  static void selectStringHandler(Request&
                         break;                          break;
                 // else[nodeset] fall down to default                  // else[nodeset] fall down to default
         default:           default: 
                 throw Exception("parser.runtime",                  throw Exception(PARSER_RUNTIME,
                         &expression,                          &expression,
                         "wrong xmlXPathEvalExpression result type (%d)", res->type);                          "wrong xmlXPathEvalExpression result type (%d)", res->type);
                 break; // never                  break; // never
Line 753  MXnode::MXnode(const char* aname, VState Line 919  MXnode::MXnode(const char* aname, VState
         // Attr getAttributeNodeNS(in DOMString namespaceURI, in DOMString localName);          // Attr getAttributeNodeNS(in DOMString namespaceURI, in DOMString localName);
         add_native_method("getAttributeNodeNS", Method::CT_DYNAMIC, _getAttributeNodeNS, 2, 2);          add_native_method("getAttributeNodeNS", Method::CT_DYNAMIC, _getAttributeNodeNS, 2, 2);
         // Attr setAttributeNodeNS(in Attr newAttr) raises(DOMException);          // Attr setAttributeNodeNS(in Attr newAttr) raises(DOMException);
         add_native_method("setAttributeNodeNS", Method::CT_DYNAMIC, _setAttributeNodeNS, 1, 1);          add_native_method("setAttributeNodeNS", Method::CT_DYNAMIC, _setAttributeNode, 1, 1);
         // boolean hasAttribute(in DOMString name) raises(DOMException);          // boolean hasAttribute(in DOMString name) raises(DOMException);
         add_native_method("hasAttribute", Method::CT_DYNAMIC, _hasAttribute, 1, 1);          add_native_method("hasAttribute", Method::CT_DYNAMIC, _hasAttribute, 1, 1);
         // boolean hasAttributeNS(in DOMString namespaceURI, in DOMString localName) raises(DOMException);          // boolean hasAttributeNS(in DOMString namespaceURI, in DOMString localName) raises(DOMException);
         add_native_method("hasAttributeNS", Method::CT_DYNAMIC, _hasAttributeNS, 2, 2);          add_native_method("hasAttributeNS", Method::CT_DYNAMIC, _hasAttributeNS, 2, 2);
           // boolean hasAttributes
           add_native_method("hasAttributes", Method::CT_DYNAMIC, _hasAttributes, 0, 0);
           
   
         /// parser          /// parser
         // ^node.select[/some/xpath/query] = hash $.#[dnode]          // ^node.select[/some/xpath/query] = hash $.#[dnode]
Line 775  MXnode::MXnode(const char* aname, VState Line 944  MXnode::MXnode(const char* aname, VState
         // consts          // consts
   
 #define CONST(name) \  #define CONST(name) \
         consts.put(String::Body(#name), new VInt(GDOME_##name))          consts.put(String::Body(#name), new VInt(XML_##name))
   #define CONST2(name, value) \
           consts.put(String::Body(#name), new VInt(value))
   
         CONST(ELEMENT_NODE);          CONST(ELEMENT_NODE);
         CONST(ATTRIBUTE_NODE);          CONST(ATTRIBUTE_NODE);
         CONST(TEXT_NODE);          CONST(TEXT_NODE);
         CONST(CDATA_SECTION_NODE);          CONST(CDATA_SECTION_NODE);
         CONST(ENTITY_REFERENCE_NODE);          CONST2(ENTITY_REFERENCE_NODE, XML_ENTITY_REF_NODE);
         CONST(ENTITY_NODE);          CONST(ENTITY_NODE);
         CONST(PROCESSING_INSTRUCTION_NODE);          CONST2(PROCESSING_INSTRUCTION_NODE, XML_PI_NODE);
         CONST(COMMENT_NODE);          CONST(COMMENT_NODE);
         CONST(DOCUMENT_NODE);          CONST(DOCUMENT_NODE);
         CONST(DOCUMENT_TYPE_NODE);          CONST(DOCUMENT_TYPE_NODE);
         CONST(DOCUMENT_FRAGMENT_NODE);          CONST2(DOCUMENT_FRAGMENT_NODE, XML_DOCUMENT_FRAG_NODE);
         CONST(NOTATION_NODE);          CONST(NOTATION_NODE);
 }  }
   

Removed from v.1.71  
changed lines
  Added in v.1.87


E-mail: