Updated TODO conditionnal compile of messages from the parser/tree.c code,

Updated TODO
conditionnal compile of messages from the parser/tree.c code,
Daniel
diff --git a/ChangeLog b/ChangeLog
index aa04c54..b17d0c4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Sat Jan 15 15:09:06 CET 2000 Daniel Veillard <Daniel.Veillard@w3.org>
+
+	* TODO: updated
+	* tree.c, parser.c: made sure that only memory alloc problems
+	  and internal parser errors are allowed to write to stdout or
+	  stderr.
+
 Thu Jan 13 11:49:11 CET 2000 Daniel Veillard <Daniel.Veillard@w3.org>
 
 	* tree.c : restored xmlNewGlobalNs since this seems used by
diff --git a/TODO b/TODO
index f3ab844..417ea00 100644
--- a/TODO
+++ b/TODO
@@ -1,16 +1,149 @@
 
-           TODO for the XML parser:
+           TODO for the XML parser and stuff:
+	   ==================================
 
-- use libunicode !
-- finish XPath, then XPointer, Xlink
-- Support for UTF-8 and UTF-16 encoding (Urgent !!!).
-- progressive parsing. The entity support is a first step toward
+URGENT:
+=======
+- Support for UTF-8 and UTF-16 encoding
+  => added some convertion routines provided by Martin Durst but I didn't
+     try to glue them in. I plan to keep everything internally as UTF-8
+     this is slightly more costly but more compact, and recent processors
+     efficiency is cache related. The key for good performances is keeping
+     the data set small, so will I.
+  => the new progressive reading routines call the detection code which
+     need to be enabled, then thest the ISO->UTF-8 stuff, and add more
+     charset conv routines.
+
+TODO:
+=====
+
+- Tools to produce man pages from the SGML docs.
+
+- Finish XPath
+  => attributes addressing troubles
+  => defaulted attributes handling
+  => namespace axis ?
+
+- Add Xpointer recognition/API
+
+- Add Xlink recognition/API
+  => started adding an xlink.[ch] with a unified API for XML and HTML.
+
+- Implement XSLT
+  => seems that someone volunteered ?!?
+
+- Implement XSchemas
+
+- O2K parsing;
+  => this is a somewhat ugly mix of HTML and XML, adding a specific
+     routine in the comment parsing code of HTML and plug the XML 
+     parsing one in-there should not be too hard. Key point is to get
+     XSL to transform all this to something decent ...
+
+- Add regression tests for all WFC errors
+  => did some in test/WFC , not added to the Makefile yet.
+
+- Optimization of tag strings allocation.
+
+- Language identification code, productions [33] to [38]
+
+- Conditional sections in DTDs [61] to [65]
+  => should this crap be really implemented ???
+
+
+- Allow parsed entities defined in the internal subset to override
+  the ones defined in the external subset (DtD customization).
+  => This mean that the entity content should be computed only at
+     use time, i.e. keep the orig string only at parse time and expand
+     only when referenced from the external subset :-(
+     Needed for complete use of most DTD from Eve Maler
+
+- maintain coherency of namespace when doing cut'n paste operations
+  => the functions are coded, but need testing
+
+- function to rebuild the ID table ?
+
+- extend the shell with:
+   - edit
+   - load/save
+   - mv (yum, yum, but it's harder because directories are ordered in
+     our case, mvup and mvdown would be required)
+
+- Parsing of a well balanced chunk
+
+- Add HTML validation using the XHTML DTD
+  - problem: do we want to keep and maintain the code for handling
+    DTD/System ID cache directly in libxml ?
+
+- Add a DTD cache prefilled with xhtml DTDs and entities and a program to
+  manage them -> like the /usr/bin/install-catalog from SGML
+  right place seems $datadir/xmldtds
+
+- turn tester into a generic program xml-test installed with xml-devel
+
+- Add output to XHTML in case of HTML documents.
+
+- dynamically adapt the alloc entry point to use g_alloc()/g_free()
+  if the programmer wants it
+
+Done:
+=====
+
+- External entities loading: 
+   - allow override by client code
+   - make sure it is alled for all external entities referenced
+  Done, client code should use xmlSetExternalEntityLoader() to set
+  the default loading routine. It will be called each time an external
+  entity entity resolution is triggered.
+- maintain ID coherency when removing/changing attributes
+  The function used to deallocate attributes now check for it being an
+  ID and removes it from the table.
+- push mode parsing i.e. non-blocking state based parser
+  done, both for XML and HTML parsers. Use xmlCreatePushParserCtxt()
+  and xmlParseChunk() and html counterparts.
+  The tester program now has a --push option to select that parser 
+  front-end. Douplicated tests to use both and check results are similar.
+
+- Most of XPath, still see some troubles and occasionnal memleaks.
+- an XML shell, allowing to traverse/manipulate an XML document with
+  a shell like interface, and using XPath for the anming syntax
+  - use of readline and history added when available
+  - the shell interface has been cleanly separated and moved to debugXML.c
+- HTML parser, should be fairly stable now
+- API to search the lang of an attribute
+- Collect IDs at parsing and maintain a table. 
+   PBM: maintain the table coherency
+   PBM: how to detect ID types in absence of DtD !
+- Use it for XPath ID support
+- Add validity checking
+  Should be finished now !
+- Add regression tests with entity substitutions
+
+- External Parsed entities, either XML or external Subset [78] and [79]
+  parsing the xmllang DtD now works, so it should be sufficient for
+  most cases !
+
+- progressive reading. The entity support is a first step toward
   asbtraction of an input stream. A large part of the context is still
   located on the stack, moving to a state machine and putting everyting
   in the parsing context should provide an adequate solution.
+  => Rather than progressive parsing, give more power to the SAX-like
+     interface. Currently the DOM-like representation is built but
+     => it should be possible to define that only as a set of SAX callbacks
+	and remove the tree creation from the parser code.
+	DONE
 
-Done:
-- Improve the support for SAX
+- DOM support, instead of using a proprietary in memory
+  format for the document representation, the parser should
+  call a DOM API to actually build the resulting document.
+  Then the parser becomes independent of the in-memory
+  representation of the document. Even better using RPC's
+  the parser can actually build the document in another
+  program.
+  => Work started, now the internal representation is by default
+     very near a direct DOM implementation. The DOM glue is implemented
+     as a separate module. See the GNOME gdome module.
+
 - C++ support : John Ehresman <jehresma@dsg.harvard.edu>
 - Updated code to follow more recent specs, added compatibility flag
 - Better error handling, use a dedicated, overridable error
@@ -18,5 +151,7 @@
 - Support for CDATA.
 - Keep track of line numbers for better error reporting.
 - Support for PI (SAX one).
+- Support for Comments (bad, should be in ASAP, they are parsed
+  but not stored), should be configurable.
+- Improve the support of entities on save (+SAX).
 
-$Id$
diff --git a/parser.c b/parser.c
index eb9a578..424b3f8 100644
--- a/parser.c
+++ b/parser.c
@@ -795,7 +795,6 @@
     int val = 0;
 
     if (ctxt->token != 0) {
-fprintf(stderr, "xmlParseCharRef : ctxt->token != 0\n");    
 	val = ctxt->token;
         ctxt->token = 0;
         return(val);
@@ -994,7 +993,6 @@
     xmlEntityPtr ent = NULL;
 
     if (ctxt->token != 0) {
-fprintf(stderr, "xmlParserHandleReference : ctxt->token != 0\n");
         return;
     }	
     if (CUR != '&') return;
@@ -1229,7 +1227,6 @@
     xmlParserInputPtr input;
 
     if (ctxt->token != 0) {
-fprintf(stderr, "xmlParserHandlePEReference : ctxt->token != 0\n");
         return;
     }	
     if (CUR != '%') return;
diff --git a/tree.c b/tree.c
index 425b454..7616f1b 100644
--- a/tree.c
+++ b/tree.c
@@ -48,6 +48,9 @@
 	(n)->last = ulccur;						\
 }}
 
