1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2024-10-26 20:25:14 +03:00

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
This commit is contained in:
Daniel Veillard 2001-02-05 17:57:33 +00:00
parent 2c833b6678
commit 0f2a53ccbd
11 changed files with 72 additions and 26 deletions

View File

@ -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

View File

@ -32,6 +32,7 @@
#include <libxml/entities.h>
#include <libxml/valid.h>
#include <libxml/xmlerror.h>
#include <libxml/parserInternals.h>
/************************************************************************
* *
@ -460,6 +461,8 @@ htmlNodeDump(xmlBufferPtr buf, xmlDocPtr doc, xmlNodePtr cur) {
}
if (cur->type == HTML_TEXT_NODE) {
if (cur->content != NULL) {
if ((cur->name == xmlStringText) ||
(cur->name != xmlStringTextNoenc)) {
xmlChar *buffer;
#ifndef XML_USE_BUFFER_CONTENT
@ -472,6 +475,9 @@ htmlNodeDump(xmlBufferPtr buf, xmlDocPtr doc, xmlNodePtr cur) {
xmlBufferWriteCHAR(buf, buffer);
xmlFree(buffer);
}
} else {
xmlBufferWriteCHAR(buf, cur->content);
}
}
return;
}
@ -794,6 +800,8 @@ htmlNodeDumpOutput(xmlOutputBufferPtr buf, xmlDocPtr doc, xmlNodePtr cur, const
}
if (cur->type == HTML_TEXT_NODE) {
if (cur->content != NULL) {
if ((cur->name == xmlStringText) ||
(cur->name != xmlStringTextNoenc)) {
xmlChar *buffer;
#ifndef XML_USE_BUFFER_CONTENT
@ -806,6 +814,9 @@ htmlNodeDumpOutput(xmlOutputBufferPtr buf, xmlDocPtr doc, xmlNodePtr cur, const
xmlOutputBufferWriteString(buf, (const char *)buffer);
xmlFree(buffer);
}
} else {
xmlOutputBufferWriteString(buf, (const char *)cur->content);
}
}
return;
}

3
SAX.c
View File

@ -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.
*/

View File

@ -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 */
};
/**

View File

@ -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[];

View File

@ -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);

View File

@ -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 */
};
/**

View File

@ -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;

View File

@ -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[];

8
tree.c
View File

@ -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

View File

@ -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);