--- parser3/src/classes/xdoc.C 2003/12/10 14:17:43 1.124 +++ parser3/src/classes/xdoc.C 2004/02/03 16:29:45 1.130 @@ -9,7 +9,7 @@ #ifdef XML -static const char * const IDENT_XDOC_C="$Date: 2003/12/10 14:17:43 $"; +static const char * const IDENT_XDOC_C="$Date: 2004/02/03 16:29:45 $"; #include "gdome.h" #include "libxml/tree.h" @@ -413,7 +413,7 @@ static void _create(Request& r, MethodPa Temp_lang temp_lang(r, String::L_XML); const String& xml=r.process_to_string(param); - const char* cstr=xml.cstr(String::L_UNSPECIFIED); + const char* cstr=xml.cstr(String::L_UNSPECIFIED, 0, &r.charsets); document=(GdomeDocument *) gdome_xml_n_mkref((xmlNode *)xmlParseMemory( cstr, strlen(cstr) @@ -615,7 +615,8 @@ static Xdoc2buf_result xdoc2buf(Request& // UTF-8 encoder contains empty input/output converters, // which is wrong for xmlOutputBufferCreateIO // while zero encoder goes perfectly - if(encoder && strcmp(encoder->name, "UTF-8")==0) + const char* encoder_name=encoder->name; + if(strcmp(encoder_name, "UTF-8")==0) encoder=0; xmlOutputBuffer_auto_ptr outputBuffer(xmlAllocOutputBuffer(encoder)); @@ -635,13 +636,14 @@ static Xdoc2buf_result xdoc2buf(Request& OOS2STYLE(encoding); OOS2STYLE(mediaType); // OOS2STYLE(doctypeSystem); - //OOS2STYLE(doctypePublic); +// OOS2STYLE(doctypePublic); OOE2STYLE(indent); OOS2STYLE(version); OOE2STYLE(standalone); OOE2STYLE(omitXmlDeclaration); xmlDoc *document=gdome_xml_doc_get_xmlDoc(vdoc.get_document()); + document->encoding=BAD_CAST xmlMemStrdup(encoder_name); if(xsltSaveResultTo(outputBuffer.get(), document, stylesheet.get())<0) { GdomeException exc=0; throw XmlException(0, exc); @@ -819,9 +821,6 @@ static void _transform(Request& r, Metho static_cast(vxdoc)->get_document()); // compile xdoc stylesheet xsltStylesheet_auto_ptr stylesheet_ptr(xsltParseStylesheetDoc(document)); - // strange thing - xsltParseStylesheetDoc records document and destroys it in stylesheet destructor - // we don't need that - stylesheet_ptr->doc=0; if(xmlHaveGenericErrors()) { GdomeException exc=0; throw XmlException(0, exc); @@ -830,6 +829,9 @@ static void _transform(Request& r, Metho throw Exception("xml", 0, "stylesheet failed to compile"); + // strange thing - xsltParseStylesheetDoc records document and destroys it in stylesheet destructor + // we don't need that + stylesheet_ptr->doc=0; // transform! result=&_transform(r, 0, @@ -839,7 +841,7 @@ static void _transform(Request& r, Metho // extablish stylesheet connection const String& stylesheet_filespec= r.absolute(params.as_string(0, "stylesheet must be file name (string) or DOM document (xdoc)")); - Stylesheet_connection_ptr connection=stylesheet_manager.get_connection(stylesheet_filespec); + Stylesheet_connection_ptr connection=stylesheet_manager->get_connection(stylesheet_filespec); // load and compile file to stylesheet [or get cached if any] // transform!