mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-07-29 11:41:22 +03:00
Patches added during last week on W3C CVS base:
- tree.c: coalesce adjacent text nodes - valid.c: handling of blank nodes in DTd validation (raised by problems with a posteriori validation). - nanohttp.c: changing behaviour on HTTP write stuff. - HTMLtree.c: forced body and html to be explicitely closed. - xpath.h: exported more XPath functions. Daniel
This commit is contained in:
@ -1,3 +1,12 @@
|
||||
Sun Oct 22 13:59:50 CEST 2000 Daniel Veillard <Daniel.Veillard@w3.org>
|
||||
|
||||
* tree.c: coalesce adjacent text nodes
|
||||
* valid.c: handling of blank nodes in DTd validation (raised
|
||||
by problems with a posteriori validation).
|
||||
* nanohttp.c: changing behaviour on HTTP write stuff.
|
||||
* HTMLtree.c: forced body and html to be explicitely closed.
|
||||
* xpath.h: exported more XPath functions.
|
||||
|
||||
Sun Oct 15 22:28:32 CEST 2000 Daniel Veillard <Daniel.Veillard@w3.org>
|
||||
|
||||
* Release of 2.2.5
|
||||
|
@ -849,9 +849,10 @@ htmlNodeDumpOutput(xmlOutputBufferPtr buf, xmlDocPtr doc, xmlNodePtr cur, const
|
||||
return;
|
||||
}
|
||||
if ((cur->content == NULL) && (cur->children == NULL)) {
|
||||
if ((info != NULL) && (info->endTag != 0))
|
||||
if ((info != NULL) && (info->endTag != 0) &&
|
||||
(strcmp(info->name, "html")) && (strcmp(info->name, "body"))) {
|
||||
xmlOutputBufferWriteString(buf, ">");
|
||||
else {
|
||||
} else {
|
||||
xmlOutputBufferWriteString(buf, "></");
|
||||
xmlOutputBufferWriteString(buf, (const char *)cur->name);
|
||||
xmlOutputBufferWriteString(buf, ">");
|
||||
|
@ -283,6 +283,9 @@ int valuePush (xmlXPathParserContextPtr ctxt,
|
||||
xmlXPathObjectPtr value);
|
||||
|
||||
xmlXPathObjectPtr xmlXPathNewString (const xmlChar *val);
|
||||
xmlXPathObjectPtr xmlXPathNewCString (const char *val);
|
||||
xmlXPathObjectPtr xmlXPathNewFloat (double val);
|
||||
xmlXPathObjectPtr xmlXPathNewBoolean (int val);
|
||||
xmlXPathObjectPtr xmlXPathNewNodeSet (xmlNodePtr val);
|
||||
void xmlXPathNodeSetAdd (xmlNodeSetPtr cur,
|
||||
xmlNodePtr val);
|
||||
|
13
nanohttp.c
13
nanohttp.c
@ -403,8 +403,17 @@ xmlNanoHTTPFreeCtxt(xmlNanoHTTPCtxtPtr ctxt) {
|
||||
|
||||
static void
|
||||
xmlNanoHTTPSend(xmlNanoHTTPCtxtPtr ctxt) {
|
||||
if (ctxt->state & XML_NANO_HTTP_WRITE)
|
||||
ctxt->last = send(ctxt->fd, ctxt->outptr, strlen(ctxt->outptr), 0);
|
||||
if (ctxt->state & XML_NANO_HTTP_WRITE) {
|
||||
int total_sent = 0;
|
||||
while (total_sent <strlen(ctxt->outptr)) {
|
||||
int nsent = send(ctxt->fd, ctxt->outptr+total_sent,
|
||||
strlen(ctxt->outptr)-total_sent, 0);
|
||||
if (nsent>0)
|
||||
total_sent += nsent;
|
||||
}
|
||||
|
||||
ctxt->last = total_sent;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
123
tree.c
123
tree.c
@ -1779,6 +1779,7 @@ xmlNewChild(xmlNodePtr parent, xmlNsPtr ns,
|
||||
* Add a new element @elem as the next siblings of @cur
|
||||
* If the new element was already inserted in a document it is
|
||||
* first unlinked from its existing context.
|
||||
* As a result of text merging @elem may be freed.
|
||||
*
|
||||
* Returns the new element or NULL in case of error.
|
||||
*/
|
||||
@ -1798,6 +1799,34 @@ xmlAddNextSibling(xmlNodePtr cur, xmlNodePtr elem) {
|
||||
}
|
||||
|
||||
xmlUnlinkNode(elem);
|
||||
|
||||
if (elem->type == XML_TEXT_NODE) {
|
||||
if (cur->type == XML_TEXT_NODE) {
|
||||
#ifndef XML_USE_BUFFER_CONTENT
|
||||
xmlNodeAddContent(cur, elem->content);
|
||||
#else
|
||||
xmlNodeAddContent(cur, xmlBufferContent(elem->content));
|
||||
#endif
|
||||
xmlFreeNode(elem);
|
||||
return(cur);
|
||||
}
|
||||
if ((cur->next != NULL) && (cur->type == XML_TEXT_NODE)) {
|
||||
#ifndef XML_USE_BUFFER_CONTENT
|
||||
xmlChar *tmp;
|
||||
|
||||
tmp = xmlStrdup(elem->content);
|
||||
tmp = xmlStrcat(tmp, cur->next->content);
|
||||
xmlNodeSetContent(cur->next, tmp);
|
||||
xmlFree(tmp);
|
||||
#else
|
||||
xmlBufferAddHead(cur->next, xmlBufferContent(elem->content),
|
||||
xmlBufferLength(elem->content));
|
||||
#endif
|
||||
xmlFreeNode(elem);
|
||||
return(cur->next);
|
||||
}
|
||||
}
|
||||
|
||||
elem->doc = cur->doc;
|
||||
elem->parent = cur->parent;
|
||||
elem->prev = cur;
|
||||
@ -1816,6 +1845,7 @@ xmlAddNextSibling(xmlNodePtr cur, xmlNodePtr elem) {
|
||||
* @elem: the new node
|
||||
*
|
||||
* Add a new element @elem as the previous siblings of @cur
|
||||
* merging adjacent TEXT nodes (@elem may be freed)
|
||||
* If the new element was already inserted in a document it is
|
||||
* first unlinked from its existing context.
|
||||
*
|
||||
@ -1837,6 +1867,34 @@ xmlAddPrevSibling(xmlNodePtr cur, xmlNodePtr elem) {
|
||||
}
|
||||
|
||||
xmlUnlinkNode(elem);
|
||||
|
||||
if (elem->type == XML_TEXT_NODE) {
|
||||
if (cur->type == XML_TEXT_NODE) {
|
||||
#ifndef XML_USE_BUFFER_CONTENT
|
||||
xmlChar *tmp;
|
||||
|
||||
tmp = xmlStrdup(elem->content);
|
||||
tmp = xmlStrcat(tmp, cur->content);
|
||||
xmlNodeSetContent(cur, tmp);
|
||||
xmlFree(tmp);
|
||||
#else
|
||||
xmlBufferAddHead(cur->content, xmlBufferContent(elem->content),
|
||||
xmlBufferLength(elem->content));
|
||||
#endif
|
||||
xmlFreeNode(elem);
|
||||
return(cur);
|
||||
}
|
||||
if ((cur->prev != NULL) && (cur->prev->type == XML_TEXT_NODE)) {
|
||||
#ifndef XML_USE_BUFFER_CONTENT
|
||||
xmlNodeAddContent(cur->prev, elem->content);
|
||||
#else
|
||||
xmlNodeAddContent(cur->prev, xmlBufferContent(elem->content));
|
||||
#endif
|
||||
xmlFreeNode(elem);
|
||||
return(cur->prev);
|
||||
}
|
||||
}
|
||||
|
||||
elem->doc = cur->doc;
|
||||
elem->parent = cur->parent;
|
||||
elem->next = cur;
|
||||
@ -1855,6 +1913,7 @@ xmlAddPrevSibling(xmlNodePtr cur, xmlNodePtr elem) {
|
||||
* @elem: the new node
|
||||
*
|
||||
* Add a new element @elem to the list of siblings of @cur
|
||||
* merging adjacent TEXT nodes (@elem may be freed)
|
||||
* If the new element was already inserted in a document it is
|
||||
* first unlinked from its existing context.
|
||||
*
|
||||
@ -1892,6 +1951,17 @@ xmlAddSibling(xmlNodePtr cur, xmlNodePtr elem) {
|
||||
}
|
||||
|
||||
xmlUnlinkNode(elem);
|
||||
|
||||
if ((cur->type == XML_TEXT_NODE) && (elem->type == XML_TEXT_NODE)) {
|
||||
#ifndef XML_USE_BUFFER_CONTENT
|
||||
xmlNodeAddContent(cur, elem->content);
|
||||
#else
|
||||
xmlNodeAddContent(cur, xmlBufferContent(elem->content));
|
||||
#endif
|
||||
xmlFreeNode(elem);
|
||||
return(cur);
|
||||
}
|
||||
|
||||
if (elem->doc == NULL)
|
||||
elem->doc = cur->doc; /* the parent may not be linked to a doc ! */
|
||||
|
||||
@ -1912,6 +1982,7 @@ xmlAddSibling(xmlNodePtr cur, xmlNodePtr elem) {
|
||||
* @cur: the first node in the list
|
||||
*
|
||||
* Add a list of node at the end of the child list of the parent
|
||||
* merging adjacent TEXT nodes (@cur may be freed)
|
||||
*
|
||||
* Returns the last child or NULL in case of error.
|
||||
*/
|
||||
@ -1946,6 +2017,27 @@ xmlAddChildList(xmlNodePtr parent, xmlNodePtr cur) {
|
||||
if (parent->children == NULL) {
|
||||
parent->children = cur;
|
||||
} else {
|
||||
/*
|
||||
* If cur and parent->last both are TEXT nodes, then merge them.
|
||||
*/
|
||||
if ((cur->type == XML_TEXT_NODE) &&
|
||||
(parent->last->type == XML_TEXT_NODE)) {
|
||||
#ifndef XML_USE_BUFFER_CONTENT
|
||||
xmlNodeAddContent(parent->last, cur->content);
|
||||
#else
|
||||
xmlNodeAddContent(parent->last, xmlBufferContent(cur->content));
|
||||
#endif
|
||||
/*
|
||||
* if it's the only child, nothing more to be done.
|
||||
*/
|
||||
if (cur->next == NULL) {
|
||||
xmlFreeNode(cur);
|
||||
return(parent->last);
|
||||
}
|
||||
prev = cur;
|
||||
cur = cur->next;
|
||||
xmlFreeNode(prev);
|
||||
}
|
||||
prev = parent->last;
|
||||
prev->next = cur;
|
||||
cur->prev = prev;
|
||||
@ -1967,7 +2059,8 @@ xmlAddChildList(xmlNodePtr parent, xmlNodePtr cur) {
|
||||
* @parent: the parent node
|
||||
* @cur: the child node
|
||||
*
|
||||
* Add a new child element, to @parent, at the end of the child list.
|
||||
* Add a new child element, to @parent, at the end of the child list
|
||||
* merging adjacent TEXT nodes (in which case @cur is freed)
|
||||
* Returns the child or NULL in case of error.
|
||||
*/
|
||||
xmlNodePtr
|
||||
@ -1995,6 +2088,34 @@ xmlAddChild(xmlNodePtr parent, xmlNodePtr cur) {
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* If cur is a TEXT node, merge its content with adjacent TEXT nodes
|
||||
* or with parent->content if parent->content != NULL.
|
||||
* cur is then freed.
|
||||
*/
|
||||
if (cur->type == XML_TEXT_NODE) {
|
||||
if (((parent->type == XML_ELEMENT_NODE) ||
|
||||
(parent->type == XML_TEXT_NODE)) &&
|
||||
(parent->content != NULL)) {
|
||||
#ifndef XML_USE_BUFFER_CONTENT
|
||||
xmlNodeAddContent(parent, cur->content);
|
||||
#else
|
||||
xmlNodeAddContent(parent, xmlBufferContent(cur->content));
|
||||
#endif
|
||||
xmlFreeNode(cur);
|
||||
return(parent);
|
||||
}
|
||||
if ((parent->last != NULL) && (parent->last->type == XML_TEXT_NODE)) {
|
||||
#ifndef XML_USE_BUFFER_CONTENT
|
||||
xmlNodeAddContent(parent->last, cur->content);
|
||||
#else
|
||||
xmlNodeAddContent(parent->last, xmlBufferContent(cur->content));
|
||||
#endif
|
||||
xmlFreeNode(cur);
|
||||
return(parent->last);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* add the new element at the end of the children list.
|
||||
*/
|
||||
|
17
valid.c
17
valid.c
@ -3505,9 +3505,19 @@ xmlValidateElementTypeElement(xmlValidCtxtPtr ctxt, xmlNodePtr *child,
|
||||
*child = cur;
|
||||
return(0);
|
||||
}
|
||||
if (ret == -1) return(-1);
|
||||
cur = *child;
|
||||
do {
|
||||
cur = *child;
|
||||
if (*child == NULL)
|
||||
break; /* while */
|
||||
if (((*child)->type == XML_TEXT_NODE) &&
|
||||
(xmlIsBlankNode(*child))) {
|
||||
*child = (*child)->next;
|
||||
continue;
|
||||
}
|
||||
ret = xmlValidateElementTypeExpr(ctxt, child, cont);
|
||||
if (ret == 1)
|
||||
cur = *child;
|
||||
} while (ret == 1);
|
||||
if (ret == -1) return(-1);
|
||||
*child = cur;
|
||||
@ -3812,6 +3822,11 @@ child_ok:
|
||||
child = elem->children;
|
||||
cont = elemDecl->content;
|
||||
ret = xmlValidateElementTypeElement(ctxt, &child, cont);
|
||||
while ((child != NULL) && (child->type == XML_TEXT_NODE) &&
|
||||
(xmlIsBlankNode(child))) {
|
||||
child = child->next;
|
||||
continue;
|
||||
}
|
||||
if ((ret == 0) || (child != NULL)) {
|
||||
char expr[1000];
|
||||
char list[2000];
|
||||
|
3
xpath.h
3
xpath.h
@ -283,6 +283,9 @@ int valuePush (xmlXPathParserContextPtr ctxt,
|
||||
xmlXPathObjectPtr value);
|
||||
|
||||
xmlXPathObjectPtr xmlXPathNewString (const xmlChar *val);
|
||||
xmlXPathObjectPtr xmlXPathNewCString (const char *val);
|
||||
xmlXPathObjectPtr xmlXPathNewFloat (double val);
|
||||
xmlXPathObjectPtr xmlXPathNewBoolean (int val);
|
||||
xmlXPathObjectPtr xmlXPathNewNodeSet (xmlNodePtr val);
|
||||
void xmlXPathNodeSetAdd (xmlNodeSetPtr cur,
|
||||
xmlNodePtr val);
|
||||
|
Reference in New Issue
Block a user