diff --git a/ChangeLog b/ChangeLog index b20ade87..27e83630 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +Mon Feb 5 18:51:36 CET 2001 Daniel Veillard + + * 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 * xmliO.c: Harry Blundell pointed out that xmlCheckFilename diff --git a/HTMLtree.c b/HTMLtree.c index 8e444b59..17fef14e 100644 --- a/HTMLtree.c +++ b/HTMLtree.c @@ -32,6 +32,7 @@ #include #include #include +#include /************************************************************************ * * @@ -460,17 +461,22 @@ htmlNodeDump(xmlBufferPtr buf, xmlDocPtr doc, xmlNodePtr cur) { } 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 @@ htmlNodeDumpOutput(xmlOutputBufferPtr buf, xmlDocPtr doc, xmlNodePtr cur, const } 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 8483c2fd..7fa94d64 100644 --- a/SAX.c +++ b/SAX.c @@ -200,7 +200,8 @@ externalSubset(void *ctx, const xmlChar *name, 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 95e529d2..b98f2a33 100644 --- a/include/libxml/parser.h +++ b/include/libxml/parser.h @@ -185,6 +185,8 @@ struct _xmlParserCtxt { 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 b0dda648..c62b298c 100644 --- a/include/libxml/parserInternals.h +++ b/include/libxml/parserInternals.h @@ -110,6 +110,7 @@ LIBXML_DLL_IMPORT extern int xmlGetWarningsDefaultValue; 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 7d972511..d46a9b14 100644 --- a/parser.c +++ b/parser.c @@ -92,6 +92,7 @@ int xmlDoValidityCheckingDefaultVal = 0; int xmlSubstituteEntitiesDefaultValue = 0; int xmlDoValidityCheckingDefaultValue = 0; #endif +int xmlLoadExtDtdDefaultValue = 0; int xmlPedanticParserDefaultValue = 0; int xmlKeepBlanksDefaultValue = 1; @@ -7211,6 +7212,7 @@ xmlParseExtParsedEnt(xmlParserCtxtPtr ctxt) { */ ctxt->instate = XML_PARSER_CONTENT; ctxt->validate = 0; + ctxt->loadsubset = 0; ctxt->depth = 0; xmlParseContent(ctxt); @@ -8750,6 +8752,7 @@ xmlParseCtxtExternalEntity(xmlParserCtxtPtr ctx, const xmlChar *URL, */ 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 @@ xmlParseExternalEntity(xmlDocPtr doc, xmlSAXHandlerPtr sax, void *user_data, */ ctxt->instate = XML_PARSER_CONTENT; ctxt->validate = 0; + ctxt->loadsubset = 0; ctxt->depth = depth; xmlParseContent(ctxt); @@ -9071,6 +9075,7 @@ xmlParseBalancedChunkMemory(xmlDocPtr doc, xmlSAXHandlerPtr sax, * 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 95e529d2..b98f2a33 100644 --- a/parser.h +++ b/parser.h @@ -185,6 +185,8 @@ struct _xmlParserCtxt { 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 37e3c7be..f99ed4e4 100644 --- a/parserInternals.c +++ b/parserInternals.c @@ -83,6 +83,7 @@ xmlCheckVersion(int version) { const char *xmlFeaturesList[] = { "validate", + "load subset", "keep blanks", "disable SAX", "fetch external entities", @@ -174,7 +175,7 @@ xmlGetFeature(xmlParserCtxtPtr ctxt, const char *name, void *result) { } 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 @@ xmlSetFeature(xmlParserCtxtPtr ctxt, const char *name, void *value) { 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 @@ xmlSetFeature(xmlParserCtxtPtr ctxt, const char *name, void *value) { 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 @@ xmlInitParserCtxt(xmlParserCtxtPtr ctxt) 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 b0dda648..c62b298c 100644 --- a/parserInternals.h +++ b/parserInternals.h @@ -110,6 +110,7 @@ LIBXML_DLL_IMPORT extern int xmlGetWarningsDefaultValue; 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 03295445..851ae0bb 100644 --- a/tree.c +++ b/tree.c @@ -2557,7 +2557,13 @@ xmlStaticCopyNode(xmlNodePtr node, xmlDocPtr doc, xmlNodePtr parent, 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 08ed5ac4..fde7c3ba 100644 --- a/xpath.c +++ b/xpath.c @@ -4190,6 +4190,7 @@ xmlXPathBooleanFunction(xmlXPathParserContextPtr ctxt, int nargs) { 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 @@ xmlXPathEvalAndExpr(xmlXPathParserContextPtr ctxt) { 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 @@ xmlXPathEvalExpr(xmlXPathParserContextPtr ctxt) { 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);