Commit 8de5c0bd authored by Daniel Veillard's avatar Daniel Veillard

adding the tree debug mode fixing various problems reported by the debug

* debugXML.c include/libxml/debugXML.h include/libxml/xmlerror.h:
  adding the tree debug mode
* parser.c relaxng.c tree.c xpath.c: fixing various problems reported
  by the debug mode.
* SAX2.c: another tree fix from Rob Richards
Daniel
parent 181a1ca0
Thu Oct 7 15:12:58 CEST 2004 Daniel Veillard <daniel@veillard.com>
* debugXML.c include/libxml/debugXML.h include/libxml/xmlerror.h:
adding the tree debug mode
* parser.c relaxng.c tree.c xpath.c: fixing various problems reported
by the debug mode.
* SAX2.c: another tree fix from Rob Richards
Wed Oct 6 10:50:03 PDT 2004 William Brack <wbrack@mmm.com.hk>
* catalog.c: small change to last fix, to get xml:base right
......
......@@ -1824,6 +1824,7 @@ xmlSAX2AttributeNs(xmlParserCtxtPtr ctxt,
valueend - value);
tmp = ret->children;
while (tmp != NULL) {
tmp->doc = ret->doc;
tmp->parent = (xmlNodePtr) ret;
if (tmp->next == NULL)
ret->last = tmp;
......
This diff is collapsed.
......@@ -61,6 +61,22 @@ XMLPUBFUN void XMLCALL
xmlDebugDumpEntities (FILE *output,
xmlDocPtr doc);
/****************************************************************
* *
* Checking routines *
* *
****************************************************************/
XMLPUBFUN int XMLCALL
xmlDebugCheckDocument (FILE * output,
xmlDocPtr doc);
/****************************************************************
* *
* XML shell helpers *
* *
****************************************************************/
XMLPUBFUN void XMLCALL
xmlLsOneNode (FILE *output, xmlNodePtr node);
XMLPUBFUN int XMLCALL
......
......@@ -57,7 +57,8 @@ typedef enum {
XML_FROM_CATALOG, /* The Catalog module */
XML_FROM_C14N, /* The Canonicalization module */
XML_FROM_XSLT, /* The XSLT engine from libxslt */
XML_FROM_VALID /* The XML DTD validation with valid context */
XML_FROM_VALID, /* The XML DTD validation with valid context */
XML_FROM_CHECK /* The error checking module */
} xmlErrorDomain;
/**
......@@ -743,7 +744,44 @@ typedef enum {
XML_SCHEMAP_SRC_CT_1, /* 3076 */
XML_SCHEMAP_DERIVATION_OK_RESTRICTION_2_1_3, /* 3077 */
XML_SCHEMAP_AU_PROPS_CORRECT_2, /* 3078 */
XML_SCHEMAP_A_PROPS_CORRECT_2
XML_SCHEMAP_A_PROPS_CORRECT_2, /* 3079 */
XML_CHECK_FOUND_ELEMENT = 5000,
XML_CHECK_FOUND_ATTRIBUTE, /* 5001 */
XML_CHECK_FOUND_TEXT, /* 5002 */
XML_CHECK_FOUND_CDATA, /* 5003 */
XML_CHECK_FOUND_ENTITYREF, /* 5004 */
XML_CHECK_FOUND_ENTITY, /* 5005 */
XML_CHECK_FOUND_PI, /* 5006 */
XML_CHECK_FOUND_COMMENT, /* 5007 */
XML_CHECK_FOUND_DOCTYPE, /* 5008 */
XML_CHECK_FOUND_FRAGMENT, /* 5009 */
XML_CHECK_FOUND_NOTATION, /* 5010 */
XML_CHECK_UNKNOWN_NODE, /* 5011 */
XML_CHECK_ENTITY_TYPE, /* 5012 */
XML_CHECK_NO_PARENT, /* 5013 */
XML_CHECK_NO_DOC, /* 5014 */
XML_CHECK_NO_NAME, /* 5015 */
XML_CHECK_NO_ELEM, /* 5016 */
XML_CHECK_WRONG_DOC, /* 5017 */
XML_CHECK_NO_PREV, /* 5018 */
XML_CHECK_WRONG_PREV, /* 5019 */
XML_CHECK_NO_NEXT, /* 5020 */
XML_CHECK_WRONG_NEXT, /* 5021 */
XML_CHECK_NOT_DTD, /* 5022 */
XML_CHECK_NOT_ATTR, /* 5023 */
XML_CHECK_NOT_ATTR_DECL, /* 5024 */
XML_CHECK_NOT_ELEM_DECL, /* 5025 */
XML_CHECK_NOT_ENTITY_DECL, /* 5026 */
XML_CHECK_NOT_NS_DECL, /* 5027 */
XML_CHECK_NO_HREF, /* 5028 */
XML_CHECK_ /* 5029 */
#if 0
XML_CHECK_, /* 5030 */
XML_CHECK_, /* 5031 */
XML_CHECK_, /* 5032 */
XML_CHECK_, /* 5033 */
XML_CHECK_X /* 503 */
#endif
} xmlParserErrors;
/**
......
......@@ -10336,6 +10336,7 @@ xmlParseCtxtExternalEntity(xmlParserCtxtPtr ctx, const xmlChar *URL,
const xmlChar *ID, xmlNodePtr *lst) {
xmlParserCtxtPtr ctxt;
xmlDocPtr newDoc;
xmlNodePtr newRoot;
xmlSAXHandlerPtr oldsax = NULL;
int ret = 0;
xmlChar start[4];
......@@ -10372,8 +10373,8 @@ xmlParseCtxtExternalEntity(xmlParserCtxtPtr ctx, const xmlChar *URL,
if (ctx->myDoc->URL != NULL) {
newDoc->URL = xmlStrdup(ctx->myDoc->URL);
}
newDoc->children = xmlNewDocNode(newDoc, NULL, BAD_CAST "pseudoroot", NULL);
if (newDoc->children == NULL) {
newRoot = xmlNewDocNode(newDoc, NULL, BAD_CAST "pseudoroot", NULL);
if (newRoot == NULL) {
ctxt->sax = oldsax;
xmlFreeParserCtxt(ctxt);
newDoc->intSubset = NULL;
......@@ -10381,6 +10382,7 @@ xmlParseCtxtExternalEntity(xmlParserCtxtPtr ctx, const xmlChar *URL,
xmlFreeDoc(newDoc);
return(-1);
}
xmlAddChild((xmlNodePtr) newDoc, newRoot);
nodePush(ctxt, newDoc->children);
if (ctx->myDoc == NULL) {
ctxt->myDoc = newDoc;
......@@ -10515,6 +10517,7 @@ xmlParseExternalEntityPrivate(xmlDocPtr doc, xmlParserCtxtPtr oldctxt,
const xmlChar *ID, xmlNodePtr *list) {
xmlParserCtxtPtr ctxt;
xmlDocPtr newDoc;
xmlNodePtr newRoot;
xmlSAXHandlerPtr oldsax = NULL;
xmlParserErrors ret = XML_ERR_OK;
xmlChar start[4];
......@@ -10578,8 +10581,8 @@ xmlParseExternalEntityPrivate(xmlDocPtr doc, xmlParserCtxtPtr oldctxt,
if (doc->URL != NULL) {
newDoc->URL = xmlStrdup(doc->URL);
}
newDoc->children = xmlNewDocNode(newDoc, NULL, BAD_CAST "pseudoroot", NULL);
if (newDoc->children == NULL) {
newRoot = xmlNewDocNode(newDoc, NULL, BAD_CAST "pseudoroot", NULL);
if (newRoot == NULL) {
if (sax != NULL)
ctxt->sax = oldsax;
ctxt->node_seq.maximum = 0;
......@@ -10591,12 +10594,13 @@ xmlParseExternalEntityPrivate(xmlDocPtr doc, xmlParserCtxtPtr oldctxt,
xmlFreeDoc(newDoc);
return(XML_ERR_INTERNAL_ERROR);
}
xmlAddChild((xmlNodePtr) newDoc, newRoot);
nodePush(ctxt, newDoc->children);
if (doc == NULL) {
ctxt->myDoc = newDoc;
} else {
ctxt->myDoc = doc;
newDoc->children->doc = doc;
newRoot->doc = doc;
}
/*
......@@ -10758,8 +10762,10 @@ xmlParseBalancedChunkMemoryInternal(xmlParserCtxtPtr oldctxt,
const xmlChar *string, void *user_data, xmlNodePtr *lst) {
xmlParserCtxtPtr ctxt;
xmlDocPtr newDoc = NULL;
xmlNodePtr newRoot;
xmlSAXHandlerPtr oldsax = NULL;
xmlNodePtr content = NULL;
xmlNodePtr last = NULL;
int size;
xmlParserErrors ret = XML_ERR_OK;
......@@ -10806,10 +10812,10 @@ xmlParseBalancedChunkMemoryInternal(xmlParserCtxtPtr oldctxt,
} else {
ctxt->myDoc = oldctxt->myDoc;
content = ctxt->myDoc->children;
last = ctxt->myDoc->last;
}
ctxt->myDoc->children = xmlNewDocNode(ctxt->myDoc, NULL,
BAD_CAST "pseudoroot", NULL);
if (ctxt->myDoc->children == NULL) {
newRoot = xmlNewDocNode(ctxt->myDoc, NULL, BAD_CAST "pseudoroot", NULL);
if (newRoot == NULL) {
ctxt->sax = oldsax;
ctxt->dict = NULL;
xmlFreeParserCtxt(ctxt);
......@@ -10817,6 +10823,9 @@ xmlParseBalancedChunkMemoryInternal(xmlParserCtxtPtr oldctxt,
xmlFreeDoc(newDoc);
return(XML_ERR_INTERNAL_ERROR);
}
ctxt->myDoc->children = NULL;
ctxt->myDoc->last = NULL;
xmlAddChild((xmlNodePtr) ctxt->myDoc, newRoot);
nodePush(ctxt, ctxt->myDoc->children);
ctxt->instate = XML_PARSER_CONTENT;
ctxt->depth = oldctxt->depth + 1;
......@@ -10877,6 +10886,7 @@ xmlParseBalancedChunkMemoryInternal(xmlParserCtxtPtr oldctxt,
if (ctxt->myDoc != NULL) {
xmlFreeNode(ctxt->myDoc->children);
ctxt->myDoc->children = content;
ctxt->myDoc->last = last;
}
ctxt->sax = oldsax;
......
......@@ -6749,7 +6749,7 @@ xmlRelaxNGNormExtSpace(xmlChar * value)
}
/**
* xmlRelaxNGCheckAttributes:
* xmlRelaxNGCleanupAttributes:
* @ctxt: a Relax-NG parser context
* @node: a Relax-NG node
*
......
......@@ -1119,6 +1119,10 @@ xmlFreeDoc(xmlDocPtr cur) {
#endif
return;
}
#ifdef LIBXML_DEBUG_RUNTIME
xmlDebugCheckDocument(stderr, cur);
#endif
if (cur != NULL) dict = cur->dict;
if ((__xmlRegisterCallbacks) && (xmlDeregisterNodeDefaultValue))
......@@ -1302,6 +1306,7 @@ xmlStringLenGetNodeList(xmlDocPtr doc, const xmlChar *value, int len) {
temp = ent->children;
while (temp) {
temp->parent = (xmlNodePtr)ent;
ent->last = temp;
temp = temp->next;
}
}
......@@ -4414,7 +4419,7 @@ xmlDocSetRootElement(xmlDocPtr doc, xmlNodePtr root) {
if (root == NULL)
return(NULL);
xmlUnlinkNode(root);
root->doc = doc;
xmlSetTreeDoc(root, doc);
root->parent = (xmlNodePtr) doc;
old = doc->children;
while (old != NULL) {
......@@ -6207,10 +6212,17 @@ xmlUnsetProp(xmlNodePtr node, const xmlChar *name) {
while (prop != NULL) {
if ((xmlStrEqual(prop->name, name)) &&
(prop->ns == NULL)) {
if (prev == NULL)
if (prev == NULL) {
node->properties = prop->next;
else
if (prop->next != NULL)
prop->next->prev = NULL;
} else {
prev->next = prop->next;
if (prop->next != NULL)
prop->next->prev = NULL;
}
prop->next = NULL;
prop->prev = NULL;
xmlFreeProp(prop);
return(0);
}
......@@ -6242,10 +6254,17 @@ xmlUnsetNsProp(xmlNodePtr node, xmlNsPtr ns, const xmlChar *name) {
while (prop != NULL) {
if ((xmlStrEqual(prop->name, name)) &&
(prop->ns != NULL) && (xmlStrEqual(prop->ns->href, ns->href))) {
if (prev == NULL)
if (prev == NULL) {
node->properties = prop->next;
else
if (prop->next != NULL)
prop->next->prev = NULL;
} else {
prev->next = prop->next;
if (prop->next != NULL)
prop->next->prev = NULL;
}
prop->next = NULL;
prop->prev = NULL;
xmlFreeProp(prop);
return(0);
}
......
......@@ -254,7 +254,7 @@ xmlXPathErrMemory(xmlXPathContextPtr ctxt, const char *extra)
}
/**
* xmlXPathErrMemory:
* xmlXPathPErrMemory:
* @ctxt: an XPath parser context
* @extra: extra informations
*
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment