Commit 68e9e74a authored by Daniel Veillard's avatar Daniel Veillard
Browse files

fixing #96925 wich was also dependant on the processing of parsed

* parser.c xpath.c: fixing #96925 wich was also dependant on the
  processing of parsed entities, and XPath computation on sustitued
  entities.
* testXPath.c: make sure entities are substitued.
Daniel
parent 328f48c1
Sat Nov 16 16:30:25 CET 2002 Daniel Veillard <daniel@veillard.com>
* parser.c xpath.c: fixing #96925 wich was also dependant on the
processing of parsed entities, and XPath computation on sustitued
entities.
* testXPath.c: make sure entities are substitued.
Fri Nov 15 16:22:54 CET 2002 Daniel Veillard <daniel@veillard.com>
* parser.c: fixed #96594, which was totally dependant on the
......
......@@ -5456,6 +5456,7 @@ xmlParseReference(xmlParserCtxtPtr ctxt) {
} else {
while (list != NULL) {
list->parent = (xmlNodePtr) ctxt->node;
list->doc = ctxt->myDoc;
if (list->next == NULL)
ent->last = list;
list = list->next;
......@@ -9767,9 +9768,9 @@ static int
xmlParseBalancedChunkMemoryInternal(xmlParserCtxtPtr oldctxt,
const xmlChar *string, void *user_data, xmlNodePtr *lst) {
xmlParserCtxtPtr ctxt;
xmlDocPtr newDoc;
xmlDocPtr newDoc = NULL;
xmlSAXHandlerPtr oldsax = NULL;
xmlNodePtr content;
xmlNodePtr content = NULL;
int size;
int ret = 0;
......@@ -9794,32 +9795,28 @@ xmlParseBalancedChunkMemoryInternal(xmlParserCtxtPtr oldctxt,
oldsax = ctxt->sax;
ctxt->sax = oldctxt->sax;
newDoc = xmlNewDoc(BAD_CAST "1.0");
if (newDoc == NULL) {
ctxt->sax = oldsax;
xmlFreeParserCtxt(ctxt);
return(-1);
}
if (oldctxt->myDoc != NULL) {
newDoc->intSubset = oldctxt->myDoc->intSubset;
newDoc->extSubset = oldctxt->myDoc->extSubset;
if (oldctxt->myDoc == NULL) {
newDoc = xmlNewDoc(BAD_CAST "1.0");
if (newDoc == NULL) {
ctxt->sax = oldsax;
xmlFreeParserCtxt(ctxt);
return(-1);
}
ctxt->myDoc = newDoc;
} else {
ctxt->myDoc = oldctxt->myDoc;
content = ctxt->myDoc->children;
}
newDoc->children = xmlNewDocNode(newDoc, NULL, BAD_CAST "pseudoroot", NULL);
if (newDoc->children == NULL) {
ctxt->myDoc->children = xmlNewDocNode(newDoc, NULL,
BAD_CAST "pseudoroot", NULL);
if (ctxt->myDoc->children == NULL) {
ctxt->sax = oldsax;
xmlFreeParserCtxt(ctxt);
newDoc->intSubset = NULL;
newDoc->extSubset = NULL;
xmlFreeDoc(newDoc);
if (newDoc != NULL)
xmlFreeDoc(newDoc);
return(-1);
}
nodePush(ctxt, newDoc->children);
if (oldctxt->myDoc == NULL) {
ctxt->myDoc = oldctxt->myDoc;
} else {
ctxt->myDoc = newDoc;
newDoc->children->doc = newDoc;
}
nodePush(ctxt, ctxt->myDoc->children);
ctxt->instate = XML_PARSER_CONTENT;
ctxt->depth = oldctxt->depth + 1;
......@@ -9829,14 +9826,7 @@ xmlParseBalancedChunkMemoryInternal(xmlParserCtxtPtr oldctxt,
ctxt->validate = 0;
ctxt->loadsubset = oldctxt->loadsubset;
if (ctxt->myDoc != NULL) {
content = ctxt->myDoc->children;
ctxt->myDoc->children = NULL;
xmlParseContent(ctxt);
ctxt->myDoc->children = content;
} else {
xmlParseContent(ctxt);
}
xmlParseContent(ctxt);
if ((RAW == '<') && (NXT(1) == '/')) {
ctxt->errNo = XML_ERR_NOT_WELL_BALANCED;
if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL))
......@@ -9852,7 +9842,7 @@ xmlParseBalancedChunkMemoryInternal(xmlParserCtxtPtr oldctxt,
ctxt->wellFormed = 0;
ctxt->disableSAX = 1;
}
if (ctxt->node != newDoc->children) {
if (ctxt->node != ctxt->myDoc->children) {
ctxt->errNo = XML_ERR_NOT_WELL_BALANCED;
if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL))
ctxt->sax->error(ctxt->userData,
......@@ -9877,20 +9867,23 @@ xmlParseBalancedChunkMemoryInternal(xmlParserCtxtPtr oldctxt,
* Return the newly created nodeset after unlinking it from
* they pseudo parent.
*/
cur = newDoc->children->children;
cur = ctxt->myDoc->children->children;
*lst = cur;
while (cur != NULL) {
cur->parent = NULL;
cur = cur->next;
}
newDoc->children->children = NULL;
ctxt->myDoc->children->children = NULL;
}
if (ctxt->myDoc != NULL) {
xmlFreeNode(ctxt->myDoc->children);
ctxt->myDoc->children = content;
}
ctxt->sax = oldsax;
xmlFreeParserCtxt(ctxt);
newDoc->intSubset = NULL;
newDoc->extSubset = NULL;
xmlFreeDoc(newDoc);
if (newDoc != NULL)
xmlFreeDoc(newDoc);
return(ret);
}
......
......@@ -171,6 +171,7 @@ int main(int argc, char **argv) {
if (valid != 0) xmlDoValidityCheckingDefaultValue = 1;
xmlLoadExtDtdDefaultValue |= XML_DETECT_IDS;
xmlLoadExtDtdDefaultValue |= XML_COMPLETE_ATTRS;
xmlSubstituteEntitiesDefaultValue = 1;
if (nocdata != 0) {
xmlDefaultSAXHandlerInit();
xmlDefaultSAXHandler.cdataBlock = NULL;
......
......@@ -1367,6 +1367,10 @@ xmlXPathCmpNodes(xmlNodePtr node1, xmlNodePtr node2) {
if (node1 == node2->next)
return(-1);
#if 0
Unfortunately this does not work. Line number in entities reset
to 1 within the entity :-(
/*
* Speedup using line numbers if availble.
*/
......@@ -1381,7 +1385,7 @@ xmlXPathCmpNodes(xmlNodePtr node1, xmlNodePtr node2) {
if (l1 > l2)
return(-1);
}
#endif
/*
* compute depth to root
*/
......@@ -5169,13 +5173,27 @@ xmlXPathNextDescendant(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) {
}
if (cur->children != NULL) {
if (cur->children->type != XML_ENTITY_DECL)
return(cur->children);
/*
* Do not descend on entities declarations
*/
if (cur->children->type != XML_ENTITY_DECL) {
cur = cur->children;
/*
* Skip DTDs
*/
if (cur->type != XML_DTD_NODE)
return(cur);
}
}
if (cur == ctxt->context->node) return(NULL);
if (cur->next != NULL) return(cur->next);
while (cur->next != NULL) {
cur = cur->next;
if ((cur->type != XML_ENTITY_DECL) &&
(cur->type != XML_DTD_NODE))
return(cur);
}
do {
cur = cur->parent;
......
Supports Markdown
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