--- parser3/src/classes/xdoc.C 2003/09/22 07:05:52 1.112 +++ parser3/src/classes/xdoc.C 2003/11/20 17:22:48 1.121 @@ -9,7 +9,7 @@ #ifdef XML -static const char* IDENT_XDOC_C="$Date: 2003/09/22 07:05:52 $"; +static const char * const IDENT_XDOC_C="$Date: 2003/11/20 17:22:48 $"; #include "gdome.h" #include "libxml/tree.h" @@ -26,6 +26,7 @@ static const char* IDENT_XDOC_C="$Date: #include "pa_vxdoc.h" #include "pa_charset.h" #include "pa_vfile.h" +#include "pa_xml_exception.h" #include "xnode.h" // defines @@ -41,13 +42,11 @@ static const char* IDENT_XDOC_C="$Date: class MXdoc: public MXnode { public: // VStateless_class - Value* create_new_value() { return new VXdoc(0, 0); } + Value* create_new_value(Pool&) { return new VXdoc(0, 0); } public: MXdoc(); -public: // Methoded - void configure_admin(Request& r); }; // global variable @@ -160,7 +159,7 @@ private: static void writeNode(Request& r, GdomeNode *node, GdomeException exc) { if(!node || exc) - throw Exception(0, exc); + throw XmlException(0, exc); // write out result r.write_no_lang(*new VXnode(&r.charsets, node)); @@ -180,19 +179,19 @@ static void _createElement(Request& r, M writeNode(r, node, exc); } -// Element createElementNS(in DOMString localName) raises(DOMException); +// Element createElementNS(in DOMString namespaceURI, in DOMString qualifiedName) raises(DOMException); static void _createElementNS(Request& r, MethodParams& params) { VXdoc& vdoc=GET_SELF(r, VXdoc); // namespaceURI;localName const String& namespaceURI=params.as_string(0, "namespaceURI must be string"); - const String& localName=params.as_string(1, "localName must be string"); + const String& qualifiedName=params.as_string(1, "qualifiedName must be string"); GdomeException exc; GdomeNode *node= (GdomeNode *)gdome_doc_createElementNS(vdoc.get_document(), r.transcode(namespaceURI).use(), - r.transcode(localName).use(), + r.transcode(qualifiedName).use(), &exc); writeNode(r, node, exc); } @@ -281,7 +280,7 @@ static void _createAttribute(Request& r, writeNode(r, node, exc); } -// Attr createAttributeNS(in DOMString name) raises(DOMException); +// Attr createAttributeNS(in DOMString namespaceURI, in DOMString qualifiedName) raises(DOMException); static void _createAttributeNS(Request& r, MethodParams& params) { VXdoc& vdoc=GET_SELF(r, VXdoc); @@ -328,10 +327,10 @@ static void _getElementsByTagName(Reques gulong length=gdome_nl_length(nodes, &exc); for(gulong i=0; ias_string(); } static void param_option_over_output_option( HashStringValue& param_options, const char* option_name, bool& output_option) { - if(Value* value=param_options.get(StringBody(option_name))) { + if(Value* value=param_options.get(String::Body(option_name))) { const String& s=value->as_string(); if(s=="yes") output_option=true; @@ -561,7 +558,7 @@ static void prepare_output_options(Reque if(voptions.is_defined()) { if(HashStringValue *options=voptions.get_hash()) { // $.method[xml|html|text] - if(Value* vmethod=options->get(StringBody(XDOC_OUTPUT_METHOD_OPTION_NAME))) + if(Value* vmethod=options->get(String::Body(XDOC_OUTPUT_METHOD_OPTION_NAME))) oo.method=&vmethod->as_string(); // $.version[1.0] @@ -651,7 +648,7 @@ static Xdoc2buf_result xdoc2buf(Request& xmlDoc *document=gdome_xml_doc_get_xmlDoc(vdoc.get_document()); if(xsltSaveResultTo(outputBuffer.get(), document, stylesheet.get())<0) { GdomeException exc=0; - throw Exception(0, exc); + throw XmlException(0, exc); } // write out result @@ -664,14 +661,15 @@ static Xdoc2buf_result xdoc2buf(Request& gnome_str=(char *)outputBuffer->buffer->content; } + if((result.length=gnome_length)) { + result.str=pa_strdup(gnome_str, gnome_length); + } else + result.str=0; + if(file_spec) file_write(*file_spec, gnome_str, gnome_length, true/*as_text*/); - else if(result.length=gnome_length) { - result.str=pa_strdup(gnome_str, gnome_length); - } else - result.str=0; return result; } @@ -692,7 +690,7 @@ static void _file(Request& r, MethodPara value_name, new VString(*oo.mediaType)); vhcontent_type.hash().put( - StringBody("charset"), + String::Body("charset"), new VString(*oo.encoding)); vfile.set(false/*tainted*/, buf.str?buf.str:""/*to distinguish from stat-ed file*/, buf.length, @@ -755,7 +753,7 @@ static VXdoc& _transform(Request& r, con transformContext.get()); if(!transformed || xmlHaveGenericErrors()) { GdomeException exc=0; - throw Exception(stylesheet_source, exc); + throw XmlException(stylesheet_source, exc); } //gdome_xml_doc_mkref dislikes XML_HTML_DOCUMENT_NODE type, fixing @@ -832,7 +830,7 @@ static void _transform(Request& r, Metho stylesheet_ptr->doc=0; if(xmlHaveGenericErrors()) { GdomeException exc=0; - throw Exception(0, exc); + throw XmlException(0, exc); } if(!stylesheet_ptr.get()) throw Exception("xml", @@ -893,10 +891,10 @@ MXdoc::MXdoc(): MXnode(XDOC_CLASS_NAME, // Node (in Node importedNode, in boolean deep) raises(DOMException) add_native_method("importNode", Method::CT_DYNAMIC, _importNode, 2, 2); - // Attr createAttributeNS(in DOMString name) raises(DOMException); + // Attr createAttributeNS(in DOMString namespaceURI, in DOMString qualifiedName) raises(DOMException); add_native_method("createAttributeNS", Method::CT_DYNAMIC, _createAttributeNS, 2, 2); - // Element createElementNS(in DOMString tagName) raises(DOMException); + // Element createElementNS(in DOMString namespaceURI, in DOMString qualifiedName) raises(DOMException); add_native_method("createElementNS", Method::CT_DYNAMIC, _createElementNS, 2, 2); // NodeList getElementsByTagNameNS(in DOMString namespaceURI, in DOMString localName); @@ -932,9 +930,6 @@ MXdoc::MXdoc(): MXnode(XDOC_CLASS_NAME, } -void MXdoc::configure_admin(Request& r) { -} - # else #include "classes.h"