--- parser3/src/classes/Attic/dom.C 2001/09/20 14:25:06 1.28 +++ parser3/src/classes/Attic/dom.C 2001/09/25 09:36:51 1.34 @@ -5,9 +5,11 @@ Author: Alexander Petrosyan (http://design.ru/paf) */ -static const char *RCSId="$Id: dom.C,v 1.28 2001/09/20 14:25:06 parser Exp $"; - #include "classes.h" +#ifdef XML + +static const char *RCSId="$Id: dom.C,v 1.34 2001/09/25 09:36:51 parser Exp $"; + #include "pa_request.h" #include "pa_vdom.h" #include "pa_xslt_stylesheet_manager.h" @@ -66,7 +68,7 @@ protected: // XalanOutputStream virtual void writeData(const char *theBuffer, unsigned long theBufferLength) { char *copy=(char *)fstring.malloc((size_t)theBufferLength); memcpy(copy, theBuffer, (size_t)theBufferLength); - fstring.APPEND_CLEAN(copy, (size_t)theBufferLength, "dom", -1); + fstring.APPEND_CLEAN(copy, (size_t)theBufferLength, "dom", 0); } virtual void doFlush() {} @@ -81,7 +83,8 @@ static void create_optioned_listener( const char *& content_type, const char *& charset, FormatterListener *& listener, Pool& pool, const String& method_name, MethodParams *params, int index, Writer& writer) { - charset=0; + // default encoding from pool + const String *scharset=&pool.get_charset(); const String *method=0; XalanDOMString xalan_encoding; @@ -97,8 +100,7 @@ static void create_optioned_listener( // $.encoding[windows-1251|...] if(Value *vencoding=static_cast(options->get(*new(pool) String(pool, DOM_OUTPUT_ENCODING_OPTION_NAME)))) { - charset=vencoding->as_string().cstr(); - xalan_encoding.append(charset, strlen(charset)); + scharset=&vencoding->as_string(); } } else PTHROW(0, 0, @@ -107,6 +109,7 @@ static void create_optioned_listener( } } + xalan_encoding.append(charset=scharset->cstr()); if(!method/*default='xml'*/ || *method == DOM_OUTPUT_METHOD_OPTION_VALUE_XML) { content_type="text/xml"; listener=new FormatterToXML(writer, @@ -239,7 +242,7 @@ static void _set(Request& r, const Strin const String& xml=r.process(vxml).as_string(); std::istrstream stream(xml.cstr()); - XalanParsedSource* parsedSource; + const XalanParsedSource* parsedSource; int error=vdom.transformer().parseSource(&stream, parsedSource); if(error) @@ -259,7 +262,7 @@ static void _load(Request& r, const Stri const String& file_name=params->as_string(0, "file name must not be code"); const char *filespec=r.absolute(file_name).cstr(String::UL_FILE_SPEC); - XalanParsedSource* parsedSource; + const XalanParsedSource* parsedSource; int error=vdom.transformer().parseSource(filespec, parsedSource); if(error) @@ -298,7 +301,7 @@ static void _xslt(Request& r, const Stri } // source - XalanParsedSource &parsed_source=vdom.get_parsed_source(pool, &method_name); + const XalanParsedSource &parsed_source=vdom.get_parsed_source(pool, &method_name); // stylesheet const String& stylesheet_file_name=params->as_string(0, "file name must not be code"); @@ -361,6 +364,14 @@ Methoded *Dom_class; // creator +#endif + Methoded *MDom_create(Pool& pool) { - return Dom_class=new(pool) MDom(pool); + return +#ifdef XML + Dom_class=new(pool) MDom(pool); +#else + 0 +#endif + ; }