Bug fixes and an extension found and required by XSLT:
- xpath.c: bug fixes found from XSLT
- tree.c: preserve node->name special values when copying nodes.
- parserInternals.[ch] parser.[ch] SAX.c : added a mode where
  external subset are fetched when available but without full
  validation. Added xmlLoadExtDtdDefaultValue, need a function.
- HTMLtree.c: add support for xmlStringTextNoenc for XSLt HTML
  output with encoding disabled.
Daniel
diff --git a/ChangeLog b/ChangeLog
index b20ade8..27e8363 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+Mon Feb  5 18:51:36 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+	* xpath.c: bug fixes found from XSLT
+	* tree.c: preserve node->name special values when copying nodes.
+	* parserInternals.[ch] parser.[ch] SAX.c : added a mode where
+	  external subset are fetched when available but without full
+	  validation. Added xmlLoadExtDtdDefaultValue, need a function.
+	* HTMLtree.c: add support for xmlStringTextNoenc for XSLt HTML
+	  output with encoding disabled.
+
 Sat Feb  3 09:50:29 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
 
 	* xmliO.c: Harry Blundell pointed out that xmlCheckFilename
diff --git a/HTMLtree.c b/HTMLtree.c
index 8e444b5..17fef14 100644
--- a/HTMLtree.c
+++ b/HTMLtree.c
@@ -32,6 +32,7 @@
 #include <libxml/entities.h>
 #include <libxml/valid.h>
 #include <libxml/xmlerror.h>
+#include <libxml/parserInternals.h>
 
 /************************************************************************
  *									*
@@ -460,17 +461,22 @@
     }
     if (cur->type == HTML_TEXT_NODE) {
 	if (cur->content != NULL) {
-            xmlChar *buffer;
+	    if ((cur->name == xmlStringText) ||
+		(cur->name != xmlStringTextNoenc)) {
+		xmlChar *buffer;
 
 #ifndef XML_USE_BUFFER_CONTENT
-            buffer = xmlEncodeEntitiesReentrant(doc, cur->content);
+		buffer = xmlEncodeEntitiesReentrant(doc, cur->content);
 #else
-            buffer = xmlEncodeEntitiesReentrant(doc, 
-                                                xmlBufferContent(cur->content));
+		buffer = xmlEncodeEntitiesReentrant(doc, 
+					    xmlBufferContent(cur->content));
 #endif 
-	    if (buffer != NULL) {
-		xmlBufferWriteCHAR(buf, buffer);
-		xmlFree(buffer);
+		if (buffer != NULL) {
+		    xmlBufferWriteCHAR(buf, buffer);
+		    xmlFree(buffer);
+		}
+	    } else {
+		xmlBufferWriteCHAR(buf, cur->content);
 	    }
 	}
 	return;
@@ -794,17 +800,22 @@
     }
     if (cur->type == HTML_TEXT_NODE) {
 	if (cur->content != NULL) {
-            xmlChar *buffer;
+	    if ((cur->name == xmlStringText) ||
+		(cur->name != xmlStringTextNoenc)) {
+		xmlChar *buffer;
 
 #ifndef XML_USE_BUFFER_CONTENT
-            buffer = xmlEncodeEntitiesReentrant(doc, cur->content);
+		buffer = xmlEncodeEntitiesReentrant(doc, cur->content);
 #else
-            buffer = xmlEncodeEntitiesReentrant(doc, 
-                                                xmlBufferContent(cur->content));
+		buffer = xmlEncodeEntitiesReentrant(doc, 
+					    xmlBufferContent(cur->content));
 #endif 
-	    if (buffer != NULL) {
-		xmlOutputBufferWriteString(buf, (const char *)buffer);
-		xmlFree(buffer);
+		if (buffer != NULL) {
+		    xmlOutputBufferWriteString(buf, (const char *)buffer);
+		    xmlFree(buffer);
+		}
+	    } else {
+		xmlOutputBufferWriteString(buf, (const char *)cur->content);
 	    }
 	}
 	return;
diff --git a/SAX.c b/SAX.c
index 8483c2f..7fa94d6 100644
--- a/SAX.c
+++ b/SAX.c
@@ -200,7 +200,8 @@
             name, ExternalID, SystemID);
 #endif
     if (((ExternalID != NULL) || (SystemID != NULL)) &&
-        (ctxt->validate && ctxt->wellFormed && ctxt->myDoc)) {
+        (((ctxt->validate) || (ctxt->loadsubset)) &&
+	 (ctxt->wellFormed && ctxt->myDoc))) {
 	/*
 	 * Try to fetch and parse the external subset.
 	 */
