Commit 8606bbbc authored by Daniel Veillard's avatar Daniel Veillard
Browse files

fixed the initialization of the SAX structure which was breaking xsltproc

* parserInternals.c: fixed the initialization of the SAX structure
  which was breaking xsltproc
* xpath.c: patch from Petr Pajas for CDATA nodes
* tree.c: patch from Petr Pajas improving xmlGetNodePath()
* parser.c include/libxml/parser.h: patch from Peter Jones
  removing a leak in xmlSAXParseMemory() and adding the
  function xmlSAXParseMemoryWithData()
Daniel
parent f854d99f
Tue Nov 12 13:32:50 CET 2002 Daniel Veillard <daniel@veillard.com>
* parserInternals.c: fixed the initialization of the SAX structure
which was breaking xsltproc
* xpath.c: patch from Petr Pajas for CDATA nodes
* tree.c: patch from Petr Pajas improving xmlGetNodePath()
* parser.c include/libxml/parser.h: patch from Peter Jones
removing a leak in xmlSAXParseMemory() and adding the
function xmlSAXParseMemoryWithData()
Mon Nov 11 20:47:03 MST 2002 John Fleck <jfleck@inkstain.net>
adding pdf of tutorial, changing web page to link to it
......
......@@ -734,6 +734,11 @@ xmlDocPtr xmlSAXParseMemory (xmlSAXHandlerPtr sax,
const char *buffer,
int size,
int recovery);
xmlDocPtr xmlSAXParseMemoryWithData (xmlSAXHandlerPtr sax,
const char *buffer,
int size,
int recovery,
void *data);
xmlDocPtr xmlSAXParseFile (xmlSAXHandlerPtr sax,
const char *filename,
int recovery);
......
......@@ -10339,30 +10339,40 @@ xmlCreateMemoryParserCtxt(const char *buffer, int size) {
}
/**
* xmlSAXParseMemory:
* xmlSAXParseMemoryWithData:
* @sax: the SAX handler block
* @buffer: an pointer to a char array
* @size: the size of the array
* @recovery: work in recovery mode, i.e. tries to read not Well Formed
* @recovery: work in recovery mode, i.e. tries to read no Well Formed
* documents
* @data: the userdata
*
* parse an XML in-memory block and use the given SAX function block
* to handle the parsing callback. If sax is NULL, fallback to the default
* DOM tree building routines.
*
*
* User data (void *) is stored within the parser context in the
* context's _private member, so it is available nearly everywhere in libxml
*
* Returns the resulting document tree
*/
xmlDocPtr
xmlSAXParseMemory(xmlSAXHandlerPtr sax, const char *buffer,
int size, int recovery) {
xmlSAXParseMemoryWithData(xmlSAXHandlerPtr sax, const char *buffer,
int size, int recovery, void *data) {
xmlDocPtr ret;
xmlParserCtxtPtr ctxt;
ctxt = xmlCreateMemoryParserCtxt(buffer, size);
if (ctxt == NULL) return(NULL);
if (sax != NULL) {
if (ctxt->sax != NULL)
xmlFree(ctxt->sax);
ctxt->sax = sax;
}
if (data!=NULL) {
ctxt->_private=data;
}
xmlParseDocument(ctxt);
......@@ -10379,6 +10389,26 @@ xmlSAXParseMemory(xmlSAXHandlerPtr sax, const char *buffer,
return(ret);
}
/**
* xmlSAXParseMemory:
* @sax: the SAX handler block
* @buffer: an pointer to a char array
* @size: the size of the array
* @recovery: work in recovery mode, i.e. tries to read not Well Formed
* documents
*
* parse an XML in-memory block and use the given SAX function block
* to handle the parsing callback. If sax is NULL, fallback to the default
* DOM tree building routines.
*
* Returns the resulting document tree
*/
xmlDocPtr
xmlSAXParseMemory(xmlSAXHandlerPtr sax, const char *buffer,
int size, int recovery) {
return xmlSAXParseMemoryWithData(sax, buffer, size, recovery, NULL);
}
/**
* xmlParseMemory:
* @buffer: an pointer to a char array
......
......@@ -2250,7 +2250,7 @@ xmlInitParserCtxt(xmlParserCtxtPtr ctxt)
ctxt->space = &ctxt->spaceTab[0];
ctxt->sax = sax;
initxmlDefaultSAXHandler(sax, xmlGetWarningsDefaultValue);
memcpy(sax, &xmlDefaultSAXHandler, sizeof(xmlSAXHandler));
ctxt->userData = ctxt;
ctxt->myDoc = NULL;
......
......@@ -3493,8 +3493,9 @@ xmlGetNodePath(xmlNodePtr node)
}
if (occur == 0) {
tmp = cur->next;
while (tmp != NULL) {
if (xmlStrEqual(cur->name, tmp->name))
while (tmp != NULL && occur == 0) {
if ((tmp->type == XML_ELEMENT_NODE) &&
(xmlStrEqual(cur->name, tmp->name)))
occur++;
tmp = tmp->next;
}
......@@ -3502,6 +3503,91 @@ xmlGetNodePath(xmlNodePtr node)
occur = 1;
} else
occur++;
} else if (cur->type == XML_COMMENT_NODE) {
sep = "/";
name = "comment()";
next = cur->parent;
/*
* Thumbler index computation
*/
tmp = cur->prev;
while (tmp != NULL) {
if (tmp->type == XML_COMMENT_NODE)
occur++;
tmp = tmp->prev;
}
if (occur == 0) {
tmp = cur->next;
while (tmp != NULL && occur == 0) {
if (tmp->type == XML_COMMENT_NODE)
occur++;
tmp = tmp->next;
}
if (occur != 0)
occur = 1;
} else
occur++;
} else if ((cur->type == XML_TEXT_NODE) ||
(cur->type == XML_CDATA_SECTION_NODE)) {
sep = "/";
name = "text()";
next = cur->parent;
/*
* Thumbler index computation
*/
tmp = cur->prev;
while (tmp != NULL) {
if ((cur->type == XML_TEXT_NODE) ||
(cur->type == XML_CDATA_SECTION_NODE))
occur++;
tmp = tmp->prev;
}
if (occur == 0) {
tmp = cur->next;
while (tmp != NULL && occur == 0) {
if ((cur->type == XML_TEXT_NODE) ||
(cur->type == XML_CDATA_SECTION_NODE))
occur++;
tmp = tmp->next;
}
if (occur != 0)
occur = 1;
} else
occur++;
} else if (cur->type == XML_PI_NODE) {
sep = "/";
snprintf(nametemp, sizeof(nametemp) - 1,
"processing-instruction('%s')", cur->name);
nametemp[sizeof(nametemp) - 1] = 0;
name = nametemp;
next = cur->parent;
/*
* Thumbler index computation
*/
tmp = cur->prev;
while (tmp != NULL) {
if ((tmp->type == XML_PI_NODE) &&
(xmlStrEqual(cur->name, tmp->name)))
occur++;
tmp = tmp->prev;
}
if (occur == 0) {
tmp = cur->next;
while (tmp != NULL && occur == 0) {
if ((tmp->type == XML_PI_NODE) &&
(xmlStrEqual(cur->name, tmp->name)))
occur++;
tmp = tmp->next;
}
if (occur != 0)
occur = 1;
} else
occur++;
} else if (cur->type == XML_ATTRIBUTE_NODE) {
sep = "/@";
name = (const char *) (((xmlAttrPtr) cur)->name);
......
......@@ -9336,7 +9336,9 @@ xmlXPathNodeCollectAndTestNth(xmlXPathParserContextPtr ctxt,
(cur->type == XML_PI_NODE) ||
(cur->type == XML_COMMENT_NODE) ||
(cur->type == XML_CDATA_SECTION_NODE) ||
(cur->type == XML_TEXT_NODE)))) {
(cur->type == XML_TEXT_NODE))) ||
((type == NODE_TYPE_TEXT) &&
(cur->type == XML_CDATA_SECTION_NODE))) {
n++;
if (n == indx)
addNode(list, cur);
......
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