+/* #define DEBUG_BUFFER */
+/* #define DEBUG_TREE */
+
 /************************************************************************
  *									*
  *		Allocation and deallocation of basic structures		*
@@ -95,7 +98,9 @@
 
     if ((doc == NULL) || (doc->oldNs == NULL)) return;
     if (doc->root == NULL) {
+#ifdef DEBUG_TREE
         fprintf(stderr, "xmlUpgradeOldNs: failed no root !\n");
+#endif
 	return;
     }
 
@@ -126,7 +131,9 @@
     xmlNsPtr cur;
 
     if (href == NULL) {
+#ifdef DEBUG_TREE
         fprintf(stderr, "xmlNewNs: href == NULL !\n");
+#endif
 	return(NULL);
     }
 
@@ -248,7 +255,9 @@
 void
 xmlSetNs(xmlNodePtr node, xmlNsPtr ns) {
     if (node == NULL) {
+#ifdef DEBUG_TREE
         fprintf(stderr, "xmlSetNs: node == NULL\n");
+#else
 	return;
     }
     node->ns = ns;
@@ -263,7 +272,9 @@
 void
 xmlFreeNs(xmlNsPtr cur) {
     if (cur == NULL) {
+#ifdef DEBUG_TREE
         fprintf(stderr, "xmlFreeNs : ns == NULL\n");
+#endif
 	return;
     }
     if (cur->href != NULL) xmlFree((char *) cur->href);
@@ -282,7 +293,9 @@
 xmlFreeNsList(xmlNsPtr cur) {
     xmlNsPtr next;
     if (cur == NULL) {
+#ifdef DEBUG_TREE
         fprintf(stderr, "xmlFreeNsList : ns == NULL\n");
+#endif
 	return;
     }
     while (cur != NULL) {
@@ -308,9 +321,12 @@
     xmlDtdPtr cur;
 
     if ((doc != NULL) && (doc->extSubset != NULL)) {
+#ifdef DEBUG_TREE
         fprintf(stderr, "xmlNewDtd(%s): document %s already have a DTD %s\n",
 	    /* !!! */ (char *) name, doc->name,
 	    /* !!! */ (char *)doc->extSubset->name);