diff --git a/include/libxml/parser.h b/include/libxml/parser.h
index 95e529d..b98f2a3 100644
--- a/include/libxml/parser.h
+++ b/include/libxml/parser.h
@@ -185,6 +185,8 @@
     int                nodemem;       /* Speed up large node parsing */
     int                pedantic;      /* signal pedantic warnings */
     void              *_private;      /* For user data, libxml won't touch it */
+
+    int                loadsubset;    /* should the external subset be loaded */
 };
 
 /**
diff --git a/include/libxml/parserInternals.h b/include/libxml/parserInternals.h
index b0dda64..c62b298 100644
--- a/include/libxml/parserInternals.h
+++ b/include/libxml/parserInternals.h
@@ -110,6 +110,7 @@
 LIBXML_DLL_IMPORT extern int xmlParserDebugEntities;
 LIBXML_DLL_IMPORT extern int xmlSubstituteEntitiesDefaultValue;
 LIBXML_DLL_IMPORT extern int xmlDoValidityCheckingDefaultValue;
+LIBXML_DLL_IMPORT extern int xmlLoadExtDtdDefaultValue;
 LIBXML_DLL_IMPORT extern int xmlPedanticParserDefaultValue;
 LIBXML_DLL_IMPORT extern int xmlKeepBlanksDefaultValue;
 LIBXML_DLL_IMPORT extern xmlChar xmlStringText[];
diff --git a/parser.c b/parser.c
index 7d97251..d46a9b1 100644
--- a/parser.c
+++ b/parser.c
@@ -92,6 +92,7 @@
 int xmlSubstituteEntitiesDefaultValue = 0;
 int xmlDoValidityCheckingDefaultValue = 0;
 #endif
+int xmlLoadExtDtdDefaultValue = 0;
 int xmlPedanticParserDefaultValue = 0;
 int xmlKeepBlanksDefaultValue = 1;
 
@@ -7211,6 +7212,7 @@
      */
     ctxt->instate = XML_PARSER_CONTENT;
     ctxt->validate = 0;
+    ctxt->loadsubset = 0;
     ctxt->depth = 0;
 
     xmlParseContent(ctxt);
@@ -8750,6 +8752,7 @@
      */
     ctxt->instate = XML_PARSER_CONTENT;
     ctxt->validate = ctx->validate;
