--- parser3/src/classes/xdoc.C 2001/11/21 14:00:27 1.46 +++ parser3/src/classes/xdoc.C 2001/12/15 21:28:18 1.53 @@ -4,7 +4,7 @@ Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com) Author: Alexander Petrosyan (http://paf.design.ru) - $Id: xdoc.C,v 1.46 2001/11/21 14:00:27 paf Exp $ + $Id: xdoc.C,v 1.53 2001/12/15 21:28:18 paf Exp $ */ #include "pa_types.h" #include "classes.h" @@ -14,6 +14,7 @@ #include "pa_vxdoc.h" #include "pa_stylesheet_manager.h" #include "pa_stylesheet_connection.h" +#include "pa_charset.h" #include "pa_vfile.h" #include "xnode.h" @@ -392,10 +393,9 @@ static void param_option_over_output_opt } } -static void create_optioned_listener( +static std::auto_ptr create_optioned_listener( Pool& pool, const String& method_name, MethodParams *params, int index, - VXdoc::Output_options& oo, Writer& writer, - FormatterListener *& listener) { + VXdoc::Output_options& oo, Writer& writer) { /* XalanDOMString encoding; XalanDOMString mediaType; @@ -460,7 +460,7 @@ static void create_optioned_listener( // default encoding from pool if(oo.encoding.empty()) - oo.encoding.append(pool.get_charset().cstr()); + oo.encoding.append(pool.get_source_charset().name().cstr()); // default method=xml if(!oo.method) oo.method=XDOC_OUTPUT_METHOD_OPTION_VALUE_XML; @@ -468,7 +468,7 @@ static void create_optioned_listener( if(strcmp(oo.method, XDOC_OUTPUT_METHOD_OPTION_VALUE_XML)==0) { if(oo.mediaType.empty()) oo.mediaType.append("text/xml"); - listener=new FormatterToXML(writer, + return std::auto_ptr(new FormatterToXML(writer, oo.version, oo.doIndent, XDOC_OUTPUT_DEFAULT_INDENT, // indent @@ -478,11 +478,11 @@ static void create_optioned_listener( oo.doctypePublic, oo.xmlDecl, oo.standalone - ); + )); } else if(strcmp(oo.method, XDOC_OUTPUT_METHOD_OPTION_VALUE_HTML)==0) { if(oo.mediaType.empty()) oo.mediaType.append("text/html"); - listener=new FormatterToHTML(writer, + return std::auto_ptr(new FormatterToHTML(writer, oo.encoding, oo.mediaType, oo.doctypeSystem, @@ -492,13 +492,13 @@ static void create_optioned_listener( oo.version, oo.standalone, oo.xmlDecl - ); + )); } else if(strcmp(oo.method, XDOC_OUTPUT_METHOD_OPTION_VALUE_TEXT)==0) { if(oo.mediaType.empty()) oo.mediaType.append("text/plain"); - listener=new FormatterToText(writer, + return std::auto_ptr(new FormatterToText(writer, oo.encoding - ); + )); } else throw Exception(0, 0, &method_name, @@ -526,9 +526,9 @@ static void _save(Request& r, const Stri VXdoc::Output_options oo(vdoc.output_options); XalanFileOutputStream stream(XalanDOMString(filespec, strlen(filespec))); XalanOutputStreamPrintWriter writer(stream); - FormatterListener *formatterListener; - create_optioned_listener(pool, method_name, params, 1, - oo, writer, formatterListener); + std::auto_ptr formatterListener= + create_optioned_listener(pool, method_name, params, 1, + oo, writer); FormatterTreeWalker treeWalker(*formatterListener); treeWalker.traverse(&node); // Walk that node and produce the XML... } catch(const XSLException& e) { @@ -549,12 +549,12 @@ static void _string(Request& r, const St try { VXdoc::Output_options oo(vdoc.output_options); - String parserString=*new(pool) String(pool); + String& parserString=*new(pool) String(pool); ParserStringXalanOutputStream stream(parserString); XalanOutputStreamPrintWriter writer(stream); - FormatterListener *formatterListener; - create_optioned_listener(pool, method_name, params, 0, - oo, writer, formatterListener); + std::auto_ptr formatterListener= + create_optioned_listener(pool, method_name, params, 0, + oo, writer); FormatterTreeWalker treeWalker(*formatterListener); treeWalker.traverse(node); // Walk that node and produce the XML... @@ -579,9 +579,9 @@ static void _file(Request& r, const Stri String& parserString=*new(pool) String(pool); ParserStringXalanOutputStream stream(parserString); XalanOutputStreamPrintWriter writer(stream); - FormatterListener *formatterListener; - create_optioned_listener(pool, method_name, params, 0, - oo, writer, formatterListener); + std::auto_ptr formatterListener= + create_optioned_listener(pool, method_name, params, 0, + oo, writer); FormatterTreeWalker treeWalker(*formatterListener); treeWalker.traverse(&node); // Walk that node and produce the XML... @@ -608,7 +608,7 @@ static void _file(Request& r, const Stri } static void _set(Request& r, const String& method_name, MethodParams *params) { - //_asm int 3; +// _asm int 3; Pool& pool=r.pool(); VXdoc& vdoc=*static_cast(r.self); @@ -739,7 +739,7 @@ static void _transform(Request& r, const // wich were originally "xalan" // not daring to change that - const XalanCompiledStylesheet& stylesheet=connection.stylesheet(true/*nocache*/); + const XalanCompiledStylesheet& stylesheet=connection.stylesheet(false/*nocache*/); if(vdoc.has_parsed_source()) { // set|load, not create? vdoc.transformer().transform2( vdoc.get_parsed_source(pool, &method_name),