--- parser3/src/classes/xnode.C 2003/09/22 07:05:53 1.57 +++ parser3/src/classes/xnode.C 2004/02/11 15:33:13 1.65 @@ -1,13 +1,13 @@ /** @file Parser: @b dom parser class. - Copyright (c) 2001-2003 ArtLebedev Group (http://www.artlebedev.com) + Copyright (c) 2001-2004 ArtLebedev Group (http://www.artlebedev.com) Author: Alexandr Petrosian (http://paf.design.ru) */ #include "classes.h" #ifdef XML -static const char* IDENT_XNODE_C="$Date: 2003/09/22 07:05:53 $"; +static const char * const IDENT_XNODE_C="$Date: 2004/02/11 15:33:13 $"; #include "pa_vmethod_frame.h" @@ -16,6 +16,7 @@ static const char* IDENT_XNODE_C="$Date: #include "pa_vxnode.h" #include "pa_vxdoc.h" #include "pa_vvoid.h" +#include "pa_xml_exception.h" #include "xnode.h" @@ -110,7 +111,6 @@ GdomeNode* as_node(MethodParams& params, throw Exception("parser.runtime", 0, msg); - result=0; // calm, compiler } return result; @@ -146,7 +146,7 @@ static void _insertBefore(Request& r, Me // write out result r.write_no_lang(*new VXnode(&r.charsets, retNode)); } else - throw Exception(0, exc); + throw XmlException(0, exc); } // Node replaceChild(in Node newChild,in Node oldChild) raises(DOMException); @@ -154,14 +154,14 @@ static void _replaceChild(Request& r, Me VXnode& vnode=GET_SELF(r, VXnode); GdomeNode* selfNode=vnode.get_node(); GdomeNode* newChild=as_node(params, 0, "newChild must be node"); - GdomeNode* refChild=as_node(params, 1, "refChild must be node"); + GdomeNode* oldChild=as_node(params, 1, "oldChild must be node"); GdomeException exc; - if(GdomeNode* retNode=gdome_n_replaceChild(selfNode, newChild, refChild, &exc)) { + if(GdomeNode* retNode=gdome_n_replaceChild(selfNode, newChild, oldChild, &exc)) { // write out result r.write_no_lang(*new VXnode(&r.charsets, retNode)); } else - throw Exception(0, exc); + throw XmlException(0, exc); } // Node removeChild(in Node oldChild) raises(DOMException); @@ -175,7 +175,7 @@ static void _removeChild(Request& r, Met // write out result r.write_no_lang(*new VXnode(&r.charsets, retNode)); } else - throw Exception(0, exc); + throw XmlException(0, exc); } // Node appendChild(in Node newChild) raises(DOMException); @@ -189,7 +189,7 @@ static void _appendChild(Request& r, Met // write out result r.write_no_lang(*new VXnode(&r.charsets, retNode)); } else - throw Exception(0, exc); + throw XmlException(0, exc); } // boolean hasChildNodes(); @@ -232,7 +232,7 @@ GdomeElement* get_self_element(Request& -// DOMString getAttribute(in DOMString name); +/// @bug attribute_value must be freed! [// DOMString getAttribute(in DOMString name); static void _getAttribute(Request& r, MethodParams& params) { GdomeElement* element=get_self_element(r); const String& name=params.as_string(0, "name must be string"); @@ -256,7 +256,7 @@ static void _setAttribute(Request& r, Me r.transcode(attribute_value).use(), &exc); if(exc) - throw Exception(0, exc); + throw XmlException(0, exc); } // void removeAttribute(in DOMString name) raises(DOMException); @@ -267,7 +267,7 @@ static void _removeAttribute(Request& r, GdomeException exc; gdome_el_removeAttribute(element, r.transcode(name).use(), &exc); if(exc) - throw Exception(0, exc); + throw XmlException(0, exc); } // Attr getAttributeNode(in DOMString name); @@ -281,9 +281,7 @@ static void _getAttributeNode(Request& r // write out result r.write_no_lang(*new VXnode(&r.charsets, (GdomeNode* )attr)); } else if(exc) - throw Exception( - 0, - exc); + throw XmlException(0, exc); } // Attr setAttributeNode(in Attr newAttr) raises(DOMException); @@ -296,9 +294,7 @@ static void _setAttributeNode(Request& r // write out result r.write_no_lang(*new VXnode(&r.charsets, (GdomeNode* )returnAttr)); } else - throw Exception( - 0, - exc); + throw XmlException(0, exc); } // Attr removeAttributeNode(in Attr oldAttr) raises(DOMException); @@ -309,9 +305,7 @@ static void _removeAttributeNode(Request GdomeException exc; gdome_el_removeAttributeNode(element, oldAttr, &exc); if(exc) - throw Exception( - 0, - exc); + throw XmlException(0, exc); } // NodeList getElementsByTagName(in DOMString name); @@ -327,12 +321,10 @@ static void _getElementsByTagName(Reques gulong length=gdome_nl_length(nodes, &exc); for(gulong i=0; inodesetval->nodeTab[i]))); @@ -588,7 +574,7 @@ static void selectNodeHandler(Request& r } } -static void selectBoolHandler(Request& r, +static void selectBoolHandler(Request&, const String& expression, xmlXPathObject_auto_ptr res, Value*& result) { @@ -608,7 +594,7 @@ static void selectBoolHandler(Request& r } } -static void selectNumberHandler(Request& r, +static void selectNumberHandler(Request&, const String& expression, xmlXPathObject_auto_ptr res, Value*& result) { @@ -719,19 +705,19 @@ MXnode::MXnode(const char* aname, VState /// DOM2 element - // DOMString getAttributeNS(in DOMString name); + // DOMString getAttributeNS(in DOMString namespaceURI, in DOMString localName); add_native_method("getAttributeNS", Method::CT_DYNAMIC, _getAttributeNS, 2, 2); - // void setAttributeNS(in DOMString name, in DOMString value) raises(DOMException); + // void setAttributeNS(in DOMString namespaceURI, in DOMString qualifiedName, in DOMString value) raises(DOMException); add_native_method("setAttributeNS", Method::CT_DYNAMIC, _setAttributeNS, 3, 3); - // void removeAttributeNS(in DOMString name) raises(DOMException); + // void removeAttributeNS(in DOMString namespaceURI, in DOMString localName) raises(DOMException); add_native_method("removeAttributeNS", Method::CT_DYNAMIC, _removeAttributeNS, 2, 2); - // Attr getAttributeNodeNS(in DOMString name); + // Attr getAttributeNodeNS(in DOMString namespaceURI, in DOMString localName); add_native_method("getAttributeNodeNS", Method::CT_DYNAMIC, _getAttributeNodeNS, 2, 2); // Attr setAttributeNodeNS(in Attr newAttr) raises(DOMException); add_native_method("setAttributeNodeNS", Method::CT_DYNAMIC, _setAttributeNodeNS, 1, 1); - // boolean hasAttribute(in Attr newAttr) raises(DOMException); + // boolean hasAttribute(in DOMString name) raises(DOMException); add_native_method("hasAttribute", Method::CT_DYNAMIC, _hasAttribute, 1, 1); - // boolean hasAttributeNS(in Attr newAttr) raises(DOMException); + // boolean hasAttributeNS(in DOMString namespaceURI, in DOMString localName) raises(DOMException); add_native_method("hasAttributeNS", Method::CT_DYNAMIC, _hasAttributeNS, 2, 2); /// parser @@ -750,7 +736,7 @@ MXnode::MXnode(const char* aname, VState // consts #define CONST(name) \ - consts.put(StringBody(#name), new VInt(GDOME_##name)) + consts.put(String::Body(#name), new VInt(GDOME_##name)) CONST(ELEMENT_NODE); CONST(ATTRIBUTE_NODE);