libxml2 r3774 - in trunk: . include/libxml



Author: veillard
Date: Mon Aug 25 14:53:31 2008
New Revision: 3774
URL: http://svn.gnome.org/viewvc/libxml2?rev=3774&view=rev

Log:
* xmlreader.c: applied patch from Aswin to fix tree skipping
* include/libxml/entities.h entities.c: fixed a comment and
  added a new xmlNewEntity() entry point
* runtest.c: be less verbose
* tree.c: space and tabs cleanups
daniel


Modified:
   trunk/ChangeLog
   trunk/entities.c
   trunk/include/libxml/entities.h
   trunk/runtest.c
   trunk/runxmlconf.c
   trunk/tree.c
   trunk/xmlreader.c

Modified: trunk/entities.c
==============================================================================
--- trunk/entities.c	(original)
+++ trunk/entities.c	Mon Aug 25 14:53:31 2008
@@ -139,45 +139,19 @@
 }
 
 /*
- * xmlAddEntity : register a new entity for an entities table.
+ * xmlCreateEntity:
+ *
+ * internal routine doing the entity node strutures allocations
  */
 static xmlEntityPtr
-xmlAddEntity(xmlDtdPtr dtd, const xmlChar *name, int type,
-	  const xmlChar *ExternalID, const xmlChar *SystemID,
-	  const xmlChar *content) {
-    xmlDictPtr dict = NULL;
-    xmlEntitiesTablePtr table = NULL;
+xmlCreateEntity(xmlDictPtr dict, const xmlChar *name, int type,
+	        const xmlChar *ExternalID, const xmlChar *SystemID,
+	        const xmlChar *content) {
     xmlEntityPtr ret;
 
-    if (name == NULL)
-	return(NULL);
-    if (dtd == NULL)
-	return(NULL);
-    if (dtd->doc != NULL)
-        dict = dtd->doc->dict;
-
-    switch (type) {
-        case XML_INTERNAL_GENERAL_ENTITY:
-        case XML_EXTERNAL_GENERAL_PARSED_ENTITY:
-        case XML_EXTERNAL_GENERAL_UNPARSED_ENTITY:
-	    if (dtd->entities == NULL)
-		dtd->entities = xmlHashCreateDict(0, dict);
-	    table = dtd->entities;
-	    break;
-        case XML_INTERNAL_PARAMETER_ENTITY:
-        case XML_EXTERNAL_PARAMETER_ENTITY:
-	    if (dtd->pentities == NULL)
-		dtd->pentities = xmlHashCreateDict(0, dict);
-	    table = dtd->pentities;
-	    break;
-        case XML_INTERNAL_PREDEFINED_ENTITY:
-	    return(NULL);
-    }
-    if (table == NULL)
-	return(NULL);
     ret = (xmlEntityPtr) xmlMalloc(sizeof(xmlEntity));
     if (ret == NULL) {
-        xmlEntitiesErrMemory("xmlAddEntity:: malloc failed");
+        xmlEntitiesErrMemory("xmlCreateEntity: malloc failed");
 	return(NULL);
     }
     memset(ret, 0, sizeof(xmlEntity));
@@ -216,6 +190,50 @@
 			the defining entity */
     ret->orig = NULL;
     ret->owner = 0;
+
+    return(ret);
+}
+
+/*
+ * xmlAddEntity : register a new entity for an entities table.
+ */
+static xmlEntityPtr
+xmlAddEntity(xmlDtdPtr dtd, const xmlChar *name, int type,
+	  const xmlChar *ExternalID, const xmlChar *SystemID,
+	  const xmlChar *content) {
+    xmlDictPtr dict = NULL;
+    xmlEntitiesTablePtr table = NULL;
+    xmlEntityPtr ret;
+
+    if (name == NULL)
+	return(NULL);
+    if (dtd == NULL)
+	return(NULL);
+    if (dtd->doc != NULL)
+        dict = dtd->doc->dict;
+
+    switch (type) {
+        case XML_INTERNAL_GENERAL_ENTITY:
+        case XML_EXTERNAL_GENERAL_PARSED_ENTITY:
+        case XML_EXTERNAL_GENERAL_UNPARSED_ENTITY:
+	    if (dtd->entities == NULL)
+		dtd->entities = xmlHashCreateDict(0, dict);
+	    table = dtd->entities;
+	    break;
+        case XML_INTERNAL_PARAMETER_ENTITY:
+        case XML_EXTERNAL_PARAMETER_ENTITY:
+	    if (dtd->pentities == NULL)
+		dtd->pentities = xmlHashCreateDict(0, dict);
+	    table = dtd->pentities;
+	    break;
+        case XML_INTERNAL_PREDEFINED_ENTITY:
+	    return(NULL);
+    }
+    if (table == NULL)
+	return(NULL);
+    ret = xmlCreateEntity(dict, name, type, ExternalID, SystemID, content);
+    if (ret == NULL)
+        return(NULL);
     ret->doc = dtd->doc;
 
     if (xmlHashAddEntry(table, name, ret)) {
@@ -363,6 +381,44 @@
 }
 
 /**
+ * xmlNewEntity:
+ * @doc:  the document
+ * @name:  the entity name
+ * @type:  the entity type XML_xxx_yyy_ENTITY
+ * @ExternalID:  the entity external ID if available
+ * @SystemID:  the entity system ID if available
+ * @content:  the entity content
+ *
+ * Create a new entity, this differs from xmlAddDocEntity() that if
+ * the document is NULL or has no internal subset defined, then an
+ * unlinked entity structure will be returned, it is then the responsability
+ * of the caller to link it to the document later or free it when not needed
+ * anymore.
+ *
+ * Returns a pointer to the entity or NULL in case of error
+ */
+xmlEntityPtr
+xmlNewEntity(xmlDocPtr doc, const xmlChar *name, int type,
+	     const xmlChar *ExternalID, const xmlChar *SystemID,
+	     const xmlChar *content) {
+    xmlEntityPtr ret;
+    xmlDictPtr dict;
+
+    if ((doc != NULL) && (doc->intSubset != NULL)) {
+	return(xmlAddDocEntity(doc, name, type, ExternalID, SystemID, content));
+    }
+    if (doc != NULL)
+        dict = doc->dict;
+    else
+        dict = NULL;
+    ret = xmlCreateEntity(dict, name, type, ExternalID, SystemID, content);
+    if (ret == NULL)
+        return(NULL);
+    ret->doc = doc;
+    return(ret);
+}
+
+/**
  * xmlGetEntityFromTable:
  * @table:  an entity table
  * @name:  the entity name

Modified: trunk/include/libxml/entities.h
==============================================================================
--- trunk/include/libxml/entities.h	(original)
+++ trunk/include/libxml/entities.h	Mon Aug 25 14:53:31 2008
@@ -57,6 +57,8 @@
     const xmlChar           *URI;	/* the full URI as computed */
     int                    owner;	/* does the entity own the childrens */
     int			 checked;	/* was the entity content checked */
+					/* this is also used to count entites
+					 * references done from that entity */
 };
 
 /*
@@ -72,9 +74,17 @@
  */
 
 #ifdef LIBXML_LEGACY_ENABLED
-XMLPUBFUN void XMLCALL		
+XMLPUBFUN void XMLCALL
 		xmlInitializePredefinedEntities	(void);
 #endif /* LIBXML_LEGACY_ENABLED */
+
+XMLPUBFUN xmlEntityPtr XMLCALL
+			xmlNewEntity		(xmlDocPtr doc,
+						 const xmlChar *name,
+						 int type,
+						 const xmlChar *ExternalID,
+						 const xmlChar *SystemID,
+						 const xmlChar *content);
 XMLPUBFUN xmlEntityPtr XMLCALL
 			xmlAddDocEntity		(xmlDocPtr doc,
 						 const xmlChar *name,
@@ -82,53 +92,53 @@
 						 const xmlChar *ExternalID,
 						 const xmlChar *SystemID,
 						 const xmlChar *content);
-XMLPUBFUN xmlEntityPtr XMLCALL		
+XMLPUBFUN xmlEntityPtr XMLCALL
 			xmlAddDtdEntity		(xmlDocPtr doc,
 						 const xmlChar *name,
 						 int type,
 						 const xmlChar *ExternalID,
 						 const xmlChar *SystemID,
 						 const xmlChar *content);
-XMLPUBFUN xmlEntityPtr XMLCALL		
+XMLPUBFUN xmlEntityPtr XMLCALL
 			xmlGetPredefinedEntity	(const xmlChar *name);
-XMLPUBFUN xmlEntityPtr XMLCALL		
+XMLPUBFUN xmlEntityPtr XMLCALL
 			xmlGetDocEntity		(xmlDocPtr doc,
 						 const xmlChar *name);
-XMLPUBFUN xmlEntityPtr XMLCALL		
+XMLPUBFUN xmlEntityPtr XMLCALL
 			xmlGetDtdEntity		(xmlDocPtr doc,
 						 const xmlChar *name);
-XMLPUBFUN xmlEntityPtr XMLCALL		
+XMLPUBFUN xmlEntityPtr XMLCALL
 			xmlGetParameterEntity	(xmlDocPtr doc,
 						 const xmlChar *name);
 #ifdef LIBXML_LEGACY_ENABLED
-XMLPUBFUN const xmlChar * XMLCALL		
+XMLPUBFUN const xmlChar * XMLCALL
 			xmlEncodeEntities	(xmlDocPtr doc,
 						 const xmlChar *input);
 #endif /* LIBXML_LEGACY_ENABLED */
-XMLPUBFUN xmlChar * XMLCALL		
+XMLPUBFUN xmlChar * XMLCALL
 			xmlEncodeEntitiesReentrant(xmlDocPtr doc,
 						 const xmlChar *input);
-XMLPUBFUN xmlChar * XMLCALL		
+XMLPUBFUN xmlChar * XMLCALL
 			xmlEncodeSpecialChars	(xmlDocPtr doc,
 						 const xmlChar *input);
-XMLPUBFUN xmlEntitiesTablePtr XMLCALL	
+XMLPUBFUN xmlEntitiesTablePtr XMLCALL
 			xmlCreateEntitiesTable	(void);
 #ifdef LIBXML_TREE_ENABLED
-XMLPUBFUN xmlEntitiesTablePtr XMLCALL	
+XMLPUBFUN xmlEntitiesTablePtr XMLCALL
 			xmlCopyEntitiesTable	(xmlEntitiesTablePtr table);
 #endif /* LIBXML_TREE_ENABLED */
-XMLPUBFUN void XMLCALL			
+XMLPUBFUN void XMLCALL
 			xmlFreeEntitiesTable	(xmlEntitiesTablePtr table);
 #ifdef LIBXML_OUTPUT_ENABLED
-XMLPUBFUN void XMLCALL			
+XMLPUBFUN void XMLCALL
 			xmlDumpEntitiesTable	(xmlBufferPtr buf,
 						 xmlEntitiesTablePtr table);
-XMLPUBFUN void XMLCALL			
+XMLPUBFUN void XMLCALL
 			xmlDumpEntityDecl	(xmlBufferPtr buf,
 						 xmlEntityPtr ent);
 #endif /* LIBXML_OUTPUT_ENABLED */
 #ifdef LIBXML_LEGACY_ENABLED
-XMLPUBFUN void XMLCALL			
+XMLPUBFUN void XMLCALL
 			xmlCleanupPredefinedEntities(void);
 #endif /* LIBXML_LEGACY_ENABLED */
 

Modified: trunk/runtest.c
==============================================================================
--- trunk/runtest.c	(original)
+++ trunk/runtest.c	Mon Aug 25 14:53:31 2008
@@ -129,7 +129,7 @@
     int len;
 
     if ((pattern == NULL) || (pglob == NULL)) return(-1);
-    
+
     strncpy(directory, pattern, 499);
     for (len = strlen(directory);len >= 0;len--) {
         if (directory[len] == '/') {
@@ -141,12 +141,12 @@
     if (len <= 0)
         len = 0;
 
-    
+
     ret = pglob;
     memset(ret, 0, sizeof(glob_t));
-    
+
     hFind = FindFirstFileA(pattern, &FindFileData);
-    if (hFind == INVALID_HANDLE_VALUE) 
+    if (hFind == INVALID_HANDLE_VALUE)
         return(0);
     nb_paths = 20;
     ret->gl_pathv = (char **) malloc(nb_paths * sizeof(char *));
@@ -181,14 +181,14 @@
     FindClose(hFind);
     return(0);
 }
- 
+
 
 
 static void globfree(glob_t *pglob) {
     unsigned int i;
     if (pglob == NULL)
         return;
-    
+
     for (i = 0;i < pglob->gl_pathc;i++) {
          if (pglob->gl_pathv[i] != NULL)
              free(pglob->gl_pathv[i]);
@@ -222,7 +222,7 @@
  * which is shared to the current running test. We also don't want to have
  * network downloads modifying tests.
  */
-static xmlParserInputPtr 
+static xmlParserInputPtr
 testExternalEntityLoader(const char *URL, const char *ID,
 			 xmlParserCtxtPtr ctxt) {
     xmlParserInputPtr ret;
@@ -234,7 +234,7 @@
 	ret = xmlNoNetExternalEntityLoader(URL, ID, ctxt);
 	extraMemoryFromResolver += xmlMemUsed() - memused;
     }
-      
+
     return(ret);
 }
 
@@ -292,12 +292,12 @@
 /**
  * xmlParserPrintFileContext:
  * @input:  an xmlParserInputPtr input
- * 
+ *
  * Displays current context within the input content for error tracking
  */
 
 static void
-xmlParserPrintFileContextInternal(xmlParserInputPtr input , 
+xmlParserPrintFileContextInternal(xmlParserInputPtr input ,
 		xmlGenericErrorFunc chanl, void *data ) {
     const xmlChar *cur, *base;
     unsigned int n, col;	/* GCC warns if signed, because compared with sizeof() */
@@ -313,8 +313,8 @@
     }
     n = 0;
     /* search backwards for beginning-of-line (to max buff size) */
-    while ((n++ < (sizeof(content)-1)) && (cur > base) && 
-    	   (*(cur) != '\n') && (*(cur) != '\r'))
+    while ((n++ < (sizeof(content)-1)) && (cur > base) &&
+   (*(cur) != '\n') && (*(cur) != '\r'))
         cur--;
     if ((*(cur) == '\n') || (*(cur) == '\r')) cur++;
     /* calculate the error position in terms of the current position */
@@ -323,8 +323,8 @@
     n = 0;
     ctnt = content;
     /* copy selected text to our buffer */
-    while ((*cur != 0) && (*(cur) != '\n') && 
-    	   (*(cur) != '\r') && (n < sizeof(content)-1)) {
+    while ((*cur != 0) && (*(cur) != '\n') &&
+   (*(cur) != '\r') && (n < sizeof(content)-1)) {
 		*ctnt++ = *cur++;
 	n++;
     }
@@ -573,7 +573,7 @@
 	(filename[4] == '/'))
 	filename = &filename[5];
  *************/
-    
+
     base = baseFilename(filename);
     if (suffix == NULL)
         suffix = ".tmp";
@@ -650,7 +650,7 @@
     int idx = 0;
     struct stat info;
 
-    if (stat(filename, &info) < 0) 
+    if (stat(filename, &info) < 0)
 	return(-1);
     if (info.st_size != size)
         return(-1);
@@ -661,7 +661,7 @@
         res = read(fd, bytes, 4096);
 	if (res <= 0)
 	    break;
-	if (res + idx > size) 
+	if (res + idx > size)
 	    break;
 	if (memcmp(bytes, &mem[idx], res) != 0) {
 	    int ix;
@@ -683,7 +683,7 @@
     struct stat info;
     char *base;
     int siz = 0;
-    if (stat(filename, &info) < 0) 
+    if (stat(filename, &info) < 0)
 	return(-1);
     base = malloc(info.st_size + 1);
     if (base == NULL)
@@ -893,7 +893,7 @@
 	return(NULL);
     /* xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; */
 
-    
+
     fprintf(SAXdebug, "SAX.resolveEntity(");
     if (publicId != NULL)
 	fprintf(SAXdebug, "%s", (char *)publicId);
@@ -953,8 +953,8 @@
 /**
  * entityDeclDebug:
  * @ctxt:  An XML parser context
- * @name:  the entity name 
- * @type:  the entity type 
+ * @name:  the entity name
+ * @type:  the entity type
  * @publicId: The public ID of the entity
  * @systemId: The system ID of the entity
  * @content: the entity value (without processing).
@@ -983,8 +983,8 @@
 /**
  * attributeDeclDebug:
  * @ctxt:  An XML parser context
- * @name:  the attribute name 
- * @type:  the attribute type 
+ * @name:  the attribute name
+ * @type:  the attribute type
  *
  * An attribute definition has been parsed
  */
@@ -1008,8 +1008,8 @@
 /**
  * elementDeclDebug:
  * @ctxt:  An XML parser context
- * @name:  the element name 
- * @type:  the element type 
+ * @name:  the element name
+ * @type:  the element type
  * @content: the element value (without processing).
  *
  * An element definition has been parsed
@@ -1195,7 +1195,7 @@
  * @ctxt:  An XML parser context
  * @name:  The entity name
  *
- * called when an entity reference is detected. 
+ * called when an entity reference is detected.
  */
 static void
 referenceDebug(void *ctx ATTRIBUTE_UNUSED, const xmlChar *name)
@@ -1431,7 +1431,7 @@
     else
 	fprintf(SAXdebug, ", '%s'", (char *) URI);
     fprintf(SAXdebug, ", %d", nb_namespaces);
-    
+
     if (namespaces != NULL) {
         for (i = 0;i < nb_namespaces * 2;i++) {
 	    fprintf(SAXdebug, ", xmlns");
@@ -1707,7 +1707,7 @@
     } else
     unlink(temp);
     free(temp);
-    
+
     /* switch back to structured error handling */
     xmlSetGenericErrorFunc(NULL, NULL);
     xmlSetStructuredErrorFunc(NULL, testStructuredErrorHandler);
@@ -1814,7 +1814,7 @@
         fprintf(stderr, "Failed to load %s\n", filename);
 	return(-1);
     }
-    
+
 #ifdef LIBXML_HTML_ENABLED
     if (options & XML_PARSE_HTML)
 	ctxt = htmlCreatePushParserCtxt(NULL, NULL, base + cur, 4, filename,
@@ -1911,7 +1911,7 @@
         fprintf(stderr, "Failed to load %s\n", filename);
 	return(-1);
     }
-    
+
     doc = xmlReadMemory(base, size, filename, NULL, 0);
     unloadMem(base);
     if (doc == NULL) {
@@ -2076,8 +2076,8 @@
 
     value = xmlTextReaderConstValue(reader);
 
-    
-    fprintf(out, "%d %d %s %d %d", 
+
+    fprintf(out, "%d %d %s %d %d",
 	    xmlTextReaderDepth(reader),
 	    type,
 	    name,
@@ -2265,7 +2265,7 @@
 testXPath(const char *str, int xptr, int expr) {
     xmlXPathObjectPtr res;
     xmlXPathContextPtr ctxt;
-    
+
     nb_tests++;
 #if defined(LIBXML_XPTR_ENABLED)
     if (xptr) {
@@ -2336,10 +2336,10 @@
     while (fgets(expression, 4500, input) != NULL) {
 	len = strlen(expression);
 	len--;
-	while ((len >= 0) && 
+	while ((len >= 0) &&
 	       ((expression[len] == '\n') || (expression[len] == '\t') ||
 		(expression[len] == '\r') || (expression[len] == ' '))) len--;
-	expression[len + 1] = 0;      
+	expression[len + 1] = 0;
 	if (len >= 0) {
 	    fprintf(xpathOutput,
 	            "\n========================\nExpression: %s\n",
@@ -3217,7 +3217,7 @@
  * @result: the file with expected result
  * @err: the file with error messages
  *
- * Parse a set of files with streaming, applying an RNG schemas 
+ * Parse a set of files with streaming, applying an RNG schemas
  *
  * Returns 0 in case of success, an error code otherwise
  */
@@ -3257,7 +3257,7 @@
      * hack is also done in the Makefile
      */
     if ((!strcmp(prefix, "tutor10_1")) || (!strcmp(prefix, "tutor10_2")) ||
-        (!strcmp(prefix, "tutor3_2")) || (!strcmp(prefix, "307377"))) 
+        (!strcmp(prefix, "tutor3_2")) || (!strcmp(prefix, "307377")))
 	disable_err = 1;
 
     snprintf(pattern, 499, "./test/relaxng/%s_?.xml", prefix);
@@ -3321,7 +3321,7 @@
 
     type = xmlTextReaderNodeType(reader);
     empty = xmlTextReaderIsEmptyElement(reader);
-	
+
     if (type == XML_READER_TYPE_ELEMENT) {
 	/* do the check only on element start */
 	match = xmlPatternMatch(patternc, xmlTextReaderCurrentNode(reader));
@@ -3353,9 +3353,9 @@
 			"  pattern %s node %s\n",
 			pattern, path);
 	    }
-	    
 
-	} 
+
+	}
 	if ((type == XML_READER_TYPE_END_ELEMENT) ||
 	    ((type == XML_READER_TYPE_ELEMENT) && (empty))) {
 	    ret = xmlStreamPop(patstream);
@@ -3376,7 +3376,7 @@
  * @result: the file with expected result
  * @err: the file with error messages
  *
- * Parse a set of files with streaming, applying an RNG schemas 
+ * Parse a set of files with streaming, applying an RNG schemas
  *
  * Returns 0 in case of success, an error code otherwise
  */
@@ -3525,13 +3525,13 @@
  ************************************************************************/
 static xmlXPathObjectPtr
 load_xpath_expr (xmlDocPtr parent_doc, const char* filename) {
-    xmlXPathObjectPtr xpath; 
+    xmlXPathObjectPtr xpath;
     xmlDocPtr doc;
     xmlChar *expr;
-    xmlXPathContextPtr ctx; 
+    xmlXPathContextPtr ctx;
     xmlNodePtr node;
     xmlNsPtr ns;
-    
+
     /*
      * load XPath expr as a file
      */
@@ -3543,10 +3543,10 @@
 	fprintf(stderr, "Error: unable to parse file \"%s\"\n", filename);
 	return(NULL);
     }
-    
+
     /*
      * Check the document is of the right kind
-     */    
+     */
     if(xmlDocGetRootElement(doc) == NULL) {
         fprintf(stderr,"Error: empty document for file \"%s\"\n", filename);
 	xmlFreeDoc(doc);
@@ -3557,8 +3557,8 @@
     while(node != NULL && !xmlStrEqual(node->name, (const xmlChar *)"XPath")) {
 	node = node->next;
     }
-    
-    if(node == NULL) {   
+
+    if(node == NULL) {
         fprintf(stderr,"Error: XPath element expected in the file  \"%s\"\n", filename);
 	xmlFreeDoc(doc);
 	return(NULL);
@@ -3574,8 +3574,8 @@
     ctx = xmlXPathNewContext(parent_doc);
     if(ctx == NULL) {
         fprintf(stderr,"Error: unable to create new context\n");
-        xmlFree(expr); 
-        xmlFreeDoc(doc); 
+        xmlFree(expr);
+        xmlFreeDoc(doc);
         return(NULL);
     }
 
@@ -3586,31 +3586,31 @@
     while(ns != NULL) {
 	if(xmlXPathRegisterNs(ctx, ns->prefix, ns->href) != 0) {
 	    fprintf(stderr,"Error: unable to register NS with prefix=\"%s\" and href=\"%s\"\n", ns->prefix, ns->href);
-    	    xmlFree(expr); 
-	    xmlXPathFreeContext(ctx); 
-	    xmlFreeDoc(doc); 
+    xmlFree(expr);
+	    xmlXPathFreeContext(ctx);
+	    xmlFreeDoc(doc);
 	    return(NULL);
 	}
 	ns = ns->next;
     }
 
-    /*  
+    /*
      * Evaluate xpath
      */
     xpath = xmlXPathEvalExpression(expr, ctx);
     if(xpath == NULL) {
         fprintf(stderr,"Error: unable to evaluate xpath expression\n");
-    	xmlFree(expr); 
-        xmlXPathFreeContext(ctx); 
-        xmlFreeDoc(doc); 
+xmlFree(expr);
+        xmlXPathFreeContext(ctx);
+        xmlFreeDoc(doc);
         return(NULL);
     }
 
     /* print_xpath_nodes(xpath->nodesetval); */
 
-    xmlFree(expr); 
-    xmlXPathFreeContext(ctx); 
-    xmlFreeDoc(doc); 
+    xmlFree(expr);
+    xmlXPathFreeContext(ctx);
+    xmlFreeDoc(doc);
     return(xpath);
 }
 
@@ -3620,7 +3620,7 @@
 #define xxx_growBufferReentrant() {						\
     buffer_size *= 2;							\
     buffer = (xmlChar **)						\
-    		xmlRealloc(buffer, buffer_size * sizeof(xmlChar*));	\
+	xmlRealloc(buffer, buffer_size * sizeof(xmlChar*));	\
     if (buffer == NULL) {						\
 	perror("realloc failed");					\
 	return(NULL);							\
@@ -3654,7 +3654,7 @@
 	return(NULL);
     }
     out = buffer;
-    
+
     while(*str != '\0') {
 	if (out - buffer > buffer_size - 10) {
 	    int indx = out - buffer;
@@ -3670,12 +3670,12 @@
     return buffer;
 }
 
-static int 
+static int
 c14nRunTest(const char* xml_filename, int with_comments, int exclusive,
 	    const char* xpath_filename, const char *ns_filename,
 	    const char* result_file) {
     xmlDocPtr doc;
-    xmlXPathObjectPtr xpath = NULL; 
+    xmlXPathObjectPtr xpath = NULL;
     xmlChar *result = NULL;
     int ret;
     xmlChar **inclusive_namespaces = NULL;
@@ -3695,24 +3695,24 @@
 	fprintf(stderr, "Error: unable to parse file \"%s\"\n", xml_filename);
 	return(-1);
     }
-    
+
     /*
      * Check the document is of the right kind
-     */    
+     */
     if(xmlDocGetRootElement(doc) == NULL) {
         fprintf(stderr,"Error: empty document for file \"%s\"\n", xml_filename);
 	xmlFreeDoc(doc);
 	return(-1);
     }
 
-    /* 
-     * load xpath file if specified 
+    /*
+     * load xpath file if specified
      */
     if(xpath_filename) {
 	xpath = load_xpath_expr(doc, xpath_filename);
 	if(xpath == NULL) {
 	    fprintf(stderr,"Error: unable to evaluate xpath expression\n");
-	    xmlFreeDoc(doc); 
+	    xmlFreeDoc(doc);
 	    return(-1);
 	}
     }
@@ -3721,7 +3721,7 @@
         if (loadMem(ns_filename, &nslist, &nssize)) {
 	    fprintf(stderr,"Error: unable to evaluate xpath expression\n");
 	    if(xpath != NULL) xmlXPathFreeObject(xpath);
-	    xmlFreeDoc(doc); 
+	    xmlFreeDoc(doc);
 	    return(-1);
 	}
         inclusive_namespaces = parse_list((xmlChar *) nslist);
@@ -3729,10 +3729,10 @@
 
     /*
      * Canonical form
-     */      
+     */
     /* fprintf(stderr,"File \"%s\" loaded: start canonization\n", xml_filename); */
-    ret = xmlC14NDocDumpMemory(doc, 
-	    (xpath) ? xpath->nodesetval : NULL, 
+    ret = xmlC14NDocDumpMemory(doc,
+	    (xpath) ? xpath->nodesetval : NULL,
 	    exclusive, inclusive_namespaces,
 	    with_comments, &result);
     if (ret >= 0) {
@@ -3746,15 +3746,15 @@
 	fprintf(stderr,"Error: failed to canonicalize XML file \"%s\" (ret=%d)\n", xml_filename, ret);
 	ret = -1;
     }
-        
+
     /*
      * Cleanup
-     */ 
+     */
     if (result != NULL) xmlFree(result);
     if(xpath != NULL) xmlXPathFreeObject(xpath);
     if (inclusive_namespaces != NULL) xmlFree(inclusive_namespaces);
     if (nslist != NULL) free((char *) nslist);
-    xmlFreeDoc(doc);    
+    xmlFreeDoc(doc);
 
     return(ret);
 }
@@ -3917,7 +3917,7 @@
     void *results[MAX_ARGC];
     int ret;
     int res = 0;
-    
+
     xmlInitParser();
 
     for (repeat = 0; repeat < 500; repeat++) {
@@ -3993,7 +3993,7 @@
             DWORD useless;
 
             tid[i] = CreateThread(NULL, 0,
-                                  win32_thread_specific_data, 
+                                  win32_thread_specific_data,
 				  (void *) testfiles[i], 0,
                                   &useless);
             if (tid[i] == NULL) {
@@ -4091,7 +4091,7 @@
     return (-1);
 }
 #endif
-static int 
+static int
 threadsTest(const char *filename ATTRIBUTE_UNUSED,
 	    const char *resul ATTRIBUTE_UNUSED,
 	    const char *err ATTRIBUTE_UNUSED,
@@ -4392,7 +4392,6 @@
 
     initializeLibxml2();
 
-    
     for (a = 1; a < argc;a++) {
         if (!strcmp(argv[a], "-v"))
 	    verbose = 1;

Modified: trunk/runxmlconf.c
==============================================================================
--- trunk/runxmlconf.c	(original)
+++ trunk/runxmlconf.c	Mon Aug 25 14:53:31 2008
@@ -446,22 +446,27 @@
 }
 
 static int
-xmlconfTestCases(xmlDocPtr doc, xmlNodePtr cur) {
+xmlconfTestCases(xmlDocPtr doc, xmlNodePtr cur, int level) {
     xmlChar *profile;
     int ret = 0;
     int tests = 0;
+    int output = 0;
 
-    profile = xmlGetProp(cur, BAD_CAST "PROFILE");
-    if (profile != NULL) {
-        printf("Test cases: %s\n", (char *) profile);
-	xmlFree(profile);
+    if (level == 1) {
+	profile = xmlGetProp(cur, BAD_CAST "PROFILE");
+	if (profile != NULL) {
+	    output = 1;
+	    level++;
+	    printf("Test cases: %s\n", (char *) profile);
+	    xmlFree(profile);
+	}
     }
     cur = cur->children;
     while (cur != NULL) {
         /* look only at elements we ignore everything else */
         if (cur->type == XML_ELEMENT_NODE) {
 	    if (xmlStrEqual(cur->name, BAD_CAST "TESTCASES")) {
-	        ret += xmlconfTestCases(doc, cur);
+	        ret += xmlconfTestCases(doc, cur, level);
 	    } else if (xmlStrEqual(cur->name, BAD_CAST "TEST")) {
 	        if (xmlconfTestItem(doc, cur) >= 0)
 		    ret++;
@@ -472,8 +477,10 @@
 	}
         cur = cur->next;
     }
-    if (tests > 0)
-	printf("Test cases: %d tests\n", tests);
+    if (output == 1) {
+	if (tests > 0)
+	    printf("Test cases: %d tests\n", tests);
+    }
     return(ret);
 }
 
@@ -493,7 +500,7 @@
         /* look only at elements we ignore everything else */
         if (cur->type == XML_ELEMENT_NODE) {
 	    if (xmlStrEqual(cur->name, BAD_CAST "TESTCASES")) {
-	        ret += xmlconfTestCases(doc, cur);
+	        ret += xmlconfTestCases(doc, cur, 1);
 	    } else {
 	        fprintf(stderr, "Unhandled element %s\n", (char *)cur->name);
 	    }
@@ -584,6 +591,7 @@
         ret = 1;
 	printf("Total %d tests, %d errors, %d leaks\n",
 	       nb_tests, nb_errors, nb_leaks);
+	printf("See %s for detailed output\n", LOGFILE);
     }
     xmlXPathFreeContext(ctxtXPath);
     xmlCleanupParser();

Modified: trunk/tree.c
==============================================================================
--- trunk/tree.c	(original)
+++ trunk/tree.c	Mon Aug 25 14:53:31 2008
@@ -45,7 +45,7 @@
 
 /************************************************************************
  *									*
- * 		Forward declarations					*
+ *		Forward declarations					*
  *									*
  ************************************************************************/
 
@@ -55,7 +55,7 @@
 
 /************************************************************************
  *									*
- * 		Tree memory error handler				*
+ *		Tree memory error handler				*
  *									*
  ************************************************************************/
 /**
@@ -103,7 +103,7 @@
 
 /************************************************************************
  *									*
- * 		A few static variables and macros			*
+ *		A few static variables and macros			*
  *									*
  ************************************************************************/
 /* #undef xmlStringText */
@@ -123,7 +123,7 @@
         (n)->last = NULL;						\
     } else {								\
         while (ulccur->next != NULL) {					\
-	       	ulccur->parent = (n);					\
+		ulccur->parent = (n);					\
 		ulccur = ulccur->next;					\
 	}								\
 	ulccur->parent = (n);						\
@@ -138,12 +138,12 @@
 
 /************************************************************************
  *									*
- *		Functions to move to entities.c once the 		*
+ *		Functions to move to entities.c once the		*
  *		API freeze is smoothen and they can be made public.	*
  *									*
  ************************************************************************/
 #include <libxml/hash.h>
- 
+
 #ifdef LIBXML_TREE_ENABLED
 /**
  * xmlGetEntityFromDtd:
@@ -152,17 +152,17 @@
  *
  * Do an entity lookup in the DTD entity hash table and
  * return the corresponding entity, if found.
- * 
+ *
  * Returns A pointer to the entity structure or NULL if not found.
  */
 static xmlEntityPtr
 xmlGetEntityFromDtd(xmlDtdPtr dtd, const xmlChar *name) {
     xmlEntitiesTablePtr table;
-    
+
     if((dtd != NULL) && (dtd->entities != NULL)) {
 	table = (xmlEntitiesTablePtr) dtd->entities;
 	return((xmlEntityPtr) xmlHashLookup(table, name));
-    	/* return(xmlGetEntityFromTable(table, name)); */
+	/* return(xmlGetEntityFromTable(table, name)); */
     }
     return(NULL);
 }
@@ -170,7 +170,7 @@
  * xmlGetParameterEntityFromDtd:
  * @dtd:  A pointer to the DTD to search
  * @name:  The entity name
- * 
+ *
  * Do an entity lookup in the DTD pararmeter entity hash table and
  * return the corresponding entity, if found.
  *
@@ -179,7 +179,7 @@
 static xmlEntityPtr
 xmlGetParameterEntityFromDtd(xmlDtdPtr dtd, const xmlChar *name) {
     xmlEntitiesTablePtr table;
-    
+
     if ((dtd != NULL) && (dtd->pentities != NULL)) {
 	table = (xmlEntitiesTablePtr) dtd->pentities;
 	return((xmlEntityPtr) xmlHashLookup(table, name));
@@ -240,7 +240,7 @@
 /**
  * xmlSplitQName2:
  * @name:  the full QName
- * @prefix:  a xmlChar ** 
+ * @prefix:  a xmlChar **
  *
  * parse an XML qualified name string
  *
@@ -278,9 +278,9 @@
      * we are not trying to validate but just to cut, and yes it will
      * work even if this is as set of UTF-8 encoded chars
      */
-    while ((name[len] != 0) && (name[len] != ':')) 
+    while ((name[len] != 0) && (name[len] != ':'))
 	len++;
-    
+
     if (name[len] == 0)
 	return(NULL);
 
@@ -329,9 +329,9 @@
      * we are not trying to validate but just to cut, and yes it will
      * work even if this is as set of UTF-8 encoded chars
      */
-    while ((name[l] != 0) && (name[l] != ':')) 
+    while ((name[l] != 0) && (name[l] != ':'))
 	l++;
-    
+
     if (name[l] == 0)
 	return(NULL);
 
@@ -345,7 +345,7 @@
  *		Check Name, NCName and QName strings			*
  *									*
  ************************************************************************/
- 
+
 #define CUR_SCHAR(s, l) xmlStringCurrentChar(NULL, s, &l)
 
 #if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XPATH_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) || defined(LIBXML_DEBUG_ENABLED) || defined (LIBXML_HTML_ENABLED) || defined(LIBXML_SAX1_ENABLED) || defined(LIBXML_HTML_ENABLED) || defined(LIBXML_WRITER_ENABLED) || defined(LIBXML_DOCB_ENABLED)
@@ -668,14 +668,14 @@
  *		Allocation and deallocation of basic structures		*
  *									*
  ************************************************************************/
- 
+
 /**
  * xmlSetBufferAllocationScheme:
  * @scheme:  allocation method to use
- * 
+ *
  * Set the buffer allocation method.  Types are
  * XML_BUFFER_ALLOC_EXACT - use exact sizes, keeps memory usage down
- * XML_BUFFER_ALLOC_DOUBLEIT - double buffer when extra needed, 
+ * XML_BUFFER_ALLOC_DOUBLEIT - double buffer when extra needed,
  *                             improves performance
  */
 void
@@ -688,9 +688,9 @@
  *
  * Types are
  * XML_BUFFER_ALLOC_EXACT - use exact sizes, keeps memory usage down
- * XML_BUFFER_ALLOC_DOUBLEIT - double buffer when extra needed, 
+ * XML_BUFFER_ALLOC_DOUBLEIT - double buffer when extra needed,
  *                             improves performance
- * 
+ *
  * Returns the current allocation scheme
  */
 xmlBufferAllocationScheme
@@ -733,9 +733,9 @@
     cur->type = XML_LOCAL_NAMESPACE;
 
     if (href != NULL)
-	cur->href = xmlStrdup(href); 
+	cur->href = xmlStrdup(href);
     if (prefix != NULL)
-	cur->prefix = xmlStrdup(prefix); 
+	cur->prefix = xmlStrdup(prefix);
 
     /*
      * Add it at the end to preserve parsing order ...
@@ -751,14 +751,14 @@
 		(xmlStrEqual(prev->prefix, cur->prefix))) {
 		xmlFreeNs(cur);
 		return(NULL);
-	    }    
+	    }
 	    while (prev->next != NULL) {
 	        prev = prev->next;
 		if (((prev->prefix == NULL) && (cur->prefix == NULL)) ||
 		    (xmlStrEqual(prev->prefix, cur->prefix))) {
 		    xmlFreeNs(cur);
 		    return(NULL);
-		}    
+		}
 	    }
 	    prev->next = cur;
 	}
@@ -867,11 +867,11 @@
     cur->type = XML_DTD_NODE;
 
     if (name != NULL)
-	cur->name = xmlStrdup(name); 
+	cur->name = xmlStrdup(name);
     if (ExternalID != NULL)
-	cur->ExternalID = xmlStrdup(ExternalID); 
+	cur->ExternalID = xmlStrdup(ExternalID);
     if (SystemID != NULL)
-	cur->SystemID = xmlStrdup(SystemID); 
+	cur->SystemID = xmlStrdup(SystemID);
     if (doc != NULL)
 	doc->extSubset = cur;
     cur->doc = doc;
@@ -949,7 +949,7 @@
 	}
     }
     if (ExternalID != NULL) {
-	cur->ExternalID = xmlStrdup(ExternalID); 
+	cur->ExternalID = xmlStrdup(ExternalID);
 	if (cur->ExternalID  == NULL) {
 	    xmlTreeErrMemory("building internal subset");
 	    if (cur->name != NULL)
@@ -959,7 +959,7 @@
 	}
     }
     if (SystemID != NULL) {
-	cur->SystemID = xmlStrdup(SystemID); 
+	cur->SystemID = xmlStrdup(SystemID);
 	if (cur->SystemID == NULL) {
 	    xmlTreeErrMemory("building internal subset");
 	    if (cur->name != NULL)
@@ -1022,7 +1022,7 @@
  * current scope
  */
 #define DICT_FREE(str)						\
-	if ((str) && ((!dict) || 				\
+	if ((str) && ((!dict) ||				\
 	    (xmlDictOwns(dict, (const xmlChar *)(str)) == 0)))	\
 	    xmlFree((char *)(str));
 
@@ -1105,7 +1105,7 @@
     /* TODO !!! */
     if (cur->notations != NULL)
         xmlFreeNotationTable((xmlNotationTablePtr) cur->notations);
-    
+
     if (cur->elements != NULL)
         xmlFreeElementTable((xmlElementTablePtr) cur->elements);
     if (cur->attributes != NULL)
@@ -1144,7 +1144,7 @@
     memset(cur, 0, sizeof(xmlDoc));
     cur->type = XML_DOCUMENT_NODE;
 
-    cur->version = xmlStrdup(version); 
+    cur->version = xmlStrdup(version);
     if (cur->version == NULL) {
 	xmlTreeErrMemory("building doc");
 	xmlFree(cur);
@@ -1282,7 +1282,7 @@
 		else
 		    tmp = 0;
 		while (tmp != ';') { /* Non input consuming loop */
-		    if ((tmp >= '0') && (tmp <= '9')) 
+		    if ((tmp >= '0') && (tmp <= '9'))
 			charval = charval * 16 + (tmp - '0');
 		    else if ((tmp >= 'a') && (tmp <= 'f'))
 			charval = charval * 16 + (tmp - 'a') + 10;
@@ -1310,7 +1310,7 @@
 		else
 		    tmp = 0;
 		while (tmp != ';') { /* Non input consuming loops */
-		    if ((tmp >= '0') && (tmp <= '9')) 
+		    if ((tmp >= '0') && (tmp <= '9'))
 			charval = charval * 10 + (tmp - '0');
 		    else {
 			xmlTreeErr(XML_TREE_INVALID_DEC, (xmlNodePtr) doc,
@@ -1355,7 +1355,7 @@
 			    last = xmlAddNextSibling(last, node);
 			} else
 			    xmlNodeAddContent(last, ent->content);
-			    
+
 		    } else {
 			/*
 			 * Create a new REFERENCE_REF node
@@ -1476,7 +1476,7 @@
 		cur += 3;
 		tmp = *cur;
 		while (tmp != ';') { /* Non input consuming loop */
-		    if ((tmp >= '0') && (tmp <= '9')) 
+		    if ((tmp >= '0') && (tmp <= '9'))
 			charval = charval * 16 + (tmp - '0');
 		    else if ((tmp >= 'a') && (tmp <= 'f'))
 			charval = charval * 16 + (tmp - 'a') + 10;
@@ -1498,7 +1498,7 @@
 		cur += 2;
 		tmp = *cur;
 		while (tmp != ';') { /* Non input consuming loops */
-		    if ((tmp >= '0') && (tmp <= '9')) 
+		    if ((tmp >= '0') && (tmp <= '9'))
 			charval = charval * 10 + (tmp - '0');
 		    else {
 			xmlTreeErr(XML_TREE_INVALID_DEC, (xmlNodePtr) doc,
@@ -1540,7 +1540,7 @@
 			    last = xmlAddNextSibling(last, node);
 			} else
 			    xmlNodeAddContent(last, ent->content);
-			    
+
 		    } else {
 			/*
 			 * Create a new REFERENCE_REF node
@@ -1978,7 +1978,7 @@
 	cur->name = xmlDictLookup(doc->dict, name, -1);
     else
 	cur->name = xmlStrdup(name);
-    cur->doc = doc; 
+    cur->doc = doc;
     if (value != NULL) {
 	xmlNodePtr tmp;
 
@@ -2185,7 +2185,7 @@
     }
     memset(cur, 0, sizeof(xmlNode));
     cur->type = XML_ELEMENT_NODE;
-    
+
     cur->name = xmlStrdup(name);
     cur->ns = ns;
 
@@ -2228,7 +2228,7 @@
     }
     memset(cur, 0, sizeof(xmlNode));
     cur->type = XML_ELEMENT_NODE;
-    
+
     cur->name = name;
     cur->ns = ns;
 
@@ -2416,9 +2416,9 @@
  * a child TEXT node will be created containing the string @content.
  * NOTE: Use xmlNewChild() if @content will contain entities that need to be
  * preserved. Use this function, xmlNewTextChild(), if you need to ensure that
- * reserved XML chars that might appear in @content, such as the ampersand, 
- * greater-than or less-than signs, are automatically replaced by their XML 
- * escaped entity representations. 
+ * reserved XML chars that might appear in @content, such as the ampersand,
+ * greater-than or less-than signs, are automatically replaced by their XML
+ * escaped entity representations.
  *
  * Returns a pointer to the new node object.
  */
@@ -2866,14 +2866,14 @@
 
 /**
  * xmlAddPropSibling:
- * @prev:  the attribute to which @prop is added after 
+ * @prev:  the attribute to which @prop is added after
  * @cur:   the base attribute passed to calling function
  * @prop:  the new attribute
  *
  * Add a new attribute after @prev using @cur as base attribute.
  * When inserting before @cur, @prev is passed as @cur->prev.
  * When inserting after @cur, @prev is passed as @cur.
- * If an existing attribute is found it is detroyed prior to adding @prop. 
+ * If an existing attribute is found it is detroyed prior to adding @prop.
  *
  * Returns the attribute being inserted or NULL in case of error.
  */
@@ -2923,7 +2923,7 @@
  * first unlinked from its existing context.
  * As a result of text merging @elem may be freed.
  * If the new node is ATTRIBUTE, it is added into properties instead of children.
- * If there is an attribute with equal name, it is first destroyed. 
+ * If there is an attribute with equal name, it is first destroyed.
  *
  * Returns the new node or NULL in case of error.
  */
@@ -3001,7 +3001,7 @@
  * If the new node was already inserted in a document it is
  * first unlinked from its existing context.
  * If the new node is ATTRIBUTE, it is added into properties instead of children.
- * If there is an attribute with equal name, it is first destroyed. 
+ * If there is an attribute with equal name, it is first destroyed.
  *
  * Returns the new node or NULL in case of error.
  */
@@ -3105,7 +3105,7 @@
      * Constant time is we can rely on the ->parent->last to find
      * the last sibling.
      */
-    if ((cur->type != XML_ATTRIBUTE_NODE) && (cur->parent != NULL) && 
+    if ((cur->type != XML_ATTRIBUTE_NODE) && (cur->parent != NULL) &&
 	(cur->parent->children != NULL) &&
 	(cur->parent->last != NULL) &&
 	(cur->parent->last->next == NULL)) {
@@ -3187,10 +3187,10 @@
 	/*
 	 * If cur and parent->last both are TEXT nodes, then merge them.
 	 */
-	if ((cur->type == XML_TEXT_NODE) && 
+	if ((cur->type == XML_TEXT_NODE) &&
 	    (parent->last->type == XML_TEXT_NODE) &&
 	    (cur->name == parent->last->name)) {
-    	    xmlNodeAddContent(parent->last, cur->content);
+	    xmlNodeAddContent(parent->last, cur->content);
 	    /*
 	     * if it's the only child, nothing more to be done.
 	     */
@@ -3228,7 +3228,7 @@
  * Add a new node to @parent, at the end of the child (or property) list
  * merging adjacent TEXT nodes (in which case @cur is freed)
  * If the new node is ATTRIBUTE, it is added into properties instead of children.
- * If there is an attribute with equal name, it is first destroyed. 
+ * If there is an attribute with equal name, it is first destroyed.
  *
  * Returns the child or NULL in case of error.
  */
@@ -3622,7 +3622,7 @@
  *		Copy operations						*
  *									*
  ************************************************************************/
- 
+
 /**
  * xmlCopyNamespace:
  * @cur:  the namespace
@@ -3739,7 +3739,7 @@
           ret->ns = xmlNewReconciliedNs(target->doc, target, cur->ns);
         }
       }
- 
+
     } else
         ret->ns = NULL;
 
@@ -3860,7 +3860,7 @@
 		return((xmlNodePtr) xmlCopyPropInternal(doc, parent, (xmlAttrPtr) node));
         case XML_NAMESPACE_DECL:
 	    return((xmlNodePtr) xmlCopyNamespaceList((xmlNsPtr) node));
-	    
+
         case XML_DOCUMENT_NODE:
         case XML_HTML_DOCUMENT_NODE:
 #ifdef LIBXML_DOCB_ENABLED
@@ -3890,7 +3890,7 @@
     ret->type = node->type;
 
     ret->doc = doc;
-    ret->parent = parent; 
+    ret->parent = parent;
     if (node->name == xmlStringText)
 	ret->name = xmlStringText;
     else if (node->name == xmlStringTextNoenc)
@@ -3929,7 +3929,7 @@
 	if (tmp != ret)
 	    return(tmp);
     }
-    
+
     if (!extended)
 	goto out;
     if ((node->type == XML_ELEMENT_NODE) && (node->nsDef != NULL))
@@ -4125,7 +4125,7 @@
     if (dtd->pentities != NULL)
 	ret->pentities = (void *) xmlCopyEntitiesTable(
 			    (xmlEntitiesTablePtr) dtd->pentities);
-    
+
     cur = dtd->children;
     while (cur != NULL) {
 	q = NULL;
@@ -4140,7 +4140,7 @@
 		    break;
 		case XML_INTERNAL_PARAMETER_ENTITY:
 		case XML_EXTERNAL_PARAMETER_ENTITY:
-    		    q = (xmlNodePtr) 
+		    q = (xmlNodePtr)
 			xmlGetParameterEntityFromDtd(ret, tmp->name);
 		    break;
 		case XML_INTERNAL_PREDEFINED_ENTITY:
@@ -4152,27 +4152,27 @@
 		xmlGetDtdQElementDesc(ret, tmp->name, tmp->prefix);
 	} else if (cur->type == XML_ATTRIBUTE_DECL) {
 	    xmlAttributePtr tmp = (xmlAttributePtr) cur;
-	    q = (xmlNodePtr) 
+	    q = (xmlNodePtr)
 		xmlGetDtdQAttrDesc(ret, tmp->elem, tmp->name, tmp->prefix);
 	} else if (cur->type == XML_COMMENT_NODE) {
 	    q = xmlCopyNode(cur, 0);
 	}
-	
+
 	if (q == NULL) {
 	    cur = cur->next;
 	    continue;
 	}
-	
+
 	if (p == NULL)
 	    ret->children = q;
 	else
-    	    p->next = q;
-	
-    	q->prev = p;
-    	q->parent = (xmlNodePtr) ret;
+	    p->next = q;
+
+	q->prev = p;
+	q->parent = (xmlNodePtr) ret;
 	q->next = NULL;
 	ret->last = q;
-    	p = q;
+	p = q;
 	cur = cur->next;
     }
 
@@ -4222,7 +4222,7 @@
         ret->oldNs = xmlCopyNamespaceList(doc->oldNs);
     if (doc->children != NULL) {
 	xmlNodePtr tmp;
-	
+
 	ret->children = xmlStaticCopyNodeList(doc->children, ret,
 		                               (xmlNodePtr)ret);
 	ret->last = NULL;
@@ -4242,7 +4242,7 @@
  *		Content access functions				*
  *									*
  ************************************************************************/
- 
+
 /**
  * xmlGetLineNo:
  * @node: valid node
@@ -4334,7 +4334,7 @@
             if (cur->ns) {
 		if (cur->ns->prefix != NULL) {
                     snprintf(nametemp, sizeof(nametemp) - 1, "%s:%s",
-		    	(char *)cur->ns->prefix, (char *)cur->name);
+			(char *)cur->ns->prefix, (char *)cur->name);
 		    nametemp[sizeof(nametemp) - 1] = 0;
 		    name = nametemp;
 		} else {
@@ -4344,7 +4344,7 @@
 		    */
 		    generic = 1;
 		    name = "*";
-		}                
+		}
             }
             next = cur->parent;
 
@@ -4432,7 +4432,7 @@
 		    {
 			occur = 1;
 			break;
-		    }			
+		    }
 		    tmp = tmp->next;
 		}
             } else
@@ -4475,10 +4475,10 @@
             if (cur->ns) {
 	        if (cur->ns->prefix != NULL)
                     snprintf(nametemp, sizeof(nametemp) - 1, "%s:%s",
-		    	(char *)cur->ns->prefix, (char *)cur->name);
+			(char *)cur->ns->prefix, (char *)cur->name);
 		else
 		    snprintf(nametemp, sizeof(nametemp) - 1, "%s",
-		    	(char *)cur->name);
+			(char *)cur->name);
                 nametemp[sizeof(nametemp) - 1] = 0;
                 name = nametemp;
             }
@@ -4546,7 +4546,7 @@
     }
     return(ret);
 }
- 
+
 #if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_WRITER_ENABLED)
 /**
  * xmlDocSetRootElement:
@@ -4588,7 +4588,7 @@
     return(old);
 }
 #endif
- 
+
 #if defined(LIBXML_TREE_ENABLED)
 /**
  * xmlNodeSetLang:
@@ -4636,7 +4636,7 @@
     xmlSetNsProp(cur, ns, BAD_CAST "lang", lang);
 }
 #endif /* LIBXML_TREE_ENABLED */
- 
+
 /**
  * xmlNodeGetLang:
  * @cur:  the node being checked
@@ -4659,7 +4659,7 @@
     }
     return(NULL);
 }
- 
+
 
 #ifdef LIBXML_TREE_ENABLED
 /**
@@ -4747,7 +4747,7 @@
     }
     return(-1);
 }
- 
+
 #ifdef LIBXML_TREE_ENABLED
 /**
  * xmlNodeSetName:
@@ -4805,7 +4805,7 @@
     }
 }
 #endif
- 
+
 #if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XINCLUDE_ENABLED)
 /**
  * xmlNodeSetBase:
@@ -4858,7 +4858,7 @@
 	    return;
 	}
     }
-    
+
     ns = xmlSearchNsByHref(cur->doc, cur, XML_XML_NAMESPACE);
     if (ns == NULL)
 	return;
@@ -4894,9 +4894,9 @@
     xmlChar *oldbase = NULL;
     xmlChar *base, *newbase;
 
-    if ((cur == NULL) && (doc == NULL)) 
+    if ((cur == NULL) && (doc == NULL))
         return(NULL);
-    if (doc == NULL) doc = cur->doc;	
+    if (doc == NULL) doc = cur->doc;
     if ((doc != NULL) && (doc->type == XML_HTML_DOCUMENT_NODE)) {
         cur = doc->children;
 	while ((cur != NULL) && (cur->name != NULL)) {
@@ -4958,7 +4958,7 @@
     }
     return(oldbase);
 }
- 
+
 /**
  * xmlNodeBufGetContent:
  * @buffer:  a buffer
@@ -4969,7 +4969,7 @@
  * of the values carried by this node child's (TEXT and ENTITY_REF).
  * Entity references are substituted.
  * Fills up the buffer @buffer with this value
- * 
+ *
  * Returns 0 in case of success and -1 in case of error.
  */
 int
@@ -5248,12 +5248,12 @@
 	        if (!((cur->doc != NULL) && (cur->doc->dict != NULL) &&
 		    (xmlDictOwns(cur->doc->dict, cur->content))))
 		    xmlFree(cur->content);
-	    }	
+	    }
 	    if (cur->children != NULL) xmlFreeNodeList(cur->children);
 	    cur->last = cur->children = NULL;
 	    if (content != NULL) {
 		cur->content = xmlStrdup(content);
-	    } else 
+	    } else
 		cur->content = NULL;
 	    cur->properties = NULL;
 	    cur->nsDef = NULL;
@@ -5326,12 +5326,12 @@
 	        if (!((cur->doc != NULL) && (cur->doc->dict != NULL) &&
 		    (xmlDictOwns(cur->doc->dict, cur->content))))
 		    xmlFree(cur->content);
-	    }	
+	    }
 	    if (cur->children != NULL) xmlFreeNodeList(cur->children);
 	    cur->children = cur->last = NULL;
 	    if (content != NULL) {
 		cur->content = xmlStrndup(content, len);
-	    } else 
+	    } else
 		cur->content = NULL;
 	    cur->properties = NULL;
 	    cur->nsDef = NULL;
@@ -5365,7 +5365,7 @@
  * @cur:  the node being modified
  * @content:  extra content
  * @len:  the size of @content
- * 
+ *
  * Append the extra substring to the node content.
  * NOTE: In contrast to xmlNodeSetContentLen(), @content is supposed to be
  *       raw text, so unescaped XML special chars are allowed, entity
@@ -5440,7 +5440,7 @@
  * xmlNodeAddContent:
  * @cur:  the node being modified
  * @content:  extra content
- * 
+ *
  * Append the extra substring to the node content.
  * NOTE: In contrast to xmlNodeSetContent(), @content is supposed to be
  *       raw text, so unescaped XML special chars are allowed, entity
@@ -5466,7 +5466,7 @@
  * xmlTextMerge:
  * @first:  the first text node
  * @second:  the second text node being merged
- * 
+ *
  * Merge two text nodes into one
  * Returns the first text node augmented
  */
@@ -5551,9 +5551,9 @@
 /*
 * xmlTreeEnsureXMLDecl:
 * @doc: the doc
-* 
+*
 * Ensures that there is an XML namespace declaration on the doc.
-* 
+*
 * Returns the XML ns-struct or NULL on API and internal errors.
 */
 static xmlNsPtr
@@ -5573,7 +5573,7 @@
 	}
 	memset(ns, 0, sizeof(xmlNs));
 	ns->type = XML_LOCAL_NAMESPACE;
-	ns->href = xmlStrdup(XML_XML_NAMESPACE); 
+	ns->href = xmlStrdup(XML_XML_NAMESPACE);
 	ns->prefix = xmlStrdup((const xmlChar *)"xml");
 	doc->oldNs = ns;
 	return (ns);
@@ -5598,7 +5598,7 @@
  */
 xmlNsPtr
 xmlSearchNs(xmlDocPtr doc, xmlNodePtr node, const xmlChar *nameSpace) {
-	
+
     xmlNsPtr cur;
     xmlNodePtr orig = node;
 
@@ -5618,8 +5618,8 @@
 	    }
 	    memset(cur, 0, sizeof(xmlNs));
 	    cur->type = XML_LOCAL_NAMESPACE;
-	    cur->href = xmlStrdup(XML_XML_NAMESPACE); 
-	    cur->prefix = xmlStrdup((const xmlChar *)"xml"); 
+	    cur->href = xmlStrdup(XML_XML_NAMESPACE);
+	    cur->prefix = xmlStrdup((const xmlChar *)"xml");
 	    cur->next = node->nsDef;
 	    node->nsDef = cur;
 	    return(cur);
@@ -5654,7 +5654,7 @@
 		    return(cur);
 		cur = cur->next;
 	    }
-	    if (orig != node) { 
+	    if (orig != node) {
 	        cur = node->ns;
 	        if (cur != NULL) {
 		    if ((cur->prefix == NULL) && (nameSpace == NULL) &&
@@ -5665,7 +5665,7 @@
 		        (xmlStrEqual(cur->prefix, nameSpace)))
 		        return(cur);
 	        }
-	    }    
+	    }
 	}
 	node = node->parent;
     }
@@ -5681,7 +5681,7 @@
  *
  * Verify that the given namespace held on @ancestor is still in scope
  * on node.
- * 
+ *
  * Returns 1 if true, 0 if false and -1 in case of error.
  */
 static int
@@ -5714,7 +5714,7 @@
         return (-1);
     return (1);
 }
-                  
+
 /**
  * xmlSearchNsByHref:
  * @doc:  the document
@@ -5768,7 +5768,7 @@
 	if (doc->oldNs == NULL)
 	    return(xmlTreeEnsureXMLDecl(doc));
 	else
-	    return(doc->oldNs);        
+	    return(doc->oldNs);
     }
     is_attr = (node->type == XML_ATTRIBUTE_NODE);
     while (node != NULL) {
@@ -5797,7 +5797,7 @@
 			    return (cur);
                     }
                 }
-            }    
+            }
         }
         node = node->parent;
     }
@@ -5860,7 +5860,7 @@
 	    snprintf((char *) prefix, sizeof(prefix), "default%d", counter++);
 	else
 	    snprintf((char *) prefix, sizeof(prefix), "%.20s%d",
-	    	(char *)ns->prefix, counter++);
+		(char *)ns->prefix, counter++);
 	def = xmlSearchNs(doc, tree, prefix);
     }
 
@@ -6055,7 +6055,7 @@
 		}
 	    }
 	    /* exit condition */
-	    if (node == tree) 
+	    if (node == tree)
 	        node = NULL;
 	} else
 	    break;
@@ -6111,14 +6111,14 @@
     /*
      * Check if there is a default/fixed attribute declaration in
      * the internal or external subset.
-     */    
+     */
     if ((node->doc != NULL) && (node->doc->intSubset != NULL)) {
 	xmlDocPtr doc = node->doc;
 	xmlAttributePtr attrDecl = NULL;
 	xmlChar *elemQName, *tmpstr = NULL;
 
 	/*
-	* We need the QName of the element for the DTD-lookup.	
+	* We need the QName of the element for the DTD-lookup.
 	*/
 	if ((node->ns != NULL) && (node->ns->prefix != NULL)) {
 	    tmpstr = xmlStrdup(node->ns->prefix);
@@ -6169,7 +6169,7 @@
 		cur++;
 	    }
 	    xmlFree(nsList);
-	}	
+	}
 	if (tmpstr != NULL)
 	    xmlFree(tmpstr);
 	/*
@@ -6213,7 +6213,7 @@
     } else if (prop->type == XML_ATTRIBUTE_DECL) {
 	return(xmlStrdup(((xmlAttributePtr)prop)->defaultValue));
     }
-    return(NULL); 
+    return(NULL);
 }
 
 /**
@@ -6225,7 +6225,7 @@
  * This function also looks in DTD attribute declaration for #FIXED or
  * default declaration values unless DTD use has been turned off.
  *
- * Returns the attribute or the attribute declaration or NULL if 
+ * Returns the attribute or the attribute declaration or NULL if
  *         neither was found.
  */
 xmlAttrPtr
@@ -6307,12 +6307,12 @@
  */
 xmlChar *
 xmlGetProp(xmlNodePtr node, const xmlChar *name) {
-    xmlAttrPtr prop;    
+    xmlAttrPtr prop;
 
     prop = xmlHasProp(node, name);
     if (prop == NULL)
 	return(NULL);
-    return(xmlGetPropNodeValueInternal(prop));     
+    return(xmlGetPropNodeValueInternal(prop));
 }
 
 /**
@@ -6333,7 +6333,7 @@
 xmlChar *
 xmlGetNoNsProp(xmlNodePtr node, const xmlChar *name) {
     xmlAttrPtr prop;
-    
+
     prop = xmlGetPropNodeInternal(node, name, NULL, xmlCheckDTD);
     if (prop == NULL)
 	return(NULL);
@@ -6399,7 +6399,7 @@
 int
 xmlUnsetNsProp(xmlNodePtr node, xmlNsPtr ns, const xmlChar *name) {
     xmlAttrPtr prop;
-    
+
     prop = xmlGetPropNodeInternal(node, name, (ns != NULL) ? ns->href : NULL, 0);
     if (prop == NULL)
 	return(-1);
@@ -6422,7 +6422,7 @@
  * error it there's no such ns-binding for the prefix in
  * scope.
  * Returns the attribute pointer.
- * 
+ *
  */
 xmlAttrPtr
 xmlSetProp(xmlNodePtr node, const xmlChar *name, const xmlChar *value) {
@@ -6465,7 +6465,7 @@
 	     const xmlChar *value)
 {
     xmlAttrPtr prop;
-    
+
     if (ns && (ns->href == NULL))
 	return(NULL);
     prop = xmlGetPropNodeInternal(node, name, (ns != NULL) ? ns->href : NULL, 0);
@@ -6477,14 +6477,14 @@
 	    xmlRemoveID(node->doc, prop);
 	    prop->atype = XML_ATTRIBUTE_ID;
 	}
-	if (prop->children != NULL) 
+	if (prop->children != NULL)
 	    xmlFreeNodeList(prop->children);
 	prop->children = NULL;
 	prop->last = NULL;
 	prop->ns = ns;
 	if (value != NULL) {
 	    xmlNodePtr tmp;
-	    
+
 	    if(!xmlCheckUTF8(value)) {
 	        xmlTreeErr(XML_TREE_NOT_UTF8, (xmlNodePtr) node->doc,
 	                   NULL);
@@ -6516,7 +6516,7 @@
 /**
  * xmlNodeIsText:
  * @node:  the node
- * 
+ *
  * Is this node a Text node ?
  * Returns 1 yes, 0 no
  */
@@ -6531,7 +6531,7 @@
 /**
  * xmlIsBlankNode:
  * @node:  the node
- * 
+ *
  * Checks whether this node is an empty or whitespace only
  * (and possibly ignorable) text-node.
  *
@@ -6560,7 +6560,7 @@
  * @node:  the node
  * @content:  the content
  * @len:  @content length
- * 
+ *
  * Concat the given string at the end of the existing node content
  *
  * Returns -1 in case of error, 0 otherwise
@@ -6698,7 +6698,7 @@
  * Sets the allocation scheme for this buffer
  */
 void
-xmlBufferSetAllocationScheme(xmlBufferPtr buf, 
+xmlBufferSetAllocationScheme(xmlBufferPtr buf,
                              xmlBufferAllocationScheme scheme) {
     if (buf == NULL) {
 #ifdef DEBUG_BUFFER
@@ -6873,7 +6873,7 @@
 
 /**
  * xmlBufferLength:
- * @buf:  the buffer 
+ * @buf:  the buffer
  *
  * Function to get the length of a buffer
  *
@@ -6931,7 +6931,7 @@
     if (buf->content == NULL)
 	rebuf = (xmlChar *) xmlMallocAtomic(newSize * sizeof(xmlChar));
     else if (buf->size - buf->use < 100) {
-	rebuf = (xmlChar *) xmlRealloc(buf->content, 
+	rebuf = (xmlChar *) xmlRealloc(buf->content,
 				       newSize * sizeof(xmlChar));
    } else {
         /*
@@ -7301,7 +7301,7 @@
 /*
 * xmlDOMWrapNsMapFree:
 * @map: the ns-map
-* 
+*
 * Frees the ns-map
 */
 static void
@@ -7332,7 +7332,7 @@
 * @oldNs: the old ns-struct
 * @newNs: the new ns-struct
 * @depth: depth and ns-kind information
-* 
+*
 * Adds an ns-mapping item.
 */
 static xmlNsMapItemPtr
@@ -7360,7 +7360,7 @@
 	memset(map, 0, sizeof(struct xmlNsMap));
 	*nsmap = map;
     }
-    
+
     if (map->pool != NULL) {
 	/*
 	* Reuse an item from the pool.
@@ -7379,11 +7379,11 @@
 	}
 	memset(ret, 0, sizeof(struct xmlNsMapItem));
     }
-    
+
     if (map->first == NULL) {
 	/*
 	* First ever.
-	*/	 
+	*/
 	map->first = ret;
 	map->last = ret;
     } else if (position == -1) {
@@ -7392,14 +7392,14 @@
 	*/
 	ret->prev = map->last;
 	map->last->next = ret;
-	map->last = ret;		
+	map->last = ret;
     } else if (position == 0) {
 	/*
 	* Set on first position.
 	*/
 	map->first->prev = ret;
-	ret->next = map->first;		
-	map->first = ret;		
+	ret->next = map->first;
+	map->first = ret;
     } else
 	return(NULL);
 
@@ -7415,10 +7415,10 @@
 * @doc: the doc
 * @nsName: the namespace name
 * @prefix: the prefix
-* 
+*
 * Creates or reuses an xmlNs struct on doc->oldNs with
 * the given prefix and namespace name.
-* 
+*
 * Returns the aquired ns struct or NULL in case of an API
 *         or internal error.
 */
@@ -7458,7 +7458,7 @@
 *
 * Allocates and initializes a new DOM-wrapper context.
 *
-* Returns the xmlDOMWrapCtxtPtr or NULL in case of an internal errror. 
+* Returns the xmlDOMWrapCtxtPtr or NULL in case of an internal errror.
 */
 xmlDOMWrapCtxtPtr
 xmlDOMWrapNewCtxt(void)
@@ -7497,9 +7497,9 @@
 * xmlTreeLookupNsListByPrefix:
 * @nsList: a list of ns-structs
 * @prefix: the searched prefix
-* 
+*
 * Searches for a ns-decl with the given prefix in @nsList.
-* 
+*
 * Returns the ns-decl if found, NULL if not found and on
 *         API errors.
 */
@@ -7527,9 +7527,9 @@
 * xmlDOMWrapNSNormGatherInScopeNs:
 * @map: the namespace map
 * @node: the node to start with
-* 
+*
 * Puts in-scope namespaces into the ns-map.
-* 
+*
 * Returns 0 on success, -1 on API or internal errors.
 */
 static int
@@ -7621,7 +7621,7 @@
 *
 * For internal use. Adds a ns-decl mapping.
 *
-* Returns 0 on success, -1 on internal errors. 
+* Returns 0 on success, -1 on internal errors.
 */
 static int
 xmlDOMWrapNSNormAddNsMapItem2(xmlNsPtr **list, int *size, int *number,
@@ -7665,7 +7665,7 @@
 * NOTE: This function was not intensively tested.
 *
 * Returns 0 on success, 1 if the node is not supported,
-*         -1 on API and internal errors. 
+*         -1 on API and internal errors.
 */
 int
 xmlDOMWrapRemoveNode(xmlDOMWrapCtxtPtr ctxt, xmlDocPtr doc,
@@ -7682,7 +7682,7 @@
     if (node->parent == NULL)
 	return (0);
 
-    switch (node->type) {    	
+    switch (node->type) {
 	case XML_TEXT_NODE:
 	case XML_CDATA_SECTION_NODE:
 	case XML_ENTITY_REF_NODE:
@@ -7690,7 +7690,7 @@
 	case XML_COMMENT_NODE:
 	    xmlUnlinkNode(node);
 	    return (0);
-	case XML_ELEMENT_NODE:	    
+	case XML_ELEMENT_NODE:
 	case XML_ATTRIBUTE_NODE:
 	    break;
 	default:
@@ -7714,7 +7714,7 @@
 		}
 		/* No break on purpose. */
 	    case XML_ATTRIBUTE_NODE:
-		if (node->ns != NULL) {		    
+		if (node->ns != NULL) {
 		    /*
 		    * Find a mapping.
 		    */
@@ -7758,14 +7758,14 @@
 		break;
 	    default:
 		goto next_sibling;
-	}	
-next_node:	 
+	}
+next_node:
 	if ((node->type == XML_ELEMENT_NODE) &&
 	    (node->children != NULL)) {
 	    node = node->children;
 	    continue;
 	}
-next_sibling:	
+next_sibling:
 	if (node == NULL)
 	    break;
 	if (node->next != NULL)
@@ -7858,7 +7858,7 @@
 			*/
 			if (out) {
 			    int ret;
-			    
+
 			    ret = xmlNsInScope(doc, node, prev, ns->prefix);
 			    if (ret < 0)
 				return (-1);
@@ -7926,7 +7926,7 @@
 	if (cur->type == XML_ELEMENT_NODE) {
 	    if (cur->nsDef != NULL) {
 		ns = cur->nsDef;
-		do {		
+		do {
 		    if ((prefix == ns->prefix) ||
 			xmlStrEqual(prefix, ns->prefix))
 		    {
@@ -7940,7 +7940,7 @@
 			return (1);
 		    }
 		    ns = ns->next;
-		} while (ns != NULL);	
+		} while (ns != NULL);
 	    }
 	} else if ((cur->type == XML_ENTITY_NODE) ||
             (cur->type == XML_ENTITY_DECL))
@@ -8047,12 +8047,12 @@
 				   xmlNsPtr ns,
 				   xmlNsPtr *retNs,
 				   xmlNsMapPtr *nsMap,
-				   
+
 				   int depth,
 				   int ancestorsOnly,
 				   int prefixed)
 {
-    xmlNsMapItemPtr mi;    
+    xmlNsMapItemPtr mi;
 
     if ((doc == NULL) || (ns == NULL) || (retNs == NULL) ||
 	(nsMap == NULL))
@@ -8077,13 +8077,13 @@
     */
     if ((XML_NSMAP_NOTEMPTY(*nsMap)) &&
 	(! (ancestorsOnly && (elem == NULL))))
-    {	
+    {
 	/*
 	* Try to find an equal ns-name in in-scope ns-decls.
 	*/
 	XML_NSMAP_FOREACH(*nsMap, mi) {
-	    if ((mi->depth >= XML_TREE_NSMAP_PARENT) && 				
-		/* 
+	    if ((mi->depth >= XML_TREE_NSMAP_PARENT) &&
+		/*
 		* ancestorsOnly: This should be turned on to gain speed,
 		* if one knows that the branch itself was already
 		* ns-wellformed and no stale references existed.
@@ -8091,10 +8091,10 @@
 		*/
 		((! ancestorsOnly) || (mi->depth == XML_TREE_NSMAP_PARENT)) &&
 		/* Skip shadowed prefixes. */
-		(mi->shadowDepth == -1) &&		
+		(mi->shadowDepth == -1) &&
 		/* Skip xmlns="" or xmlns:foo="". */
 		((mi->newNs->href != NULL) &&
-		(mi->newNs->href[0] != 0)) &&		
+		(mi->newNs->href[0] != 0)) &&
 		/* Ensure a prefix if wanted. */
 		((! prefixed) || (mi->newNs->prefix != NULL)) &&
 		/* Equal ns name */
@@ -8121,7 +8121,7 @@
 	    return (-1);
 	/*
 	* Insert mapping.
-	*/	
+	*/
 	if (xmlDOMWrapNsMapAddItem(nsMap, -1, ns,
 		tmpns, XML_TREE_NSMAP_DOC) == NULL) {
 	    xmlFreeNs(tmpns);
@@ -8163,7 +8163,7 @@
 }
 
 typedef enum {
-    XML_DOM_RECONNS_REMOVEREDUND = 1<<0    
+    XML_DOM_RECONNS_REMOVEREDUND = 1<<0
 } xmlDOMReconcileNSOptions;
 
 /*
@@ -8181,7 +8181,7 @@
 * NOTE: This function was not intensively tested.
 *
 * Returns 0 if succeeded, -1 otherwise and on API/internal errors.
-*/   
+*/
 
 int
 xmlDOMWrapReconcileNamespaces(xmlDOMWrapCtxtPtr ctxt ATTRIBUTE_UNUSED,
@@ -8196,7 +8196,7 @@
     xmlNsMapItemPtr /* topmi = NULL, */ mi;
     /* @ancestorsOnly should be set by an option flag. */
     int ancestorsOnly = 0;
-    int optRemoveRedundantNS = 
+    int optRemoveRedundantNS =
 	((xmlDOMReconcileNSOptions) options & XML_DOM_RECONNS_REMOVEREDUND) ? 1 : 0;
     xmlNsPtr *listRedund = NULL;
     int sizeRedund = 0, nbRedund = 0, ret, i, j;
@@ -8232,7 +8232,7 @@
 			    }
 			    parnsdone = 1;
 			}
-			
+
 			/*
 			* Lookup the ns ancestor-axis for equal ns-decls in scope.
 			*/
@@ -8244,7 +8244,7 @@
 				      xmlStrEqual(ns->prefix, mi->newNs->prefix)) &&
 				    ((ns->href == mi->newNs->href) ||
 				      xmlStrEqual(ns->href, mi->newNs->href)))
-				{				    
+				{
 				    /*
 				    * A redundant ns-decl was found.
 				    * Add it to the list of redundant ns-decls.
@@ -8254,11 +8254,11 @@
 					goto internal_error;
 				    /*
 				    * Remove the ns-decl from the element-node.
-				    */				    
+				    */
 				    if (prevns)
 					prevns->next = ns->next;
 				    else
-					cur->nsDef = ns->next;				    				    
+					cur->nsDef = ns->next;
 				    goto next_ns_decl;
 				}
 			    }
@@ -8269,7 +8269,7 @@
 			* ns-decl is declared on the same element.
 			*/
 			if ((cur->ns != NULL) && adoptns && (cur->ns == ns))
-			    adoptns = 0;						
+			    adoptns = 0;
 			/*
 			* Does it shadow any ns-decl?
 			*/
@@ -8279,7 +8279,7 @@
 				    (mi->shadowDepth == -1) &&
 				    ((ns->prefix == mi->newNs->prefix) ||
 				    xmlStrEqual(ns->prefix, mi->newNs->prefix))) {
-				    
+
 				    mi->shadowDepth = depth;
 				}
 			    }
@@ -8289,11 +8289,11 @@
 			*/
 			if (xmlDOMWrapNsMapAddItem(&nsMap, -1, ns, ns,
 			    depth) == NULL)
-			    goto internal_error;			
+			    goto internal_error;
 
 			prevns = ns;
 next_ns_decl:
-			ns = ns->next;			
+			ns = ns->next;
 		    }
 		}
 		if (! adoptns)
@@ -8303,7 +8303,7 @@
 		/* No ns, no fun. */
 		if (cur->ns == NULL)
 		    goto ns_end;
-		
+
 		if (! parnsdone) {
 		    if ((elem->parent) &&
 			((xmlNodePtr) elem->parent->doc != elem->parent)) {
@@ -8322,7 +8322,7 @@
 			   cur->ns = listRedund[++j];
 			   break;
 		       }
-		   } 
+		   }
 		}
 		/*
 		* Adopt ns-references.
@@ -8360,7 +8360,7 @@
 		    cur = (xmlNodePtr) cur->properties;
 		    continue;
 		}
-		break;		
+		break;
 	    default:
 		goto next_sibling;
 	}
@@ -8373,18 +8373,18 @@
 	    cur = cur->children;
 	    continue;
 	}
-next_sibling:	
+next_sibling:
 	if (cur == elem)
 	    break;
 	if (cur->type == XML_ELEMENT_NODE) {
-	    if (XML_NSMAP_NOTEMPTY(nsMap)) {	    
+	    if (XML_NSMAP_NOTEMPTY(nsMap)) {
 		/*
 		* Pop mappings.
 		*/
 		while ((nsMap->last != NULL) &&
 		    (nsMap->last->depth >= depth))
 		{
-		    XML_NSMAP_POP(nsMap, mi)		    
+		    XML_NSMAP_POP(nsMap, mi)
 		}
 		/*
 		* Unshadow.
@@ -8393,7 +8393,7 @@
 		    if (mi->shadowDepth >= depth)
 			mi->shadowDepth = -1;
 		}
-	    }	    
+	    }
 	    depth--;
 	}
 	if (cur->next != NULL)
@@ -8407,13 +8407,13 @@
 	    goto next_sibling;
 	}
     } while (cur != NULL);
-    
+
     ret = 0;
     goto exit;
 internal_error:
     ret = -1;
 exit:
-    if (listRedund) {	
+    if (listRedund) {
 	for (i = 0, j = 0; i < nbRedund; i++, j += 2) {
 	    xmlFreeNs(listRedund[j]);
 	}
@@ -8464,7 +8464,7 @@
     int parnsdone;
     /* @ancestorsOnly should be set per option. */
     int ancestorsOnly = 0;
-    
+
     /*
     * Optimize string adoption for equal or none dicts.
     */
@@ -8518,17 +8518,17 @@
 	}
 	cur->doc = destDoc;
 	switch (cur->type) {
-	    case XML_XINCLUDE_START:		
+	    case XML_XINCLUDE_START:
 	    case XML_XINCLUDE_END:
 		/*
 		* TODO
 		*/
 		return (-1);
-	    case XML_ELEMENT_NODE:   	
+	    case XML_ELEMENT_NODE:
 		curElem = cur;
 		depth++;
 		/*
-		* Namespace declarations.		
+		* Namespace declarations.
 		* - ns->href and ns->prefix are never in the dict, so
 		*   we need not move the values over to the destination dict.
 		* - Note that for custom handling of ns-references,
@@ -8552,10 +8552,10 @@
 			* NOTE: ns->prefix and ns->href are never in the dict.
 			* XML_TREE_ADOPT_STR(ns->prefix)
 			* XML_TREE_ADOPT_STR(ns->href)
-			*/			
+			*/
 			/*
 			* Does it shadow any ns-decl?
-			*/			
+			*/
 			if (XML_NSMAP_NOTEMPTY(nsMap)) {
 			    XML_NSMAP_FOREACH(nsMap, mi) {
 				if ((mi->depth >= XML_TREE_NSMAP_PARENT) &&
@@ -8563,7 +8563,7 @@
 				    ((ns->prefix == mi->newNs->prefix) ||
 				    xmlStrEqual(ns->prefix,
 				    mi->newNs->prefix))) {
-				    
+
 				    mi->shadowDepth = depth;
 				}
 			    }
@@ -8626,7 +8626,7 @@
 		    * Aquire a normalized ns-decl and add it to the map.
 		    */
 		    if (xmlDOMWrapNSNormAquireNormalizedNs(destDoc,
-			/* ns-decls on curElem or on destDoc->oldNs */			
+			/* ns-decls on curElem or on destDoc->oldNs */
 			destParent ? curElem : NULL,
 			cur->ns, &ns,
 			&nsMap, depth,
@@ -8662,7 +8662,7 @@
 		    */
 		    if ((sourceDoc != NULL) &&
 			(((xmlAttrPtr) cur)->atype == XML_ATTRIBUTE_ID))
-		    {			
+		    {
 			xmlRemoveID(sourceDoc, (xmlAttrPtr) cur);
 		    }
 		    ((xmlAttrPtr) cur)->atype = 0;
@@ -8670,13 +8670,13 @@
 		}
 		break;
 	    case XML_TEXT_NODE:
-	    case XML_CDATA_SECTION_NODE:		
+	    case XML_CDATA_SECTION_NODE:
 		/*
 		* This puts the content in the dest dict, only if
 		* it was previously in the source dict.
 		*/
-		XML_TREE_ADOPT_STR_2(cur->content)		
-		goto leave_node;	   
+		XML_TREE_ADOPT_STR_2(cur->content)
+		goto leave_node;
 	    case XML_ENTITY_REF_NODE:
 		/*
 		* Remove reference to the entitity-node.
@@ -8701,7 +8701,7 @@
 		XML_TREE_ADOPT_STR(cur->name)
 		XML_TREE_ADOPT_STR_2(cur->content)
 		break;
-	    case XML_COMMENT_NODE:	    
+	    case XML_COMMENT_NODE:
 		break;
 	    default:
 		goto internal_error;
@@ -8724,15 +8724,15 @@
 	    /*
 	    * TODO: Do we expect nsDefs on XML_XINCLUDE_START?
 	    */
-	    if (XML_NSMAP_NOTEMPTY(nsMap)) {	    
+	    if (XML_NSMAP_NOTEMPTY(nsMap)) {
 		/*
 		* Pop mappings.
 		*/
 		while ((nsMap->last != NULL) &&
 		    (nsMap->last->depth >= depth))
 		{
-		    XML_NSMAP_POP(nsMap, mi)		    
-		}		
+		    XML_NSMAP_POP(nsMap, mi)
+		}
 		/*
 		* Unshadow.
 		*/
@@ -8754,10 +8754,10 @@
 	    goto leave_node;
 	}
     }
-    
+
     goto exit;
 
-internal_error:    
+internal_error:
     ret = -1;
 
 exit:
@@ -8775,7 +8775,7 @@
 		nsMap->pool = nsMap->first;
 		nsMap->first = NULL;
 	    }
-	} else    
+	} else
 	    xmlDOMWrapNsMapFree(nsMap);
     }
     return(ret);
@@ -8797,7 +8797,7 @@
 * 2) If *no* @destParent is given, then @destDoc->oldNs entries are used.
 *    This is the case when you don't know already where the cloned branch
 *    will be added to.
-* 
+*
 * If @destParent is given, it ensures that the tree is namespace
 * wellformed by creating additional ns-decls where needed.
 * Note that, since prefixes of already existent ns-decls can be
@@ -8831,7 +8831,7 @@
     /* gather @parent's ns-decls. */
     int parnsdone = 0;
     /*
-    * @ancestorsOnly: 
+    * @ancestorsOnly:
     * TODO: @ancestorsOnly should be set per option.
     *
     */
@@ -8858,7 +8858,7 @@
 	return (-1);
     }
     if (sourceDoc == NULL)
-	sourceDoc = node->doc;    
+	sourceDoc = node->doc;
     if (sourceDoc == NULL)
         return (-1);
 
@@ -8870,7 +8870,7 @@
 	nsMap = (xmlNsMapPtr) ctxt->namespaceMap;
 
     *resNode = NULL;
-   
+
     cur = node;
     while (cur != NULL) {
 	if (cur->doc != sourceDoc) {
@@ -8879,7 +8879,7 @@
 	    * TODO: Do we need to reconciliate XIncluded nodes?
 	    * TODO: This here returns -1 in this case.
 	    */
-	    goto internal_error;	
+	    goto internal_error;
 	}
 	/*
 	* Create a new node.
@@ -8894,9 +8894,9 @@
 		break;
 	    case XML_ELEMENT_NODE:
 	    case XML_TEXT_NODE:
-	    case XML_CDATA_SECTION_NODE:	    
+	    case XML_CDATA_SECTION_NODE:
 	    case XML_COMMENT_NODE:
-	    case XML_PI_NODE:	    
+	    case XML_PI_NODE:
 	    case XML_DOCUMENT_FRAG_NODE:
 	    case XML_ENTITY_REF_NODE:
 	    case XML_ENTITY_NODE:
@@ -8908,20 +8908,20 @@
 		    xmlTreeErrMemory("xmlDOMWrapCloneNode(): allocating a node");
 		    goto internal_error;
 		}
-		memset(clone, 0, sizeof(xmlNode));		
+		memset(clone, 0, sizeof(xmlNode));
 		/*
 		* Set hierachical links.
 		*/
-		if (resultClone != NULL) {	    
+		if (resultClone != NULL) {
 		    clone->parent = parentClone;
 		    if (prevClone) {
 			prevClone->next = clone;
 			clone->prev = prevClone;
-		    } else 
+		    } else
 			parentClone->children = clone;
 		} else
 		    resultClone = clone;
-		
+
 		break;
 	    case XML_ATTRIBUTE_NODE:
 		/*
@@ -8932,7 +8932,7 @@
 		    xmlTreeErrMemory("xmlDOMWrapCloneNode(): allocating an attr-node");
 		    goto internal_error;
 		}
-		memset(clone, 0, sizeof(xmlAttr));		
+		memset(clone, 0, sizeof(xmlAttr));
 		/*
 		* Set hierachical links.
 		* TODO: Change this to add to the end of attributes.
@@ -8942,7 +8942,7 @@
 		    if (prevClone) {
 			prevClone->next = clone;
 			clone->prev = prevClone;
-		    } else 
+		    } else
 			parentClone->properties = (xmlAttrPtr) clone;
 		} else
 		    resultClone = clone;
@@ -8955,8 +8955,8 @@
 	}
 
 	clone->type = cur->type;
-	clone->doc = destDoc;	
-		
+	clone->doc = destDoc;
+
 	/*
 	* Clone the name of the node if any.
 	*/
@@ -8966,14 +8966,14 @@
 	    /*
 	    * NOTE: Although xmlStringTextNoenc is never assigned to a node
 	    *   in tree.c, it might be set in Libxslt via
-	    *   "xsl:disable-output-escaping".	   
+	    *   "xsl:disable-output-escaping".
 	    */
 	    clone->name = xmlStringTextNoenc;
 	else if (cur->name == xmlStringComment)
 	    clone->name = xmlStringComment;
 	else if (cur->name != NULL) {
 	    DICT_CONST_COPY(cur->name, clone->name);
-	}				    
+	}
 
 	switch (cur->type) {
 	    case XML_XINCLUDE_START:
@@ -8996,7 +8996,7 @@
 			    */
 			    if (xmlDOMWrapNSNormGatherInScopeNs(&nsMap,
 				destParent) == -1)
-				goto internal_error;			    
+				goto internal_error;
 			}
 			parnsdone = 1;
 		    }
@@ -9016,7 +9016,7 @@
 			}
 			memset(cloneNs, 0, sizeof(xmlNs));
 			cloneNs->type = XML_LOCAL_NAMESPACE;
-			
+
 			if (ns->href != NULL)
 			    cloneNs->href = xmlStrdup(ns->href);
 			if (ns->prefix != NULL)
@@ -9037,7 +9037,7 @@
 			    * Does it shadow any ns-decl?
 			    */
 			    if (XML_NSMAP_NOTEMPTY(nsMap)) {
-				XML_NSMAP_FOREACH(nsMap, mi) {				
+				XML_NSMAP_FOREACH(nsMap, mi) {
 				    if ((mi->depth >= XML_TREE_NSMAP_PARENT) &&
 					(mi->shadowDepth == -1) &&
 					((ns->prefix == mi->newNs->prefix) ||
@@ -9062,7 +9062,7 @@
 		}
 		/* cur->ns will be processed further down. */
 		break;
-	    case XML_ATTRIBUTE_NODE:				
+	    case XML_ATTRIBUTE_NODE:
 		/* IDs will be processed further down. */
 		/* cur->ns will be processed further down. */
 		break;
@@ -9071,12 +9071,12 @@
 		/*
 		* Note that this will also cover the values of attributes.
 		*/
-		DICT_COPY(cur->content, clone->content);		
+		DICT_COPY(cur->content, clone->content);
 		goto leave_node;
 	    case XML_ENTITY_NODE:
 		/* TODO: What to do here? */
 		goto leave_node;
-	    case XML_ENTITY_REF_NODE:		
+	    case XML_ENTITY_REF_NODE:
 		if (sourceDoc != destDoc) {
 		    if ((destDoc->intSubset) || (destDoc->extSubset)) {
 			xmlEntityPtr ent;
@@ -9116,13 +9116,13 @@
 /* handle_ns_reference: */
 	/*
 	** The following will take care of references to ns-decls ********
-	** and is intended only for element- and attribute-nodes.	
+	** and is intended only for element- and attribute-nodes.
 	**
 	*/
 	if (! parnsdone) {
 	    if (destParent && (ctxt == NULL)) {
 		if (xmlDOMWrapNSNormGatherInScopeNs(&nsMap, destParent) == -1)
-		    goto internal_error;		
+		    goto internal_error;
 	    }
 	    parnsdone = 1;
 	}
@@ -9133,7 +9133,7 @@
 	    /*
 	    * Search for a mapping.
 	    */
-	    XML_NSMAP_FOREACH(nsMap, mi) {	    
+	    XML_NSMAP_FOREACH(nsMap, mi) {
 		if ((mi->shadowDepth == -1) &&
 		    (cur->ns == mi->oldNs)) {
 		    /*
@@ -9165,7 +9165,7 @@
 	    * Aquire a normalized ns-decl and add it to the map.
 	    */
 	    if (xmlDOMWrapNSNormAquireNormalizedNs(destDoc,
-		/* ns-decls on curElem or on destDoc->oldNs */			
+		/* ns-decls on curElem or on destDoc->oldNs */
 		destParent ? curElem : NULL,
 		cur->ns, &ns,
 		&nsMap, depth,
@@ -9188,9 +9188,9 @@
 	    (clone->parent != NULL))
 	{
 	    if (xmlIsID(destDoc, clone->parent, (xmlAttrPtr) clone)) {
-	   
+
 		xmlChar *idVal;
-		
+
 		idVal = xmlNodeListGetString(cur->doc, cur->children, 1);
 		if (idVal != NULL) {
 		    if (xmlAddID(NULL, destDoc, idVal, (xmlAttrPtr) cur) == NULL) {
@@ -9206,12 +9206,12 @@
 	**
 	** The following will traverse the tree **************************
 	**
-	*	
+	*
 	* Walk the element's attributes before descending into child-nodes.
 	*/
 	if ((cur->type == XML_ELEMENT_NODE) && (cur->properties != NULL)) {
 	    prevClone = NULL;
-	    parentClone = clone;	    
+	    parentClone = clone;
 	    cur = (xmlNodePtr) cur->properties;
 	    continue;
 	}
@@ -9241,14 +9241,14 @@
 	    /*
 	    * TODO: Do we expect nsDefs on XML_XINCLUDE_START?
 	    */
-	    if (XML_NSMAP_NOTEMPTY(nsMap)) {	    
+	    if (XML_NSMAP_NOTEMPTY(nsMap)) {
 		/*
 		* Pop mappings.
 		*/
 		while ((nsMap->last != NULL) &&
 		    (nsMap->last->depth >= depth))
 		{
-		    XML_NSMAP_POP(nsMap, mi)		    
+		    XML_NSMAP_POP(nsMap, mi)
 		}
 		/*
 		* Unshadow.
@@ -9257,7 +9257,7 @@
 		    if (mi->shadowDepth >= depth)
 			mi->shadowDepth = -1;
 		}
-	    }	    
+	    }
 	    depth--;
 	}
 	if (cur->next != NULL) {
@@ -9270,7 +9270,7 @@
 	    if (clone->parent != NULL)
 		clone->parent->last = clone;
 	    clone = clone->parent;
-	    parentClone = clone->parent; 
+	    parentClone = clone->parent;
 	    /*
 	    * Process parent --> next;
 	    */
@@ -9279,14 +9279,14 @@
 	} else {
 	    /* This is for attributes only. */
 	    clone = clone->parent;
-	    parentClone = clone->parent; 
+	    parentClone = clone->parent;
 	    /*
 	    * Process parent-element --> children.
 	    */
 	    cur = cur->parent;
-	    goto into_content;	    
+	    goto into_content;
 	}
-    }        
+    }
     goto exit;
 
 internal_error:
@@ -9307,7 +9307,7 @@
 		nsMap->pool = nsMap->first;
 		nsMap->first = NULL;
 	    }
-	} else    
+	} else
 	    xmlDOMWrapNsMapFree(nsMap);
     }
     /*
@@ -9347,7 +9347,7 @@
 
     if ((attr == NULL) || (destDoc == NULL))
 	return (-1);
-    
+
     attr->doc = destDoc;
     if (attr->ns != NULL) {
 	xmlNsPtr ns = NULL;
@@ -9374,13 +9374,13 @@
 		ns = xmlDOMWrapNSNormDeclareNsForced(destDoc, destParent,
 		    attr->ns->href, attr->ns->prefix, 1);
 	    }
-	}	    
+	}
 	if (ns == NULL)
 	    goto internal_error;
 	attr->ns = ns;
-    }   
-    
-    XML_TREE_ADOPT_STR(attr->name);    
+    }
+
+    XML_TREE_ADOPT_STR(attr->name);
     attr->atype = 0;
     attr->psvi = NULL;
     /*
@@ -9395,7 +9395,7 @@
 	    case XML_TEXT_NODE:
 	    case XML_CDATA_SECTION_NODE:
 		XML_TREE_ADOPT_STR_2(cur->content)
-		break;	   
+		break;
 	    case XML_ENTITY_REF_NODE:
 		/*
 		* Remove reference to the entitity-node.
@@ -9413,7 +9413,7 @@
 			cur->content = ent->content;
 			cur->children = (xmlNodePtr) ent;
 			cur->last = (xmlNodePtr) ent;
-		    }	    	    		
+		    }
 		}
 		break;
 	    default:
@@ -9451,8 +9451,8 @@
 * 1) If @destParent is given, then nsDef entries on element-nodes are used
 * 2) If *no* @destParent is given, then @destDoc->oldNs entries are used
 *    This is the case when you have an unliked node and just want to move it
-*    to the context of 
-* 
+*    to the context of
+*
 * If @destParent is given, it ensures that the tree is namespace
 * wellformed by creating additional ns-decls where needed.
 * Note that, since prefixes of already existent ns-decls can be
@@ -9469,7 +9469,7 @@
 xmlDOMWrapAdoptNode(xmlDOMWrapCtxtPtr ctxt,
 		    xmlDocPtr sourceDoc,
 		    xmlNodePtr node,
-		    xmlDocPtr destDoc,		    
+		    xmlDocPtr destDoc,
 		    xmlNodePtr destParent,
 		    int options)
 {
@@ -9478,7 +9478,7 @@
 	return(-1);
     /*
     * Check node->doc sanity.
-    */    
+    */
     if ((node->doc != NULL) && (sourceDoc != NULL) &&
 	(node->doc != sourceDoc)) {
 	/*
@@ -9491,7 +9491,7 @@
     if (sourceDoc == destDoc)
 	return (-1);
     switch (node->type) {
-	case XML_ELEMENT_NODE:	    
+	case XML_ELEMENT_NODE:
 	case XML_ATTRIBUTE_NODE:
 	case XML_TEXT_NODE:
 	case XML_CDATA_SECTION_NODE:
@@ -9517,7 +9517,7 @@
     } else if (node->type == XML_ATTRIBUTE_NODE) {
 	    return (xmlDOMWrapAdoptAttr(ctxt, sourceDoc,
 		(xmlAttrPtr) node, destDoc, destParent, options));
-    } else {	
+    } else {
 	xmlNodePtr cur = node;
 	int adoptStr = 1;
 
@@ -9529,7 +9529,7 @@
 	    (sourceDoc->dict == destDoc->dict))
 		adoptStr = 0;
 	switch (node->type) {
-	    case XML_TEXT_NODE:	    
+	    case XML_TEXT_NODE:
 	    case XML_CDATA_SECTION_NODE:
 		XML_TREE_ADOPT_STR_2(node->content)
 		    break;
@@ -9562,7 +9562,7 @@
 	    default:
 		break;
 	}
-    }	
+    }
     return (0);
 }
 

Modified: trunk/xmlreader.c
==============================================================================
--- trunk/xmlreader.c	(original)
+++ trunk/xmlreader.c	Mon Aug 25 14:53:31 2008
@@ -1847,17 +1847,22 @@
     }
 
     if (reader->state != XML_TEXTREADER_BACKTRACK) {
-        if (reader->node->children != 0) {
-            reader->node = reader->node->children;
-            reader->depth++;
+	/* Here removed traversal to child, because we want to skip the subtree, 
+	replace with traversal to sibling to skip subtree */
+        if (reader->node->next != 0) {
+            reader->node = reader->node->next;// Move to sibling if present,skipping sub-tree
+            //reader->depth++;
             reader->state = XML_TEXTREADER_START;
             return(1);
         }
-
+	
+	/* if reader->node->next is NULL mean no subtree for current node, 
+	so need to move to sibling of parent node if present */
         if ((reader->node->type == XML_ELEMENT_NODE) ||
             (reader->node->type == XML_ATTRIBUTE_NODE)) {
             reader->state = XML_TEXTREADER_BACKTRACK;
-            return(1);
+            xmlTextReaderRead(reader);// This will move to parent if present
+            //return(xmlTextReaderReadTree(reader));
         }
     }
 
@@ -1876,7 +1881,8 @@
         reader->node = reader->node->parent;
         reader->depth--;
         reader->state = XML_TEXTREADER_BACKTRACK;
-        return(1);
+        xmlTextReaderNextTree(reader); //Repeat process to move to sibling of parent node if present
+        //return(1);
     }
 
     reader->state = XML_TEXTREADER_END;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]