+    ctxt->loadsubset = ctx->loadsubset;
     ctxt->depth = ctx->depth + 1;
     ctxt->replaceEntities = ctx->replaceEntities;
     if (ctxt->validate) {
@@ -8927,6 +8930,7 @@
      */
     ctxt->instate = XML_PARSER_CONTENT;
     ctxt->validate = 0;
+    ctxt->loadsubset = 0;
     ctxt->depth = depth;
 
     xmlParseContent(ctxt);
@@ -9071,6 +9075,7 @@
      * Doing validity checking on chunk doesn't make sense
      */
     ctxt->validate = 0;
+    ctxt->loadsubset = 0;
 
     xmlParseContent(ctxt);
    
diff --git a/parser.h b/parser.h
index 95e529d..b98f2a3 100644
--- a/parser.h
+++ b/parser.h
@@ -185,6 +185,8 @@
     int                nodemem;       /* Speed up large node parsing */
     int                pedantic;      /* signal pedantic warnings */
     void              *_private;      /* For user data, libxml won't touch it */
+
+    int                loadsubset;    /* should the external subset be loaded */
 };
 
 /**
diff --git a/parserInternals.c b/parserInternals.c
index 37e3c7b..f99ed4e 100644
--- a/parserInternals.c
+++ b/parserInternals.c
@@ -83,6 +83,7 @@
 
 const char *xmlFeaturesList[] = {
     "validate",
+    "load subset",
     "keep blanks",
     "disable SAX",
     "fetch external entities",
@@ -174,7 +175,7 @@
     } else if (!strcmp(name, "disable SAX")) {
 	*((int *) result) = ctxt->disableSAX;
     } else if (!strcmp(name, "fetch external entities")) {
-	*((int *) result) = ctxt->validate;
+	*((int *) result) = ctxt->loadsubset;
     } else if (!strcmp(name, "substitute entities")) {
 	*((int *) result) = ctxt->replaceEntities;
     } else if (!strcmp(name, "gather line info")) {
@@ -269,14 +270,8 @@
 	return(-1);
 
     if (!strcmp(name, "validate")) {
-        ctxt->validate = *((int *) value);
-    } else if (!strcmp(name, "keep blanks")) {
-        ctxt->keepBlanks = *((int *) value);
-    } else if (!strcmp(name, "disable SAX")) {
-        ctxt->disableSAX = *((int *) value);
-    } else if (!strcmp(name, "fetch external entities")) {
-	int newvalid = *((int *) value);
-	if ((!ctxt->validate) && (newvalid != 0)) {
+	int newvalidate = *((int *) value);
+	if ((!ctxt->validate) && (newvalidate != 0)) {
 	    if (ctxt->vctxt.warning == NULL)
 		ctxt->vctxt.warning = xmlParserValidityWarning;
 	    if (ctxt->vctxt.error == NULL)
@@ -293,7 +288,13 @@
 	    ctxt->vctxt.nodeMax = 4;
 	    ctxt->vctxt.node = NULL;
 	}
-	ctxt->validate = newvalid;
+        ctxt->validate = newvalidate;
+    } else if (!strcmp(name, "keep blanks")) {
+        ctxt->keepBlanks = *((int *) value);
+    } else if (!strcmp(name, "disable SAX")) {
+        ctxt->disableSAX = *((int *) value);
+    } else if (!strcmp(name, "fetch external entities")) {
+	ctxt->loadsubset = *((int *) value);
     } else if (!strcmp(name, "substitute entities")) {
         ctxt->replaceEntities = *((int *) value);
     } else if (!strcmp(name, "gather line info")) {
@@ -2189,6 +2190,7 @@
     ctxt->myDoc = NULL;
     ctxt->wellFormed = 1;
     ctxt->valid = 1;
+    ctxt->loadsubset = xmlLoadExtDtdDefaultValue;
     ctxt->validate = xmlDoValidityCheckingDefaultValue;
     ctxt->pedantic = xmlPedanticParserDefaultValue;
     ctxt->keepBlanks = xmlKeepBlanksDefaultValue;
diff --git a/parserInternals.h b/parserInternals.h
index b0dda64..c62b298 100644
--- a/parserInternals.h
+++ b/parserInternals.h
@@ -110,6 +110,7 @@
 LIBXML_DLL_IMPORT extern int xmlParserDebugEntities;
 LIBXML_DLL_IMPORT extern int xmlSubstituteEntitiesDefaultValue;
 LIBXML_DLL_IMPORT extern int xmlDoValidityCheckingDefaultValue;
+LIBXML_DLL_IMPORT extern int xmlLoadExtDtdDefaultValue;
 LIBXML_DLL_IMPORT extern int xmlPedanticParserDefaultValue;
 LIBXML_DLL_IMPORT extern int xmlKeepBlanksDefaultValue;
 LIBXML_DLL_IMPORT extern xmlChar xmlStringText[];
diff --git a/tree.c b/tree.c
index 0329544..851ae0b 100644
--- a/tree.c
+++ b/tree.c
@@ -2557,7 +2557,13 @@
 
     ret->doc = doc;
     ret->parent = parent; 
-    if (node->name != NULL)
+    if (node->name == xmlStringText)
+	ret->name = xmlStringText;
+    else if (node->name == xmlStringTextNoenc)
+	ret->name = xmlStringTextNoenc;
+    else if (node->name == xmlStringComment)
+	ret->name = xmlStringComment;
+    else if (node->name != NULL)
 	ret->name = xmlStrdup(node->name);
     if ((node->content != NULL) && (node->type != XML_ENTITY_REF_NODE)) {
 #ifndef XML_USE_BUFFER_CONTENT
diff --git a/xpath.c b/xpath.c
index 08ed5ac..fde7c3b 100644
--- a/xpath.c
+++ b/xpath.c
@@ -4190,6 +4190,7 @@
     if (cur == NULL) XP_ERROR(XPATH_INVALID_OPERAND);
     switch (cur->type) {
         case XPATH_NODESET:
+        case XPATH_XSLT_TREE:
 	    if ((cur->nodesetval == NULL) ||
 	        (cur->nodesetval->nodeNr == 0)) res = 0;
 	    else 
@@ -5419,7 +5420,9 @@
 	SKIP_BLANKS;
         xmlXPathEvalEqualityExpr(ctxt);
 	CHECK_ERROR;
+	xmlXPathBooleanFunction(ctxt, 1);
 	arg2 = valuePop(ctxt);
+	xmlXPathBooleanFunction(ctxt, 1);
 	arg1 = valuePop(ctxt);
 	arg1->boolval &= arg2->boolval;
 	valuePush(ctxt, arg1);
@@ -5451,7 +5454,9 @@
 	SKIP_BLANKS;
         xmlXPathEvalAndExpr(ctxt);
 	CHECK_ERROR;
+	xmlXPathBooleanFunction(ctxt, 1);
 	arg2 = valuePop(ctxt);
+	xmlXPathBooleanFunction(ctxt, 1);
 	arg1 = valuePop(ctxt);
 	arg1->boolval |= arg2->boolval;
 	valuePush(ctxt, arg1);