From 2eac5039948f9eb591e968162538bc71957a7381 Mon Sep 17 00:00:00 2001 From: Daniel Veillard Date: Sun, 9 Jan 2000 21:08:56 +0000 Subject: [PATCH] Added a Fragment function for Raph (DOM) Daniel. --- ChangeLog | 5 +++++ include/libxml/tree.h | 1 + testHTML.c | 2 +- tree.c | 38 ++++++++++++++++++++++++++++++++++++++ tree.h | 1 + 5 files changed, 46 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 54025082..2af9bb9a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Sun Jan 9 23:03:20 CET 2000 Daniel Veillard + + * tree.[ch] : added xmlNewDocFragment() for DOM + * testHTML.c: uninitialized variable. + Wed Jan 5 17:29:17 CET 2000 Daniel Veillard * doc/* : rebuild the docs diff --git a/include/libxml/tree.h b/include/libxml/tree.h index 13469942..f53c4ca3 100644 --- a/include/libxml/tree.h +++ b/include/libxml/tree.h @@ -426,6 +426,7 @@ xmlNodePtr xmlNewReference (xmlDocPtr doc, xmlNodePtr xmlCopyNode (xmlNodePtr node, int recursive); xmlNodePtr xmlCopyNodeList (xmlNodePtr node); +xmlNodePtr xmlNewDocFragment (xmlDocPtr doc); /* * Navigating diff --git a/testHTML.c b/testHTML.c index bd3e6653..61fc95e7 100644 --- a/testHTML.c +++ b/testHTML.c @@ -584,7 +584,7 @@ void parseSAXFile(char *filename) { } void parseAndPrintFile(char *filename) { - htmlDocPtr doc, tmp; + htmlDocPtr doc = NULL, tmp; /* * build an HTML tree from a string; diff --git a/tree.c b/tree.c index f21c76e9..3c145784 100644 --- a/tree.c +++ b/tree.c @@ -1152,6 +1152,44 @@ xmlNewDocRawNode(xmlDocPtr doc, xmlNsPtr ns, return(cur); } +/** + * xmlNewDocFragment: + * @doc: the document owning the fragment + * + * Creation of a new Fragment node. + * Returns a pointer to the new node object. + */ +xmlNodePtr +xmlNewDocFragment(xmlDocPtr doc) { + xmlNodePtr cur; + + /* + * Allocate a new DocumentFragment node and fill the fields. + */ + cur = (xmlNodePtr) xmlMalloc(sizeof(xmlNode)); + if (cur == NULL) { + fprintf(stderr, "xmlNewDocFragment : malloc failed\n"); + return(NULL); + } + + cur->type = XML_DOCUMENT_FRAG_NODE; + cur->doc = doc; + cur->parent = NULL; + cur->next = NULL; + cur->prev = NULL; + cur->childs = NULL; + cur->last = NULL; + cur->properties = NULL; + cur->name = NULL; + cur->ns = NULL; + cur->nsDef = NULL; + cur->content = NULL; +#ifndef XML_WITHOUT_CORBA + cur->_private = NULL; + cur->vepv = NULL; +#endif + return(cur); +} /** * xmlNewText: diff --git a/tree.h b/tree.h index 13469942..f53c4ca3 100644 --- a/tree.h +++ b/tree.h @@ -426,6 +426,7 @@ xmlNodePtr xmlNewReference (xmlDocPtr doc, xmlNodePtr xmlCopyNode (xmlNodePtr node, int recursive); xmlNodePtr xmlCopyNodeList (xmlNodePtr node); +xmlNodePtr xmlNewDocFragment (xmlDocPtr doc); /* * Navigating