1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-10-24 13:33:01 +03:00

fixed #145092 by adding an xmlSaveOption to omit XML declaration Daniel

* xmlsave.c include/libxml/xmlsave.h: fixed #145092 by adding
  an xmlSaveOption to omit XML declaration
Daniel
This commit is contained in:
Daniel Veillard
2005-08-08 14:44:11 +00:00
parent b8c8016044
commit 100e18030d
3 changed files with 33 additions and 25 deletions

View File

@@ -1,3 +1,8 @@
Mon Aug 8 16:43:04 CEST 2005 Daniel Veillard <daniel@veillard.com>
* xmlsave.c include/libxml/xmlsave.h: fixed #145092 by adding
an xmlSaveOption to omit XML declaration
Mon Aug 8 15:44:54 CEST 2005 Daniel Veillard <daniel@veillard.com> Mon Aug 8 15:44:54 CEST 2005 Daniel Veillard <daniel@veillard.com>
* HTMLtree.c: fixed bug #310333 with a patch close to the provided * HTMLtree.c: fixed bug #310333 with a patch close to the provided

View File

@@ -27,7 +27,8 @@ extern "C" {
* to the xmlSaveToFd() and similar calls. * to the xmlSaveToFd() and similar calls.
*/ */
typedef enum { typedef enum {
XML_SAVE_FORMAT = 1<<0 /* format save output */ XML_SAVE_FORMAT = 1<<0, /* format save output */
XML_SAVE_NO_DECL = 1<<1 /* drop the xml declaration */
} xmlSaveOption; } xmlSaveOption;

View File

@@ -826,31 +826,33 @@ xmlDocContentDumpOutput(xmlSaveCtxtPtr ctxt, xmlDocPtr cur) {
cur->encoding = BAD_CAST ctxt->encoding; cur->encoding = BAD_CAST ctxt->encoding;
buf = ctxt->buf; buf = ctxt->buf;
xmlOutputBufferWrite(buf, 14, "<?xml version="); if ((ctxt->options & XML_SAVE_NO_DECL) == 0) {
if (cur->version != NULL) xmlOutputBufferWrite(buf, 14, "<?xml version=");
xmlBufferWriteQuotedString(buf->buffer, cur->version); if (cur->version != NULL)
else xmlBufferWriteQuotedString(buf->buffer, cur->version);
xmlOutputBufferWrite(buf, 5, "\"1.0\""); else
if (ctxt->encoding == NULL) { xmlOutputBufferWrite(buf, 5, "\"1.0\"");
if (cur->encoding != NULL) if (ctxt->encoding == NULL) {
encoding = cur->encoding; if (cur->encoding != NULL)
else if (cur->charset != XML_CHAR_ENCODING_UTF8) encoding = cur->encoding;
encoding = (const xmlChar *) else if (cur->charset != XML_CHAR_ENCODING_UTF8)
xmlGetCharEncodingName((xmlCharEncoding) cur->charset); 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");
} }
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");
#ifdef LIBXML_HTML_ENABLED #ifdef LIBXML_HTML_ENABLED
dtd = xmlGetIntSubset(cur); dtd = xmlGetIntSubset(cur);