1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2024-12-25 23:21:26 +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>
* xmlversion.h.in win32config.h win32/libxml2/*: applied

View File

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

View File

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