--- parser3/src/classes/xdoc.C 2002/02/07 12:15:47 1.83 +++ parser3/src/classes/xdoc.C 2002/03/27 15:30:34 1.87 @@ -1,10 +1,10 @@ /** @file Parser: @b xdoc parser class. - Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com) - Author: Alexander Petrosyan (http://paf.design.ru) + Copyright (c) 2001, 2002 ArtLebedev Group (http://www.artlebedev.com) + Author: Alexandr Petrosian (http://paf.design.ru) - $Id: xdoc.C,v 1.83 2002/02/07 12:15:47 paf Exp $ + $Id: xdoc.C,v 1.87 2002/03/27 15:30:34 paf Exp $ */ #include "classes.h" #ifdef XML @@ -155,7 +155,7 @@ private: static void writeNode(Request& r, const String& method_name, GdomeNode *node, GdomeException exc) { if(!node || exc) - throw Exception(0, 0, + throw Exception( &method_name, exc); @@ -285,70 +285,6 @@ static void _createEntityReference(Reque writeNode(r, method_name, node, exc); } -static void _getElementsByTagName(Request& r, const String& method_name, MethodParams *params) { - Pool& pool=r.pool(); - VXdoc& vdoc=*static_cast(r.self); - - const String& name=params->as_string(0, "name must be string"); - - GdomeException exc; - VHash& result=*new(pool) VHash(pool); - if(GdomeNodeList *nodes= - gdome_doc_getElementsByTagName( - vdoc.get_document(&method_name), - pool.transcode(name).get(), - &exc)) { - gulong length=gdome_nl_length(nodes, &exc); - for(gulong i=0; i(r.self); - - // namespaceURI;localName - const String& namespaceURI=params->as_string(0, "namespaceURI must be string"); - const String& localName=params->as_string(0, "localName must be string"); - - GdomeException exc; - VHash& result=*new(pool) VHash(pool); - if(GdomeNodeList *nodes= - gdome_doc_getElementsByTagNameNS( - vdoc.get_document(&method_name), - pool.transcode(namespaceURI).get(), - pool.transcode(localName).get(), - &exc)) { - gulong length=gdome_nl_length(nodes, &exc); - for(gulong i=0; i(r.self); @@ -365,7 +301,7 @@ static void _getElementById(Request& r, VXnode& result=*new(pool) VXnode(pool, node); r.write_no_lang(result); } else if(exc || xmlHaveGenericErrors()) - throw Exception(0, 0, + throw Exception( &method_name, exc); } @@ -384,7 +320,7 @@ static void _importNode(Request& r, cons importedNode, deep, &exc); if(exc) - throw Exception(0, 0, + throw Exception( &method_name, exc); @@ -415,7 +351,7 @@ static void _create(Request& r, const St )); if(!document || xmlHaveGenericErrors()) { GdomeException exc=0; - throw Exception(0, 0, + throw Exception( &method_name, exc); } @@ -431,7 +367,7 @@ static void _create(Request& r, const St 0/*systemId* /, &exc); if(!documentType || exc || xmlHaveGenericErrors()) - throw Exception(0, 0, + throw Exception( &method_name, exc); */ @@ -441,7 +377,7 @@ static void _create(Request& r, const St 0/*doctype*/, &exc); if(!document || exc || xmlHaveGenericErrors()) - throw Exception(0, 0, + throw Exception( &method_name, exc); @@ -463,7 +399,7 @@ static void _load(Request& r, const Stri gdome_xml_n_mkref((xmlNode *)xmlParseFile(uri.cstr())); if(!document || xmlHaveGenericErrors()) { GdomeException exc=0; - throw Exception(0, 0, + throw Exception( &uri, exc); } @@ -490,7 +426,7 @@ static void param_option_over_output_opt else if(s=="no") output_option=false; else - throw Exception(0, 0, + throw Exception("parser.runtime", &s, "%s must be either 'yes' or 'no'", option_name); } @@ -571,7 +507,7 @@ static void xdoc2buf(Pool& pool, VXdoc& const char *encoding_cstr=oo.encoding->cstr(); xmlCharEncodingHandler *encoder=xmlFindCharEncodingHandler(encoding_cstr); if(!encoder) - throw Exception(0, 0, + throw Exception("parser.runtime", &method_name, "encoding '%s' not supported", encoding_cstr); // UTF-8 encoder contains empty input/output converters, @@ -584,7 +520,7 @@ static void xdoc2buf(Pool& pool, VXdoc& xsltStylesheet_auto_ptr stylesheet(xsltNewStylesheet()); if(!stylesheet.get()) - throw Exception(0, 0, + throw Exception(0, &method_name, "xsltNewStylesheet failed"); @@ -606,7 +542,7 @@ static void xdoc2buf(Pool& pool, VXdoc& xmlDoc *document=gdome_xml_doc_get_xmlDoc(vdoc.get_document(&method_name)); if(xsltSaveResultTo(outputBuffer.get(), document, stylesheet.get())<0) { GdomeException exc=0; - throw Exception(0, 0, + throw Exception( &method_name, exc); } @@ -710,7 +646,7 @@ static void _transform(Request& r, const params->for_each(add_xslt_param, transform_params); transform_params[params->size()*2]=0; } else - throw Exception(0, 0, + throw Exception("parser.runtime", &method_name, "transform parameters parameter must be hash"); } @@ -733,7 +669,7 @@ static void _transform(Request& r, const transformContext.get()); if(!transformed || xmlHaveGenericErrors()) { GdomeException exc=0; - throw Exception(0, 0, + throw Exception( &stylesheet_filespec, exc); } @@ -743,7 +679,7 @@ static void _transform(Request& r, const // constructing result GdomeDocument *gdomeDocument=gdome_xml_doc_mkref(transformed); if(!gdomeDocument) - throw Exception(0, 0, + throw Exception(0, &method_name, "gdome_xml_doc_mkref failed"); VXdoc& result=*new(pool) VXdoc(pool, gdomeDocument); @@ -804,10 +740,6 @@ MXdoc::MXdoc(Pool& apool) : MXnode(apool add_native_method("createAttribute", Method::CT_DYNAMIC, _createAttribute, 1, 1); // EntityReference createEntityReference(in DOMString name) raises(DOMException); add_native_method("createEntityReference", Method::CT_DYNAMIC, _createEntityReference, 1, 1); - // NodeList getElementsByTagName(in DOMString tagname); - add_native_method("getElementsByTagName", Method::CT_DYNAMIC, _getElementsByTagName, 1, 1); - // ^xdoc.getElementsByTagNameNS[namespaceURI;localName] = array of nodes - add_native_method("getElementsByTagNameNS", Method::CT_DYNAMIC, _getElementsByTagNameNS, 2, 2); /// DOM2