--- parser3/src/classes/xnode.C 2002/01/14 15:29:41 1.26 +++ parser3/src/classes/xnode.C 2002/01/24 14:10:08 1.32 @@ -4,7 +4,7 @@ Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com) Author: Alexander Petrosyan (http://paf.design.ru) - $Id: xnode.C,v 1.26 2002/01/14 15:29:41 paf Exp $ + $Id: xnode.C,v 1.32 2002/01/24 14:10:08 paf Exp $ */ #include "classes.h" #ifdef XML @@ -18,8 +18,8 @@ extern "C" { #include "gdomecore/gdome-xml-node.h" -}; #include "gdomecore/gdome-xml-document.h" +}; #include "gdome.h" #include "libxml/xpath.h" @@ -27,8 +27,8 @@ extern "C" { class xmlXPathObject_auto_ptr { public: - explicit xmlXPathObject_auto_ptr(xmlXPathObject *_P = 0) - : _Owns(_P != 0), _Ptr(_P) {} + explicit xmlXPathObject_auto_ptr(xmlXPathObject *_APtr = 0) + : _Owns(_APtr != 0), _Ptr(_APtr) {} xmlXPathObject_auto_ptr(const xmlXPathObject_auto_ptr& _Y) : _Owns(_Y._Owns), _Ptr(_Y.release()) {} xmlXPathObject_auto_ptr& operator=(const xmlXPathObject_auto_ptr& _Y) @@ -60,8 +60,8 @@ private: class xmlXPathContext_auto_ptr { public: - explicit xmlXPathContext_auto_ptr(xmlXPathContext *_P = 0) - : _Owns(_P != 0), _Ptr(_P) {} + explicit xmlXPathContext_auto_ptr(xmlXPathContext *_APtr = 0) + : _Owns(_APtr != 0), _Ptr(_APtr) {} xmlXPathContext_auto_ptr(const xmlXPathContext_auto_ptr& _Y) : _Owns(_Y._Owns), _Ptr(_Y.release()) {} xmlXPathContext_auto_ptr& operator=(const xmlXPathContext_auto_ptr& _Y) @@ -396,15 +396,22 @@ static void _selectX(Request& r, const S GdomeException exc; GdomeNode *dome_node=vnode.get_node(&method_name); GdomeDocument *dome_document=gdome_n_ownerDocument(dome_node, &exc); - if(!dome_document) - dome_document=GDOME_DOC(dome_node); + 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_Document *)dome_document)->n; xmlXPathContext_auto_ptr ctxt(xmlXPathNewContext(xml_document)); - ctxt->node=xmlDocGetRootElement(xml_document); + ctxt->node=gdome_xml_n_get_xmlNode(dome_node); /*error to stderr for now*/ xmlXPathObject_auto_ptr res( xmlXPathEvalExpression(BAD_CAST pool.transcode(expression)->str, ctxt.get())); + if(xmlHaveGenericErrors()) { + GdomeException exc=0; + throw Exception(0, 0, + &expression, + exc); + } + Value *result=0; if(res.get()) handler(pool, expression, res, result); @@ -418,12 +425,12 @@ static void selectNodesHandler(Pool& poo const String& expression, xmlXPathObject_auto_ptr res, Value *& result) { + VHash *vhash=new(pool) VHash(pool); result=vhash; switch(res->type) { case XPATH_UNDEFINED: break; case XPATH_NODESET: if(int size=res->nodesetval->nodeNr) { - VHash *vhash=new(pool) VHash(pool); Hash& hash=vhash->hash(0); for(int i=0; inodesetval->nodeTab[0]))); + gdome_xml_n_mkref(res->nodesetval->nodeTab[i]))); } - result=vhash; } break; default: