--- parser3/src/classes/xdoc.C 2002/02/08 08:30:10 1.85 +++ parser3/src/classes/xdoc.C 2002/04/09 15:27:13 1.89 @@ -4,7 +4,7 @@ Copyright (c) 2001, 2002 ArtLebedev Group (http://www.artlebedev.com) Author: Alexandr Petrosian (http://paf.design.ru) - $Id: xdoc.C,v 1.85 2002/02/08 08:30:10 paf Exp $ + $Id: xdoc.C,v 1.89 2002/04/09 15:27:13 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); } @@ -375,7 +311,7 @@ static void _importNode(Request& r, cons VXdoc& vdoc=*static_cast(r.self); GdomeNode *importedNode= - as_node(pool, method_name, params, 0, "importedNode must be node"); + as_node(method_name, params, 0, "importedNode must be node"); bool deep= params->as_bool(1, "deep must be bool", r); @@ -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); } @@ -690,9 +626,9 @@ static void add_xslt_param(const Hash::K void *info) { Value *meaning=static_cast(ameaning); Pool& pool=meaning->pool(); - const char **transform_params=(const char **)info; - *transform_params++=pool.transcode(aattribute)->str; - *transform_params++=pool.transcode(meaning->as_string())->str; + const char ** & current_transform_param=*(const char ***)info; + *current_transform_param++=pool.transcode(aattribute)->str; + *current_transform_param++=pool.transcode(meaning->as_string())->str; } static void _transform(Request& r, const String& method_name, MethodParams *params) { //_asm int 3; @@ -705,12 +641,12 @@ static void _transform(Request& r, const Value& vparams=params->as_no_junction(1, "transform parameters must be hash"); if(vparams.is_defined()) if(Hash *params=vparams.get_hash(&method_name)) { - transform_params= - (const char **)pool.malloc(sizeof(const char *)*params->size()*2+1); - params->for_each(add_xslt_param, transform_params); + const char **current_transform_param=transform_params= + (const char **)pool.malloc(sizeof(const char *)*(params->size()*2+1)); + params->for_each(add_xslt_param, ¤t_transform_param); 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