--- parser3/src/classes/xnode.C 2002/02/19 15:03:10 1.39 +++ parser3/src/classes/xnode.C 2002/03/28 14:02:30 1.42 @@ -4,7 +4,7 @@ Copyright (c) 2001, 2002 ArtLebedev Group (http://www.artlebedev.com) Author: Alexandr Petrosian (http://paf.design.ru) - $Id: xnode.C,v 1.39 2002/02/19 15:03:10 paf Exp $ + $Id: xnode.C,v 1.42 2002/03/28 14:02:30 paf Exp $ */ #include "classes.h" #ifdef XML @@ -98,12 +98,12 @@ private: // helpers -GdomeNode *as_node(Pool& pool, const String& method_name, MethodParams *params, +GdomeNode *as_node(const String& method_name, MethodParams *params, int index, const char *msg) { Value& value=params->as_no_junction(index, msg); if(!(strcmp(value.type(), VXNODE_TYPE)==0 || strcmp(value.type(), VXDOC_TYPE)==0)) - throw Exception(0, 0, + throw Exception("parser.runtime", &method_name, msg); @@ -115,10 +115,10 @@ GdomeNode *as_node(Pool& pool, const Str GdomeAttr * as_attr(Pool& pool, const String& method_name, MethodParams *params, int index, const char *msg) { - GdomeNode *node=as_node(pool, method_name, params, index, msg); + GdomeNode *node=as_node(method_name, params, index, msg); GdomeException exc; if(gdome_n_nodeType(node, &exc)!=GDOME_ATTRIBUTE_NODE) - throw Exception(0, 0, + throw Exception("parser.runtime", &method_name, msg); @@ -134,8 +134,8 @@ static void _insertBefore(Request& r, co Pool& pool=r.pool(); VXnode& vnode=*static_cast(r.self); GdomeNode *selfNode=vnode.get_node(&method_name); - GdomeNode *newChild=as_node(pool, method_name, params, 0, "newChild must be node"); - GdomeNode *refChild=as_node(pool, method_name, params, 1, "refChild must be node"); + GdomeNode *newChild=as_node(method_name, params, 0, "newChild must be node"); + GdomeNode *refChild=as_node(method_name, params, 1, "refChild must be node"); GdomeException exc; if(GdomeNode *retNode=gdome_n_insertBefore(selfNode, newChild, refChild, &exc)) { @@ -143,7 +143,7 @@ static void _insertBefore(Request& r, co VXnode& result=*new(pool) VXnode(pool, retNode); r.write_no_lang(result); } else - throw Exception(0, 0, + throw Exception( &method_name, exc); } @@ -153,15 +153,15 @@ static void _replaceChild(Request& r, co Pool& pool=r.pool(); VXnode& vnode=*static_cast(r.self); GdomeNode *selfNode=vnode.get_node(&method_name); - GdomeNode *newChild=as_node(pool, method_name, params, 0, "newChild must be node"); - GdomeNode *refChild=as_node(pool, method_name, params, 1, "refChild must be node"); + GdomeNode *newChild=as_node(method_name, params, 0, "newChild must be node"); + GdomeNode *refChild=as_node(method_name, params, 1, "refChild must be node"); GdomeException exc; if(GdomeNode *retNode=gdome_n_replaceChild(selfNode, newChild, refChild, &exc)) { // write out result r.write_no_lang(*new(pool) VXnode(pool, retNode)); } else - throw Exception(0, 0, + throw Exception( &method_name, exc); } @@ -171,14 +171,14 @@ static void _removeChild(Request& r, con Pool& pool=r.pool(); VXnode& vnode=*static_cast(r.self); GdomeNode *selfNode=vnode.get_node(&method_name); - GdomeNode *oldChild=as_node(pool, method_name, params, 0, "oldChild must be node"); + GdomeNode *oldChild=as_node(method_name, params, 0, "oldChild must be node"); GdomeException exc; if(GdomeNode *retNode=gdome_n_removeChild(selfNode, oldChild, &exc)) { // write out result r.write_no_lang(*new(pool) VXnode(pool, retNode)); } else - throw Exception(0, 0, + throw Exception( &method_name, exc); } @@ -188,14 +188,14 @@ static void _appendChild(Request& r, con Pool& pool=r.pool(); VXnode& vnode=*static_cast(r.self); GdomeNode *selfNode=vnode.get_node(&method_name); - GdomeNode *newChild=as_node(pool, method_name, params, 0, "newChild must be node"); + GdomeNode *newChild=as_node(method_name, params, 0, "newChild must be node"); GdomeException exc; if(GdomeNode *retNode=gdome_n_appendChild(selfNode, newChild, &exc)) { // write out result r.write_no_lang(*new(pool) VXnode(pool, retNode)); } else - throw Exception(0, 0, + throw Exception( &method_name, exc); } @@ -237,7 +237,7 @@ GdomeElement *get_self_element(Request& GdomeException exc; if(gdome_n_nodeType(node, &exc)!=GDOME_ELEMENT_NODE) - throw Exception(0, 0, + throw Exception("parser.runtime", &method_name, "method can be called on node of ELEMENT type"); @@ -270,7 +270,7 @@ static void _setAttribute(Request& r, co pool.transcode(attribute_value).get(), &exc); if(exc) - throw Exception(0, 0, + throw Exception( &method_name, exc); } @@ -284,7 +284,7 @@ static void _removeAttribute(Request& r, GdomeException exc; gdome_el_removeAttribute(element, pool.transcode(name).get(), &exc); if(exc) - throw Exception(0, 0, + throw Exception( &method_name, exc); } @@ -301,7 +301,7 @@ static void _getAttributeNode(Request& r VXnode& result=*new(pool) VXnode(pool, (GdomeNode *)attr); r.write_no_lang(result); } else if(exc) - throw Exception(0, 0, + throw Exception( &method_name, exc); } @@ -318,7 +318,7 @@ static void _setAttributeNode(Request& r VXnode& result=*new(pool) VXnode(pool, (GdomeNode *)returnAttr); r.write_no_lang(result); } else - throw Exception(0, 0, + throw Exception( &method_name, exc); } @@ -332,7 +332,7 @@ static void _removeAttributeNode(Request GdomeException exc; gdome_el_removeAttributeNode(element, oldAttr, &exc); if(exc) - throw Exception(0, 0, + throw Exception( &method_name, exc); } @@ -360,7 +360,7 @@ static void _getElementsByTagName(Reques result.hash(0).put(skey, new(pool) VXnode(pool, gdome_nl_item(nodes, i, &exc))); } } else if(exc) - throw Exception(0, 0, + throw Exception( &method_name, exc); @@ -410,7 +410,7 @@ static void _normalize(Request& r, const GdomeException exc; gdome_n_normalize(selfNode, &exc); if(exc) - throw Exception(0, 0, + throw Exception( &method_name, exc); } @@ -441,9 +441,7 @@ static void _selectX(Request& r, const S if(xmlHaveGenericErrors()) { GdomeException exc=0; - throw Exception(0, 0, - &expression, - exc); + throw Exception(&expression, exc); } Value *result=0; @@ -464,23 +462,24 @@ static void selectNodesHandler(Pool& poo case XPATH_UNDEFINED: break; case XPATH_NODESET: - if(int size=res->nodesetval->nodeNr) { - Hash& hash=vhash->hash(0); - for(int i=0; inodesetval) + if(int size=res->nodesetval->nodeNr) { + Hash& hash=vhash->hash(0); + for(int i=0; inodesetval->nodeTab[i]))); + hash.put(skey, new(pool) VXnode(pool, + gdome_xml_n_mkref(res->nodesetval->nodeTab[i]))); + } } - } break; default: - throw Exception(0, 0, + throw Exception(0, &expression, "wrong xmlXPathEvalExpression result type (%d)", res->type); break; // never @@ -495,9 +494,9 @@ static void selectNodeHandler(Pool& pool case XPATH_UNDEFINED: break; case XPATH_NODESET: - if(res->nodesetval->nodeNr) { // empty result strangly has NODESET res->type + if(res->nodesetval && res->nodesetval->nodeNr) { // empty result strangly has NODESET res->type if(res->nodesetval->nodeNr>1) - throw Exception(0, 0, + throw Exception("parser.runtime", &expression, "resulted not in a single node (%d)", res->nodesetval->nodeNr); @@ -517,7 +516,7 @@ static void selectNodeHandler(Pool& pool gdome_str_mkref_dup((const gchar *)res->stringval)).get())); break; default: - throw Exception(0, 0, + throw Exception("parser.runtime", &expression, "wrong xmlXPathEvalExpression result type (%d)", res->type); break; // never @@ -533,11 +532,11 @@ static void selectBoolHandler(Pool& pool result=new(pool) VBool(pool, res->boolval!=0); break; case XPATH_NODESET: - if(!res->nodesetval->nodeNr) + if(!(res->nodesetval && res->nodesetval->nodeNr)) break; // else[nodeset] fall down to default default: - throw Exception(0, 0, + throw Exception("parser.runtime", &expression, "wrong xmlXPathEvalExpression result type (%d)", res->type); break; // never @@ -553,11 +552,11 @@ static void selectNumberHandler(Pool& po result=new(pool) VDouble(pool, res->floatval); break; case XPATH_NODESET: - if(!res->nodesetval->nodeNr) + if(!(res->nodesetval && res->nodesetval->nodeNr)) break; // else[nodeset] fall down to default default: - throw Exception(0, 0, + throw Exception("parser.runtime", &expression, "wrong xmlXPathEvalExpression result type (%d)", res->type); break; // never @@ -578,11 +577,11 @@ static void selectStringHandler(Pool& po gdome_str_mkref_dup((const gchar *)res->stringval)).get())); break; case XPATH_NODESET: - if(!res->nodesetval->nodeNr) + if(!(res->nodesetval && res->nodesetval->nodeNr)) break; // else[nodeset] fall down to default default: - throw Exception(0, 0, + throw Exception("parser.runtime", &expression, "wrong xmlXPathEvalExpression result type (%d)", res->type); break; // never