--- parser3/src/classes/xnode.C 2005/12/16 15:08:46 1.73 +++ parser3/src/classes/xnode.C 2007/02/03 18:08:38 1.76 @@ -7,7 +7,7 @@ #include "classes.h" #ifdef XML -static const char * const IDENT_XNODE_C="$Date: 2005/12/16 15:08:46 $"; +static const char * const IDENT_XNODE_C="$Date: 2007/02/03 18:08:38 $"; #include "pa_vmethod_frame.h" @@ -17,6 +17,7 @@ static const char * const IDENT_XNODE_C= #include "pa_vxdoc.h" #include "pa_vvoid.h" #include "pa_xml_exception.h" +#include "pa_vbool.h" #include "xnode.h" #include "libxml/xpath.h" @@ -170,7 +171,7 @@ xmlNs& pa_xmlMapNs(xmlDoc& doc, const xm static void pa_addAttributeNode(xmlNode& selfNode, xmlAttr& attrNode) { if(attrNode.type!=XML_ATTRIBUTE_NODE) - throw Exception("xml", + throw Exception("parser.runtime", 0, "must be ATTRIBUTE_NODE"); @@ -265,17 +266,22 @@ static void _replaceChild(Request& r, Me xmlDoc& xmldoc=vxdoc.get_xmldoc(); xmlNode& selfNode=vnode.get_xmlnode(); xmlNode& newChild=as_node(params, 0, "newChild must be node"); - xmlNode& oldChild=as_node(params, 1, "refChild must be node"); + xmlNode& oldChild=as_node(params, 1, "oldChild must be node"); if(newChild.doc!=&xmldoc) - throw Exception("xml", + throw Exception("xml.dom", 0, "WRONG_DOCUMENT_ERR"); if(oldChild.doc!=&xmldoc) - throw Exception("xml", + 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; @@ -297,7 +303,7 @@ static void _removeChild(Request& r, Met xmlNode& oldChild=as_node(params, 0, "refChild must be node"); if(oldChild.doc!=&xmldoc) - throw Exception("xml", + throw Exception("xml.dom", 0, "WRONG_DOCUMENT_ERR"); @@ -412,12 +418,12 @@ static void _setAttributeNode(Request& r xmlAttr& newAttr=as_attr(params, 0, "newAttr must be ATTRIBUTE node"); if(newAttr.doc!=&xmldoc) - throw Exception("xml", + throw Exception("xml.dom", 0, "WRONG_DOCUMENT_ERR"); if(newAttr.parent) - throw Exception("xml", + throw Exception("xml.dom", 0, "INUSE_ATTRIBUTE_ERR"); @@ -438,7 +444,7 @@ static void _removeAttributeNode(Request xmlAttr& oldAttr=as_attr(params, 0, "oldAttr must be ATTRIBUTE node"); if(oldAttr.parent!=&element) - throw Exception("xml", + throw Exception("xml.dom", 0, "NOT_FOUND_ERR"); @@ -631,7 +637,7 @@ static void _selectX(Request& r, MethodP Value*& result)) { VXnode& vnode=GET_SELF(r, VXnode); - xmlNode& element=get_self_element(vnode); + xmlNode& xmlnode=vnode.get_xmlnode(); VXdoc& vdoc=vnode.get_vxdoc(); xmlDoc& xmldoc=vdoc.get_xmldoc(); @@ -640,9 +646,9 @@ static void _selectX(Request& r, MethodP xmlXPathContext_auto_ptr ctxt(xmlXPathNewContext(&xmldoc)); { Register_one_ns_info info={&r, ctxt.get()}; - vdoc.search_namespaces.hash().for_each(register_one_ns, &info); + vdoc.search_namespaces.hash().for_each(register_one_ns, &info); } - ctxt->node=&element; + ctxt->node=&xmlnode; /*error to stderr for now*/ xmlXPathObject_auto_ptr res( xmlXPathEvalExpression(r.transcode(expression), ctxt.get())); @@ -677,7 +683,7 @@ static void selectNodesHandler(Request&, } break; default: - throw Exception(0, + throw Exception("parser.runtime", &expression, "wrong xmlXPathEvalExpression result type (%d)", res->type); break; // never