+#endif
+	return(NULL);
     }
 
     /*
@@ -360,9 +376,11 @@
     xmlDtdPtr cur;
 
     if ((doc != NULL) && (doc->intSubset != NULL)) {
+#ifdef DEBUG_TREE
         fprintf(stderr, 
      "xmlCreateIntSubset(): document %s already have an internal subset\n",
 	    doc->name);
+#endif
 	return(NULL);
     }
 
@@ -406,7 +424,9 @@
 void
 xmlFreeDtd(xmlDtdPtr cur) {
     if (cur == NULL) {
+#ifdef DEBUG_TREE
         fprintf(stderr, "xmlFreeDtd : DTD == NULL\n");
+#endif
 	return;
     }
     if (cur->name != NULL) xmlFree((char *) cur->name);
@@ -435,7 +455,9 @@
     xmlDocPtr cur;
 
     if (version == NULL) {
+#ifdef DEBUG_TREE
         fprintf(stderr, "xmlNewDoc : version == NULL\n");
+#endif
 	return(NULL);
     }
 
@@ -544,8 +566,10 @@
 	    q = cur;
 	    while ((*cur != 0) && (cur - value < len) && (*cur != ';')) cur++;
 	    if ((*cur == 0) || (cur - value >= len)) {
+#ifdef DEBUG_TREE
 	        fprintf(stderr,
 		    "xmlStringLenGetNodeList: unterminated entity %30s\n", q);
+#endif
 	        return(ret);
 	    }
             if (cur != q) {
@@ -655,8 +679,10 @@
 	    q = cur;
 	    while ((*cur != 0) && (*cur != ';')) cur++;
 	    if (*cur == 0) {
+#ifdef DEBUG_TREE
 	        fprintf(stderr,
 		        "xmlStringGetNodeList: unterminated entity %30s\n", q);
+#endif
 	        return(ret);
 	    }
             if (cur != q) {
@@ -804,7 +830,9 @@
     xmlAttrPtr cur;
 
     if (name == NULL) {
+#ifdef DEBUG_TREE
         fprintf(stderr, "xmlNewProp : name == NULL\n");
+#endif
 	return(NULL);
     }
 
@@ -871,7 +899,9 @@
     xmlAttrPtr cur;
 
     if (name == NULL) {
+#ifdef DEBUG_TREE
         fprintf(stderr, "xmlNewProp : name == NULL\n");
+#endif
 	return(NULL);
     }
 
@@ -928,7 +958,9 @@
     xmlAttrPtr cur;
 
     if (name == NULL) {
+#ifdef DEBUG_TREE
         fprintf(stderr, "xmlNewProp : name == NULL\n");
+#endif
 	return(NULL);
     }
 
@@ -967,7 +999,9 @@
 xmlFreePropList(xmlAttrPtr cur) {
     xmlAttrPtr next;
     if (cur == NULL) {
+#ifdef DEBUG_TREE
         fprintf(stderr, "xmlFreePropList : property == NULL\n");
+#endif
 	return;
     }
     while (cur != NULL) {
@@ -986,7 +1020,9 @@
 void
 xmlFreeProp(xmlAttrPtr cur) {
     if (cur == NULL) {
+#ifdef DEBUG_TREE
         fprintf(stderr, "xmlFreeProp : property == NULL\n");
+#endif
 	return;
     }
     /* Check for ID removal -> leading to invalid references ! */
