mirror of
https://github.com/GNOME/libxml2.git
synced 2025-02-17 18:19:32 +08:00
- HTMLtree.[ch]: more work on the HTML serialization routnes,
cleanup, encoding support. Daniel
This commit is contained in:
parent
608ad0791b
commit
c4f631d28a
@ -1,3 +1,8 @@
|
|||||||
|
Fri Jun 15 07:08:57 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
|
||||||
|
|
||||||
|
* HTMLtree.[ch]: more work on the HTML serialization routnes,
|
||||||
|
cleanup, encoding support.
|
||||||
|
|
||||||
Thu Jun 14 10:31:17 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
|
Thu Jun 14 10:31:17 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
|
||||||
|
|
||||||
* xpath.c: Thomas Broyer suggested a better patch for the / arg
|
* xpath.c: Thomas Broyer suggested a better patch for the / arg
|
||||||
|
54
HTMLtree.c
54
HTMLtree.c
@ -294,6 +294,9 @@ found_meta:
|
|||||||
* *
|
* *
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
|
|
||||||
|
void htmlNodeDumpFormatOutput(xmlOutputBufferPtr buf, xmlDocPtr doc,
|
||||||
|
xmlNodePtr cur, const char *encoding, int format);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
htmlDocContentDump(xmlBufferPtr buf, xmlDocPtr cur, int format);
|
htmlDocContentDump(xmlBufferPtr buf, xmlDocPtr cur, int format);
|
||||||
|
|
||||||
@ -616,18 +619,46 @@ htmlNodeDump(xmlBufferPtr buf, xmlDocPtr doc, xmlNodePtr cur) {
|
|||||||
*
|
*
|
||||||
* Dump an HTML node, recursive behaviour,children are printed too.
|
* Dump an HTML node, recursive behaviour,children are printed too.
|
||||||
*
|
*
|
||||||
* TODO: handle the encoding not used yet
|
* TODO: if encoding == NULL try to save in the doc encoding
|
||||||
|
*
|
||||||
|
* returns: the number of byte written or -1 in case of failure.
|
||||||
*/
|
*/
|
||||||
void
|
int
|
||||||
htmlNodeDumpFileFormat(FILE *out, xmlDocPtr doc, xmlNodePtr cur,
|
htmlNodeDumpFileFormat(FILE *out, xmlDocPtr doc,
|
||||||
const char *encoding ATTRIBUTE_UNUSED, int format) {
|
xmlNodePtr cur, const char *encoding, int format) {
|
||||||
xmlBufferPtr buf;
|
xmlOutputBufferPtr buf;
|
||||||
|
xmlCharEncodingHandlerPtr handler = NULL;
|
||||||
|
int ret;
|
||||||
|
|
||||||
buf = xmlBufferCreate();
|
if (encoding != NULL) {
|
||||||
if (buf == NULL) return;
|
xmlCharEncoding enc;
|
||||||
htmlNodeDumpFormat(buf, doc, cur, format);
|
|
||||||
xmlBufferDump(out, buf);
|
enc = xmlParseCharEncoding(encoding);
|
||||||
xmlBufferFree(buf);
|
if (enc != XML_CHAR_ENCODING_UTF8) {
|
||||||
|
handler = xmlFindCharEncodingHandler(encoding);
|
||||||
|
if (handler == NULL)
|
||||||
|
return(-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Fallback to HTML or ASCII when the encoding is unspecified
|
||||||
|
*/
|
||||||
|
if (handler == NULL)
|
||||||
|
handler = xmlFindCharEncodingHandler("HTML");
|
||||||
|
if (handler == NULL)
|
||||||
|
handler = xmlFindCharEncodingHandler("ascii");
|
||||||
|
|
||||||
|
/*
|
||||||
|
* save the content to a temp buffer.
|
||||||
|
*/
|
||||||
|
buf = xmlOutputBufferCreateFile(out, handler);
|
||||||
|
if (buf == NULL) return(0);
|
||||||
|
|
||||||
|
htmlNodeDumpFormatOutput(buf, doc, cur, encoding, format);
|
||||||
|
|
||||||
|
ret = xmlOutputBufferClose(buf);
|
||||||
|
return(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -862,9 +893,6 @@ htmlAttrListDumpOutput(xmlOutputBufferPtr buf, xmlDocPtr doc, xmlAttrPtr cur, co
|
|||||||
void htmlNodeDumpOutput(xmlOutputBufferPtr buf, xmlDocPtr doc,
|
void htmlNodeDumpOutput(xmlOutputBufferPtr buf, xmlDocPtr doc,
|
||||||
xmlNodePtr cur, const char *encoding);
|
xmlNodePtr cur, const char *encoding);
|
||||||
|
|
||||||
void htmlNodeDumpFormatOutput(xmlOutputBufferPtr buf, xmlDocPtr doc,
|
|
||||||
xmlNodePtr cur, const char *encoding, int format);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* htmlNodeListDumpOutput:
|
* htmlNodeListDumpOutput:
|
||||||
* @buf: the HTML buffer output
|
* @buf: the HTML buffer output
|
||||||
|
@ -75,7 +75,7 @@ void htmlNodeDump (xmlBufferPtr buf,
|
|||||||
void htmlNodeDumpFile (FILE *out,
|
void htmlNodeDumpFile (FILE *out,
|
||||||
xmlDocPtr doc,
|
xmlDocPtr doc,
|
||||||
xmlNodePtr cur);
|
xmlNodePtr cur);
|
||||||
void htmlNodeDumpFileFormat (FILE *out,
|
int htmlNodeDumpFileFormat (FILE *out,
|
||||||
xmlDocPtr doc,
|
xmlDocPtr doc,
|
||||||
xmlNodePtr cur,
|
xmlNodePtr cur,
|
||||||
const char *encoding,
|
const char *encoding,
|
||||||
|
@ -75,7 +75,7 @@ void htmlNodeDump (xmlBufferPtr buf,
|
|||||||
void htmlNodeDumpFile (FILE *out,
|
void htmlNodeDumpFile (FILE *out,
|
||||||
xmlDocPtr doc,
|
xmlDocPtr doc,
|
||||||
xmlNodePtr cur);
|
xmlNodePtr cur);
|
||||||
void htmlNodeDumpFileFormat (FILE *out,
|
int htmlNodeDumpFileFormat (FILE *out,
|
||||||
xmlDocPtr doc,
|
xmlDocPtr doc,
|
||||||
xmlNodePtr cur,
|
xmlNodePtr cur,
|
||||||
const char *encoding,
|
const char *encoding,
|
||||||
|
Loading…
Reference in New Issue
Block a user