From a464d9993e2acd5b8e1089b218ba74c6fcf215c5 Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Mon, 5 Sep 2005 17:10:35 +0000 Subject: Load /usr/tmp/tmp.CMoFff/libxml2-2.6.21 into packages/libxml2/branches/upstream/current. --- xmlsave.c | 116 ++++++++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 75 insertions(+), 41 deletions(-) (limited to 'xmlsave.c') diff --git a/xmlsave.c b/xmlsave.c index d6e3e65..571427d 100644 --- a/xmlsave.c +++ b/xmlsave.c @@ -826,31 +826,33 @@ xmlDocContentDumpOutput(xmlSaveCtxtPtr ctxt, xmlDocPtr cur) { cur->encoding = BAD_CAST ctxt->encoding; buf = ctxt->buf; - xmlOutputBufferWrite(buf, 14, "version != NULL) - xmlBufferWriteQuotedString(buf->buffer, cur->version); - else - xmlOutputBufferWrite(buf, 5, "\"1.0\""); - if (ctxt->encoding == NULL) { - if (cur->encoding != NULL) - encoding = cur->encoding; - else if (cur->charset != XML_CHAR_ENCODING_UTF8) - encoding = (const xmlChar *) - xmlGetCharEncodingName((xmlCharEncoding) cur->charset); - } - if (encoding != NULL) { - xmlOutputBufferWrite(buf, 10, " encoding="); - xmlBufferWriteQuotedString(buf->buffer, (xmlChar *) encoding); - } - switch (cur->standalone) { - case 0: - xmlOutputBufferWrite(buf, 16, " standalone=\"no\""); - break; - case 1: - xmlOutputBufferWrite(buf, 17, " standalone=\"yes\""); - break; + if ((ctxt->options & XML_SAVE_NO_DECL) == 0) { + xmlOutputBufferWrite(buf, 14, "version != NULL) + xmlBufferWriteQuotedString(buf->buffer, cur->version); + else + xmlOutputBufferWrite(buf, 5, "\"1.0\""); + if (ctxt->encoding == NULL) { + if (cur->encoding != NULL) + encoding = cur->encoding; + else if (cur->charset != XML_CHAR_ENCODING_UTF8) + encoding = (const xmlChar *) + xmlGetCharEncodingName((xmlCharEncoding) cur->charset); + } + if (encoding != NULL) { + xmlOutputBufferWrite(buf, 10, " encoding="); + xmlBufferWriteQuotedString(buf->buffer, (xmlChar *) encoding); + } + switch (cur->standalone) { + case 0: + xmlOutputBufferWrite(buf, 16, " standalone=\"no\""); + break; + case 1: + xmlOutputBufferWrite(buf, 17, " standalone=\"yes\""); + break; + } + xmlOutputBufferWrite(buf, 3, "?>\n"); } - xmlOutputBufferWrite(buf, 3, "?>\n"); #ifdef LIBXML_HTML_ENABLED dtd = xmlGetIntSubset(cur); @@ -858,12 +860,6 @@ xmlDocContentDumpOutput(xmlSaveCtxtPtr ctxt, xmlDocPtr cur) { is_xhtml = xmlIsXHTML(dtd->SystemID, dtd->ExternalID); if (is_xhtml < 0) is_xhtml = 0; } - if (is_xhtml) { - if (encoding != NULL) - htmlSetMetaEncoding(cur, (const xmlChar *) ctxt->encoding); - else - htmlSetMetaEncoding(cur, BAD_CAST "UTF-8"); - } #endif if (cur->children != NULL) { xmlNodePtr child = cur->children; @@ -1084,7 +1080,7 @@ xhtmlNodeListDumpOutput(xmlSaveCtxtPtr ctxt, xmlNodePtr cur) { */ static void xhtmlNodeDumpOutput(xmlSaveCtxtPtr ctxt, xmlNodePtr cur) { - int format; + int format, addmeta = 0; xmlNodePtr tmp; xmlChar *start, *end; xmlOutputBufferPtr buf; @@ -1208,14 +1204,51 @@ xhtmlNodeDumpOutput(xmlSaveCtxtPtr ctxt, xmlNodePtr cur) { if (cur->properties != NULL) xhtmlAttrListDumpOutput(ctxt, cur->properties); + if ((cur->type == XML_ELEMENT_NODE) && + (cur->parent != NULL) && + (cur->parent->parent == (xmlNodePtr) cur->doc) && + xmlStrEqual(cur->name, BAD_CAST"head") && + xmlStrEqual(cur->parent->name, BAD_CAST"html")) { + + tmp = cur->children; + while (tmp != NULL) { + if (xmlStrEqual(tmp->name, BAD_CAST"meta")) { + xmlChar *httpequiv; + + httpequiv = xmlGetProp(tmp, BAD_CAST"http-equiv"); + if (httpequiv != NULL) { + if (xmlStrcasecmp(httpequiv, BAD_CAST"Content-Type") == 0) { + xmlFree(httpequiv); + break; + } + xmlFree(httpequiv); + } + } + tmp = tmp->next; + } + if (tmp == NULL) + addmeta = 1; + } + if ((cur->type == XML_ELEMENT_NODE) && (cur->children == NULL)) { if (((cur->ns == NULL) || (cur->ns->prefix == NULL)) && - (xhtmlIsEmpty(cur) == 1)) { + ((xhtmlIsEmpty(cur) == 1) && (addmeta == 0))) { /* * C.2. Empty Elements */ xmlOutputBufferWrite(buf, 3, " />"); } else { + if (addmeta == 1) { + xmlOutputBufferWrite(buf, 1, ">"); + xmlOutputBufferWriteString(buf, + ""); + if (addmeta == 1) { + xmlOutputBufferWriteString(buf, + ""); + } if ((cur->type != XML_ELEMENT_NODE) && (cur->content != NULL)) { xmlOutputBufferWriteEscape(buf, cur->content, ctxt->escape); } @@ -1830,15 +1873,6 @@ xmlNodeDumpOutput(xmlOutputBufferPtr buf, xmlDocPtr doc, xmlNodePtr cur, is_xhtml = xmlIsXHTML(dtd->SystemID, dtd->ExternalID); if (is_xhtml < 0) is_xhtml = 0; - if ((is_xhtml) && (cur->parent == (xmlNodePtr) doc) && - (cur->type == XML_ELEMENT_NODE) && - (xmlStrEqual(cur->name, BAD_CAST "html"))) { - if (encoding != NULL) - htmlSetMetaEncoding((htmlDocPtr) doc, - (const xmlChar *) encoding); - else - htmlSetMetaEncoding((htmlDocPtr) doc, BAD_CAST "UTF-8"); - } } if (is_xhtml) -- cgit v1.2.3