@@ -1012,11 +1048,14 @@
 xmlRemoveProp(xmlAttrPtr cur) {
     xmlAttrPtr tmp;
     if (cur == NULL) {
+#ifdef DEBUG_TREE
         fprintf(stderr, "xmlRemoveProp : cur == NULL\n");
+#endif
 	return(-1);
     }
     if (cur->node == NULL) {
         fprintf(stderr, "xmlRemoveProp : cur->node == NULL\n");
+#endif
 	return(-1);
     }
     tmp = cur->node->properties;
@@ -1033,7 +1072,9 @@
 	}
         tmp = tmp->next;
     }
+#ifdef DEBUG_TREE
     fprintf(stderr, "xmlRemoveProp : attribute not owned by its node\n");
+#endif
     return(-1);
 }
 
@@ -1050,7 +1091,9 @@
     xmlNodePtr cur;
 
     if (name == NULL) {
+#ifdef DEBUG_TREE
         fprintf(stderr, "xmlNewPI : name == NULL\n");
+#endif
 	return(NULL);
     }
 
@@ -1107,7 +1150,9 @@
     xmlNodePtr cur;
 
     if (name == NULL) {
+#ifdef DEBUG_TREE
         fprintf(stderr, "xmlNewNode : name == NULL\n");
+#endif
 	return(NULL);
     }
 
@@ -1308,12 +1353,16 @@
     xmlNodePtr cur, prev;
 
     if (parent == NULL) {
+#ifdef DEBUG_TREE
         fprintf(stderr, "xmlNewTextChild : parent == NULL\n");
+#endif
 	return(NULL);
     }
 
     if (name == NULL) {
+#ifdef DEBUG_TREE
         fprintf(stderr, "xmlNewTextChild : name == NULL\n");
+#endif
 	return(NULL);
     }
 
@@ -1642,12 +1691,16 @@
     xmlNodePtr cur, prev;
 
     if (parent == NULL) {
+#ifdef DEBUG_TREE
         fprintf(stderr, "xmlNewChild : parent == NULL\n");
+#endif
 	return(NULL);
     }
 
     if (name == NULL) {
+#ifdef DEBUG_TREE
         fprintf(stderr, "xmlNewChild : name == NULL\n");
+#endif
 	return(NULL);
     }
 
