1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-08-08 17:42:14 +03:00

- HTMLparser.c HTMLtree.c: applied part of the patches provided

by P C Chow and William M. Brack for XSLT HTML output
Daniel
This commit is contained in:
Daniel Veillard
2001-04-18 09:45:35 +00:00
parent 5d7a9fe6b3
commit 1ed3f88b8b
3 changed files with 44 additions and 11 deletions

View File

@@ -1,3 +1,8 @@
Wed Apr 18 11:42:47 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
* HTMLparser.c HTMLtree.c: applied part of the patches provided
by P C Chow and William M. Brack for XSLT HTML output
Mon Apr 16 19:44:36 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr> Mon Apr 16 19:44:36 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
* xmlversion.h.in win32config.h win32/libxml2/*: applied * xmlversion.h.in win32config.h win32/libxml2/*: applied

View File

@@ -616,7 +616,7 @@ htmlTagLookup(const xmlChar *tag) {
for (i = 0; i < (sizeof(html40ElementTable) / for (i = 0; i < (sizeof(html40ElementTable) /
sizeof(html40ElementTable[0]));i++) { sizeof(html40ElementTable[0]));i++) {
if (xmlStrEqual(tag, BAD_CAST html40ElementTable[i].name)) if (!xmlStrcasecmp(tag, BAD_CAST html40ElementTable[i].name))
return(&html40ElementTable[i]); return(&html40ElementTable[i]);
} }
return(NULL); return(NULL);

View File

@@ -189,6 +189,7 @@ htmlSetMetaEncoding(htmlDocPtr doc, const xmlChar *encoding) {
*/ */
while (cur != NULL) { while (cur != NULL) {
if (cur->name != NULL) { if (cur->name != NULL) {
/*
if (xmlStrEqual(cur->name, BAD_CAST"html")) if (xmlStrEqual(cur->name, BAD_CAST"html"))
break; break;
if (xmlStrEqual(cur->name, BAD_CAST"body")) { if (xmlStrEqual(cur->name, BAD_CAST"body")) {
@@ -207,6 +208,13 @@ htmlSetMetaEncoding(htmlDocPtr doc, const xmlChar *encoding) {
goto found_head; goto found_head;
if (xmlStrEqual(cur->name, BAD_CAST"meta")) if (xmlStrEqual(cur->name, BAD_CAST"meta"))
goto found_meta; goto found_meta;
*/
if (xmlStrcasecmp(cur->name, BAD_CAST"html") == 0)
break;
if (xmlStrcasecmp(cur->name, BAD_CAST"head") == 0)
goto found_head;
if (xmlStrcasecmp(cur->name, BAD_CAST"meta") == 0)
goto found_meta;
} }
cur = cur->next; cur = cur->next;
} }
@@ -219,6 +227,7 @@ htmlSetMetaEncoding(htmlDocPtr doc, const xmlChar *encoding) {
*/ */
while (cur != NULL) { while (cur != NULL) {
if (cur->name != NULL) { if (cur->name != NULL) {
/*
if (xmlStrEqual(cur->name, BAD_CAST"head")) if (xmlStrEqual(cur->name, BAD_CAST"head"))
break; break;
if (xmlStrEqual(cur->name, BAD_CAST"body")) { if (xmlStrEqual(cur->name, BAD_CAST"body")) {
@@ -235,6 +244,11 @@ htmlSetMetaEncoding(htmlDocPtr doc, const xmlChar *encoding) {
} }
if (xmlStrEqual(cur->name, BAD_CAST"meta")) if (xmlStrEqual(cur->name, BAD_CAST"meta"))
goto found_meta; goto found_meta;
*/
if (xmlStrcasecmp(cur->name, BAD_CAST"head") == 0)
break;
if (xmlStrcasecmp(cur->name, BAD_CAST"meta") == 0)
goto found_meta;
} }
cur = cur->next; cur = cur->next;
} }
@@ -246,8 +260,8 @@ found_head:
return(0); return(0);
meta = xmlNewDocNode(doc, NULL, BAD_CAST"meta", NULL); meta = xmlNewDocNode(doc, NULL, BAD_CAST"meta", NULL);
xmlAddChild(cur, meta); xmlAddChild(cur, meta);
xmlNewProp(meta, BAD_CAST"http-equiv", BAD_CAST"Content-Type");
xmlNewProp(meta, BAD_CAST"content", BAD_CAST newcontent); xmlNewProp(meta, BAD_CAST"content", BAD_CAST newcontent);
xmlNewProp(meta, BAD_CAST"http-equiv", BAD_CAST"Content-Type");
return(0); return(0);
} }
cur = cur->children; cur = cur->children;
@@ -260,8 +274,8 @@ found_meta:
meta = xmlNewDocNode(doc, NULL, BAD_CAST"meta", NULL); meta = xmlNewDocNode(doc, NULL, BAD_CAST"meta", NULL);
xmlAddPrevSibling(cur, meta); xmlAddPrevSibling(cur, meta);
xmlNewProp(meta, BAD_CAST"http-equiv", BAD_CAST"Content-Type");
xmlNewProp(meta, BAD_CAST"content", BAD_CAST newcontent); xmlNewProp(meta, BAD_CAST"content", BAD_CAST newcontent);
xmlNewProp(meta, BAD_CAST"http-equiv", BAD_CAST"Content-Type");
} }
/* /*
@@ -270,13 +284,15 @@ found_meta:
*/ */
while (cur != NULL) { while (cur != NULL) {
if (cur->name != NULL) { if (cur->name != NULL) {
if (xmlStrEqual(cur->name, BAD_CAST"meta")) { if (xmlStrcasecmp(cur->name, BAD_CAST"meta") == 0) {
xmlAttrPtr attr = cur->properties; xmlAttrPtr attr = cur->properties;
int http; int http;
const xmlChar *value; const xmlChar *value;
int same_charset;
content = NULL; content = NULL;
http = 0; http = 0;
same_charset = 0;
while (attr != NULL) { while (attr != NULL) {
if ((attr->children != NULL) && if ((attr->children != NULL) &&
(attr->children->type == XML_TEXT_NODE) && (attr->children->type == XML_TEXT_NODE) &&
@@ -289,15 +305,22 @@ found_meta:
if ((!xmlStrcasecmp(attr->name, BAD_CAST"http-equiv")) if ((!xmlStrcasecmp(attr->name, BAD_CAST"http-equiv"))
&& (!xmlStrcasecmp(value, BAD_CAST"Content-Type"))) && (!xmlStrcasecmp(value, BAD_CAST"Content-Type")))
http = 1; http = 1;
else if ((value != NULL) else
&& (!xmlStrcasecmp(attr->name, BAD_CAST"content"))) {
content = value; if ((value != NULL) &&
if ((http != 0) && (content != NULL)) (!xmlStrcasecmp(attr->name, BAD_CAST"content")))
content = value;
else
if ((!xmlStrcasecmp(attr->name, BAD_CAST"charset"))
&& (!xmlStrcasecmp(value, encoding)))
same_charset = 1;
}
if ((http != 0) && (content != NULL) && (same_charset != 0))
break; break;
} }
attr = attr->next; attr = attr->next;
} }
if ((http != 0) && (content != NULL)) { if ((http != 0) && (content != NULL) && (same_charset != 0)) {
meta = cur; meta = cur;
cur = cur->next; cur = cur->next;
xmlUnlinkNode(meta); xmlUnlinkNode(meta);
@@ -796,7 +819,8 @@ htmlNodeListDumpOutput(xmlOutputBufferPtr buf, xmlDocPtr doc, xmlNodePtr cur, co
* Dump an HTML node, recursive behaviour,children are printed too. * Dump an HTML node, recursive behaviour,children are printed too.
*/ */
void void
htmlNodeDumpOutput(xmlOutputBufferPtr buf, xmlDocPtr doc, xmlNodePtr cur, const char *encoding) { htmlNodeDumpOutput(xmlOutputBufferPtr buf, xmlDocPtr doc,
xmlNodePtr cur, const char *encoding) {
htmlElemDescPtr info; htmlElemDescPtr info;
if (cur == NULL) { if (cur == NULL) {
@@ -867,7 +891,7 @@ htmlNodeDumpOutput(xmlOutputBufferPtr buf, xmlDocPtr doc, xmlNodePtr cur, const
} }
/* /*
* Get specific HTmL info for taht node. * Get specific HTML info for taht node.
*/ */
info = htmlTagLookup(cur->name); info = htmlTagLookup(cur->name);
@@ -887,6 +911,10 @@ htmlNodeDumpOutput(xmlOutputBufferPtr buf, xmlDocPtr doc, xmlNodePtr cur, const
} }
if ((cur->content == NULL) && (cur->children == NULL)) { if ((cur->content == NULL) && (cur->children == NULL)) {
if ((info != NULL) && (info->saveEndTag != 0) && if ((info != NULL) && (info->saveEndTag != 0) &&
/*
(xmlStrcasecmp(BAD_CAST info->name, BAD_CAST "html")) &&
(xmlStrcasecmp(BAD_CAST info->name, BAD_CAST "body"))) {
*/
(strcmp(info->name, "html")) && (strcmp(info->name, "body"))) { (strcmp(info->name, "html")) && (strcmp(info->name, "body"))) {
xmlOutputBufferWriteString(buf, ">"); xmlOutputBufferWriteString(buf, ">");
} else { } else {