--- parser3/src/classes/xdoc.C 2004/02/17 14:22:53 1.133 +++ parser3/src/classes/xdoc.C 2004/02/18 11:47:04 1.138 @@ -9,7 +9,7 @@ #ifdef XML -static const char * const IDENT_XDOC_C="$Date: 2004/02/17 14:22:53 $"; +static const char * const IDENT_XDOC_C="$Date: 2004/02/18 11:47:04 $"; #include "gdome.h" #include "libxml/tree.h" @@ -595,7 +595,7 @@ static void prepare_output_options(Reque } } -/// patching piece from libxslt not to set meta encoding +/// patching piecees from libxslt and libxml not to set meta encoding static int pa_xsltSaveResultTo(xmlOutputBufferPtr buf, xmlDocPtr result, xsltStylesheetPtr style) { @@ -626,20 +626,43 @@ pa_xsltSaveResultTo(xmlOutputBufferPtr b XSLT_GET_IMPORT_INT(indent, style, indent); if ((method == NULL) && (result->type == XML_HTML_DOCUMENT_NODE)) - method = (const xmlChar *) "html"; + method = BAD_CAST "html"; if ((method != NULL) && (xmlStrEqual(method, (const xmlChar *) "html"))) { if (indent == -1) indent = 1; - htmlDocContentDumpFormatOutput(buf, result, (const char *) encoding, + + int is_xhtml = 0; + xmlDtdPtr dtd = xmlGetIntSubset(result); + if (dtd != NULL) { + is_xhtml = xmlIsXHTML(dtd->SystemID, dtd->ExternalID); + if (is_xhtml < 0) + is_xhtml = 0; + } + xmlNodePtr cur=result->last; + if(!cur) { + is_xhtml=0; + } + + if(is_xhtml) { + // xhtmlNodeDumpOutput is static :( + if((cur->parent == (xmlNodePtr) result) && + (cur->type == XML_ELEMENT_NODE) && + (xmlStrEqual(cur->name, BAD_CAST "html"))) { + //cur->name=BAD_CAST "html "; + } + + method = BAD_CAST "xml"; + } else { + htmlDocContentDumpFormatOutput(buf, result, (const char *) encoding, indent); - xmlOutputBufferFlush(buf); - } else if ((method != NULL) && - (xmlStrEqual(method, (const xmlChar *) "xhtml"))) { - htmlDocContentDumpOutput(buf, result, (const char *) encoding); - xmlOutputBufferFlush(buf); - } else if ((method != NULL) && + xmlOutputBufferFlush(buf); + goto finish; + } + } + + if ((method != NULL) && (xmlStrEqual(method, (const xmlChar *) "text"))) { xmlNodePtr cur; @@ -730,6 +753,7 @@ pa_xsltSaveResultTo(xmlOutputBufferPtr b } xmlOutputBufferFlush(buf); } +finish: return(buf->written - base); }