1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-08-08 17:42:14 +03:00

integrated a couple of fixes and a new API function

* parser.c include/libxml/parserInternals.h tree.c: integrated
  a couple of fixes and a new API function xmlSetEntityReferenceFunc()
  from Keith Isdale and dedicated to xsldbg the XSLT debugger.
Daniel
This commit is contained in:
Daniel Veillard
2002-01-13 14:10:10 +00:00
parent db0eb8df5a
commit 8107a22f96
4 changed files with 78 additions and 4 deletions

View File

@@ -1,3 +1,9 @@
Sun Jan 13 15:07:49 CET 2002 Daniel Veillard <daniel@veillard.com>
* parser.c include/libxml/parserInternals.h tree.c: integrated
a couple of fixes and a new API function xmlSetEntityReferenceFunc()
from Keith Isdale and dedicated to xsldbg the XSLT debugger.
Sun Jan 13 14:23:21 CET 2002 Daniel Veillard <daniel@veillard.com> Sun Jan 13 14:23:21 CET 2002 Daniel Veillard <daniel@veillard.com>
* threads.c: applied Serguei Narojnyi's patch to add native * threads.c: applied Serguei Narojnyi's patch to add native

View File

@@ -394,6 +394,18 @@ void xmlParserInputShrink (xmlParserInputPtr in);
void htmlInitAutoClose (void); void htmlInitAutoClose (void);
htmlParserCtxtPtr htmlCreateFileParserCtxt(const char *filename, htmlParserCtxtPtr htmlCreateFileParserCtxt(const char *filename,
const char *encoding); const char *encoding);
/*
* Specific function to keep track of entities references
* and used by the XSLT debugger
*/
typedef void (*xmlEntityReferenceFunc) (xmlEntityPtr ent,
xmlNodePtr firstNode,
xmlNodePtr lastNode);
void xmlSetEntityReferenceFunc (xmlEntityReferenceFunc func);
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@@ -99,6 +99,10 @@ xmlParseExternalEntityPrivate(xmlDocPtr doc, xmlParserCtxtPtr oldctxt,
void *user_data, int depth, const xmlChar *URL, void *user_data, int depth, const xmlChar *URL,
const xmlChar *ID, xmlNodePtr *list); const xmlChar *ID, xmlNodePtr *list);
static void
xmlAddEntityReference(xmlEntityPtr ent, xmlNodePtr firstNode,
xmlNodePtr lastNode);
/************************************************************************ /************************************************************************
* * * *
* Parser stacks related functions and macros * * Parser stacks related functions and macros *
@@ -5256,6 +5260,8 @@ xmlParseReference(xmlParserCtxtPtr ctxt) {
list = list->next; list = list->next;
} }
list = ent->children; list = ent->children;
if (ent->etype == XML_EXTERNAL_GENERAL_PARSED_ENTITY)
xmlAddEntityReference(ent, list, NULL);
} }
} else { } else {
while (list != NULL) { while (list != NULL) {
@@ -5297,15 +5303,20 @@ xmlParseReference(xmlParserCtxtPtr ctxt) {
* In the first occurrence list contains the replacement * In the first occurrence list contains the replacement
*/ */
if (list == NULL) { if (list == NULL) {
xmlNodePtr new, cur; xmlNodePtr new = NULL, cur, firstChild = NULL;
cur = ent->children; cur = ent->children;
while (cur != NULL) { while (cur != NULL) {
new = xmlCopyNode(cur, 1); new = xmlCopyNode(cur, 1);
if (firstChild == NULL){
firstChild = new;
}
xmlAddChild(ctxt->node, new); xmlAddChild(ctxt->node, new);
if (cur == ent->last) if (cur == ent->last)
break; break;
cur = cur->next; cur = cur->next;
} }
if (ent->etype == XML_EXTERNAL_GENERAL_PARSED_ENTITY)
xmlAddEntityReference(ent, firstChild, new);
} else { } else {
/* /*
* the name change is to avoid coalescing of the * the name change is to avoid coalescing of the
@@ -10226,6 +10237,44 @@ xmlParseDoc(xmlChar *cur) {
return(xmlSAXParseDoc(NULL, cur, 0)); return(xmlSAXParseDoc(NULL, cur, 0));
} }
/************************************************************************
* *
* Specific function to keep track of entities references *
* and used by the XSLT debugger *
* *
************************************************************************/
static xmlEntityReferenceFunc xmlEntityRefFunc = NULL;
/**
* xmlAddEntityReference:
* @ent : A valid entity
* @firstNode : A valid first node for children of entity
* @lastNode : A valid last node of children entity
*
* Notify of a reference to an entity of type XML_EXTERNAL_GENERAL_PARSED_ENTITY
*/
static void
xmlAddEntityReference(xmlEntityPtr ent, xmlNodePtr firstNode,
xmlNodePtr lastNode)
{
if (xmlEntityRefFunc != NULL) {
(*xmlEntityRefFunc) (ent, firstNode, lastNode);
}
}
/**
* xmlSetEntityReferenceFunc:
* @func : A valid function
*
* Set the function to call call back when a xml reference has been made
*/
void
xmlSetEntityReferenceFunc(xmlEntityReferenceFunc func)
{
xmlEntityRefFunc = func;
}
/************************************************************************ /************************************************************************
* * * *

9
tree.c
View File

@@ -2643,8 +2643,12 @@ xmlCopyProp(xmlNodePtr target, xmlAttrPtr cur) {
if ((cur->ns != NULL) && (target != NULL)) { if ((cur->ns != NULL) && (target != NULL)) {
xmlNsPtr ns; xmlNsPtr ns;
if (target->doc)
ns = xmlSearchNs(target->doc, target, cur->ns->prefix); ns = xmlSearchNs(target->doc, target, cur->ns->prefix);
else if (cur->doc) /* target may not yet have a doc : KPI */
ns = xmlSearchNs(cur->doc, target, cur->ns->prefix);
else
ns = NULL;
ret->ns = ns; ret->ns = ns;
} else } else
ret->ns = NULL; ret->ns = NULL;
@@ -2786,6 +2790,9 @@ xmlStaticCopyNode(const xmlNodePtr node, xmlDocPtr doc, xmlNodePtr parent,
xmlBufferContent(node->content), xmlBufferContent(node->content),
xmlBufferLength(node->content)); xmlBufferLength(node->content));
#endif #endif
}else{
if (node->type == XML_ELEMENT_NODE)
ret->content = (void*)(long) node->content;
} }
if (parent != NULL) if (parent != NULL)
xmlAddChild(parent, ret); xmlAddChild(parent, ret);