@@ -1693,11 +1746,15 @@
 xmlNodePtr
 xmlAddNextSibling(xmlNodePtr cur, xmlNodePtr elem) {
     if (cur == NULL) {
+#ifdef DEBUG_TREE
         fprintf(stderr, "xmlAddNextSibling : cur == NULL\n");
+#endif
 	return(NULL);
     }
     if (elem == NULL) {
+#ifdef DEBUG_TREE
         fprintf(stderr, "xmlAddNextSibling : elem == NULL\n");
+#endif
 	return(NULL);
     }
 
@@ -1728,11 +1785,15 @@
 xmlNodePtr
 xmlAddPrevSibling(xmlNodePtr cur, xmlNodePtr elem) {
     if (cur == NULL) {
+#ifdef DEBUG_TREE
         fprintf(stderr, "xmlAddPrevSibling : cur == NULL\n");
+#endif
 	return(NULL);
     }
     if (elem == NULL) {
+#ifdef DEBUG_TREE
         fprintf(stderr, "xmlAddPrevSibling : elem == NULL\n");
+#endif
 	return(NULL);
     }
 
@@ -1765,12 +1826,16 @@
     xmlNodePtr parent;
 
     if (cur == NULL) {
+#ifdef DEBUG_TREE
         fprintf(stderr, "xmlAddSibling : cur == NULL\n");
+#endif
 	return(NULL);
     }
 
     if (elem == NULL) {
+#ifdef DEBUG_TREE
         fprintf(stderr, "xmlAddSibling : elem == NULL\n");
+#endif
 	return(NULL);
     }
 
@@ -1815,18 +1880,24 @@
     xmlNodePtr prev;
 
     if (parent == NULL) {
+#ifdef DEBUG_TREE
         fprintf(stderr, "xmlAddChild : parent == NULL\n");
+#endif
 	return(NULL);
     }
 
     if (cur == NULL) {
+#ifdef DEBUG_TREE
         fprintf(stderr, "xmlAddChild : child == NULL\n");
+#endif
 	return(NULL);
     }
 
     if ((cur->doc != NULL) && (parent->doc != NULL) &&
         (cur->doc != parent->doc)) {
+#ifdef DEBUG_TREE
 	fprintf(stderr, "Elements moved to a different document\n");
+#endif
     }
 
     /*
@@ -1884,7 +1955,9 @@
 xmlNodePtr
 xmlGetLastChild(xmlNodePtr parent) {
     if (parent == NULL) {
+#ifdef DEBUG_TREE
         fprintf(stderr, "xmlGetLastChild : parent == NULL\n");
+#endif
 	return(NULL);
     }
     return(parent->last);
@@ -1901,7 +1974,9 @@
 xmlFreeNodeList(xmlNodePtr cur) {
     xmlNodePtr next;
     if (cur == NULL) {
+#ifdef DEBUG_TREE
         fprintf(stderr, "xmlFreeNodeList : node == NULL\n");
+#endif
 	return;
     }
     while (cur != NULL) {
@@ -1920,7 +1995,9 @@
 void
 xmlFreeNode(xmlNodePtr cur) {
     if (cur == NULL) {
+#ifdef DEBUG_TREE
         fprintf(stderr, "xmlFreeNode : node == NULL\n");
+#endif
 	return;
     }
     cur->doc = NULL;
@@ -1950,7 +2027,9 @@
 void
 xmlUnlinkNode(xmlNodePtr cur) {
     if (cur == NULL) {
+#ifdef DEBUG_TREE
         fprintf(stderr, "xmlUnlinkNode : node == NULL\n");
+#endif
 	return;
     }
     if ((cur->parent != NULL) && (cur->parent->childs == cur))
@@ -1979,7 +2058,9 @@
 xmlNodePtr
 xmlReplaceNode(xmlNodePtr old, xmlNodePtr cur) {
     if (old == NULL) {
+#ifdef DEBUG_TREE
         fprintf(stderr, "xmlReplaceNode : old == NULL\n");
+#endif
 	return(NULL);
     }
     if (cur == NULL) {
@@ -2033,7 +2114,9 @@
 	    ret = xmlNewNs(NULL, cur->href, cur->prefix);
 	    break;
 	default:
+#ifdef DEBUG_TREE
 	    fprintf(stderr, "xmlCopyNamespace: unknown type %d\n", cur->type);
+#endif
 	    return(NULL);
     }
     return(ret);
@@ -2645,7 +2728,9 @@
 void
 xmlNodeSetContent(xmlNodePtr cur, const xmlChar *content) {
     if (cur == NULL) {
+#ifdef DEBUG_TREE
         fprintf(stderr, "xmlNodeSetContent : node == NULL\n");
+#endif
 	return;
     }
     switch (cur->type) {
@@ -2712,7 +2797,9 @@
 void
 xmlNodeSetContentLen(xmlNodePtr cur, const xmlChar *content, int len) {
     if (cur == NULL) {
+#ifdef DEBUG_TREE
         fprintf(stderr, "xmlNodeSetContentLen : node == NULL\n");
+#endif
 	return;
     }
     switch (cur->type) {
@@ -2778,7 +2865,9 @@
 void
 xmlNodeAddContentLen(xmlNodePtr cur, const xmlChar *content, int len) {
     if (cur == NULL) {
+#ifdef DEBUG_TREE
         fprintf(stderr, "xmlNodeAddContentLen : node == NULL\n");
+#endif
 	return;
     }
     if (len <= 0) return;
@@ -2851,7 +2940,9 @@
     int len;
 
     if (cur == NULL) {
+#ifdef DEBUG_TREE
         fprintf(stderr, "xmlNodeAddContent : node == NULL\n");
+#endif
 	return;
     }
     if (content == NULL) return;
@@ -3445,7 +3536,9 @@
 
     if ((node->type != XML_TEXT_NODE) &&
         (node->type != XML_CDATA_SECTION_NODE)) {
+#ifdef DEBUG_TREE
 	fprintf(stderr, "xmlTextConcat: node is not text nor cdata\n");
+#endif
         return;
     }
 #ifndef XML_USE_BUFFER_CONTENT
@@ -3534,7 +3627,9 @@
 xmlBufferSetAllocationScheme(xmlBufferPtr buf, 
                              xmlBufferAllocationScheme scheme) {
     if (buf == NULL) {
+#ifdef DEBUG_BUFFER
         fprintf(stderr, "xmlBufferSetAllocationScheme: buf == NULL\n");
+#endif
         return;
     }
 
@@ -3550,7 +3645,9 @@
 void
 xmlBufferFree(xmlBufferPtr buf) {
     if (buf == NULL) {
+#ifdef DEBUG_BUFFER
         fprintf(stderr, "xmlBufferFree: buf == NULL\n");
+#endif
 	return;
     }
     if (buf->content != NULL) {
@@ -3611,11 +3708,15 @@
     int ret;
 
     if (buf == NULL) {
+#ifdef DEBUG_BUFFER
         fprintf(stderr, "xmlBufferDump: buf == NULL\n");
+#endif
 	return(0);
     }
     if (buf->content == NULL) {
+#ifdef DEBUG_BUFFER
         fprintf(stderr, "xmlBufferDump: buf->content == NULL\n");
+#endif
 	return(0);
     }
     if (file == NULL) file = stdout;
@@ -3715,11 +3816,15 @@
     int l, needSize;
 
     if (str == NULL) {
+#ifdef DEBUG_BUFFER
         fprintf(stderr, "xmlBufferAdd: str == NULL\n");
+#endif
 	return;
     }
     if (len < -1) {
+#ifdef DEBUG_BUFFER
         fprintf(stderr, "xmlBufferAdd: len < 0\n");
+#endif
 	return;
     }
     if (len == 0) return;
@@ -3730,7 +3835,12 @@
     else 
 	for (l = 0;l < len;l++)
 	    if (str[l] == 0) break;
-    if (l < len){  len = l; printf("xmlBufferAdd bad length\n"); }
+    if (l < len){  
+	len = l; 
+#ifdef DEBUG_BUFFER
+	printf("xmlBufferAdd bad length\n");
+#endif
+    }
 
     /* CJN 11.18.99 okay, now I'm using the length */
     if(len == -1) len = l;
@@ -3776,7 +3886,9 @@
     const char *cur;
 
     if (str == NULL) {
+#ifdef DEBUG_BUFFER
         fprintf(stderr, "xmlBufferAdd: str == NULL\n");
+#endif
 	return;
     }
     for (cur = str;*cur != 0;cur++) {
@@ -3830,8 +3942,10 @@
 xmlBufferWriteQuotedString(xmlBufferPtr buf, const xmlChar *string) {
     if (xmlStrchr(string, '"')) {
         if (xmlStrchr(string, '\'')) {
+#ifdef DEBUG_BUFFER
 	    fprintf(stderr,
  "xmlBufferWriteQuotedString: string contains quote and double-quotes !\n");
+#endif
 	}
         xmlBufferCCat(buf, "'");
         xmlBufferCat(buf, string);
@@ -3854,7 +3968,9 @@
 static void
 xmlGlobalNsDump(xmlBufferPtr buf, xmlNsPtr cur) {
     if (cur == NULL) {
+#ifdef DEBUG_TREE
         fprintf(stderr, "xmlGlobalNsDump : Ns == NULL\n");
+#endif
 	return;
     }
     if (cur->type == XML_GLOBAL_NAMESPACE) {
@@ -3897,7 +4013,9 @@
 static void
 xmlNsDump(xmlBufferPtr buf, xmlNsPtr cur) {
     if (cur == NULL) {
+#ifdef DEBUG_TREE
         fprintf(stderr, "xmlNsDump : Ns == NULL\n");
+#endif
 	return;
     }
     if (cur->type == XML_LOCAL_NAMESPACE) {
@@ -3940,7 +4058,9 @@
     xmlDtdPtr cur = doc->intSubset;
 
     if (cur == NULL) {
+#ifdef DEBUG_TREE
         fprintf(stderr, "xmlDtdDump : no internal subset\n");
+#endif
 	return;
     }
     xmlBufferWriteChar(buf, "<!DOCTYPE ");
@@ -3986,7 +4106,9 @@
     xmlChar *value;
 
     if (cur == NULL) {
+#ifdef DEBUG_TREE
         fprintf(stderr, "xmlAttrDump : property == NULL\n");
+#endif
 	return;
     }
     xmlBufferWriteChar(buf, " ");
@@ -4016,7 +4138,9 @@
 static void
 xmlAttrListDump(xmlBufferPtr buf, xmlDocPtr doc, xmlAttrPtr cur) {
     if (cur == NULL) {
+#ifdef DEBUG_TREE
         fprintf(stderr, "xmlAttrListDump : property == NULL\n");
+#endif
 	return;
     }
     while (cur != NULL) {
@@ -4048,7 +4172,9 @@
     int i;
 
     if (cur == NULL) {
+#ifdef DEBUG_TREE
         fprintf(stderr, "xmlNodeListDump : node == NULL\n");
+#endif
 	return;
     }
     while (cur != NULL) {
@@ -4081,7 +4207,9 @@
     xmlNodePtr tmp;
 
     if (cur == NULL) {
+#ifdef DEBUG_TREE
         fprintf(stderr, "xmlNodeDump : node == NULL\n");
+#endif
 	return;
     }
     if (cur->type == XML_TEXT_NODE) {