diff --git a/ChangeLog b/ChangeLog index d08503da..db91021d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Sun Jan 13 15:07:49 CET 2002 Daniel Veillard + + * 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 * threads.c: applied Serguei Narojnyi's patch to add native diff --git a/include/libxml/parserInternals.h b/include/libxml/parserInternals.h index 490f9f6b..ae23d27c 100644 --- a/include/libxml/parserInternals.h +++ b/include/libxml/parserInternals.h @@ -394,6 +394,18 @@ void xmlParserInputShrink (xmlParserInputPtr in); void htmlInitAutoClose (void); htmlParserCtxtPtr htmlCreateFileParserCtxt(const char *filename, 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 #ifdef __cplusplus } diff --git a/parser.c b/parser.c index 8122e199..f7164188 100644 --- a/parser.c +++ b/parser.c @@ -99,6 +99,10 @@ xmlParseExternalEntityPrivate(xmlDocPtr doc, xmlParserCtxtPtr oldctxt, void *user_data, int depth, const xmlChar *URL, const xmlChar *ID, xmlNodePtr *list); +static void +xmlAddEntityReference(xmlEntityPtr ent, xmlNodePtr firstNode, + xmlNodePtr lastNode); + /************************************************************************ * * * Parser stacks related functions and macros * @@ -5254,8 +5258,10 @@ xmlParseReference(xmlParserCtxtPtr ctxt) { if (list->next == NULL) ent->last = list; list = list->next; - } + } list = ent->children; + if (ent->etype == XML_EXTERNAL_GENERAL_PARSED_ENTITY) + xmlAddEntityReference(ent, list, NULL); } } else { while (list != NULL) { @@ -5297,15 +5303,20 @@ xmlParseReference(xmlParserCtxtPtr ctxt) { * In the first occurrence list contains the replacement */ if (list == NULL) { - xmlNodePtr new, cur; + xmlNodePtr new = NULL, cur, firstChild = NULL; cur = ent->children; while (cur != NULL) { new = xmlCopyNode(cur, 1); + if (firstChild == NULL){ + firstChild = new; + } xmlAddChild(ctxt->node, new); if (cur == ent->last) break; cur = cur->next; } + if (ent->etype == XML_EXTERNAL_GENERAL_PARSED_ENTITY) + xmlAddEntityReference(ent, firstChild, new); } else { /* * the name change is to avoid coalescing of the @@ -10226,6 +10237,44 @@ xmlParseDoc(xmlChar *cur) { 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; +} /************************************************************************ * * diff --git a/tree.c b/tree.c index feabe8bf..28f4490e 100644 --- a/tree.c +++ b/tree.c @@ -2642,9 +2642,13 @@ xmlCopyProp(xmlNodePtr target, xmlAttrPtr cur) { ret->parent = target; if ((cur->ns != NULL) && (target != NULL)) { - xmlNsPtr ns; - + xmlNsPtr ns; + if (target->doc) 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; } else ret->ns = NULL; @@ -2786,6 +2790,9 @@ xmlStaticCopyNode(const xmlNodePtr node, xmlDocPtr doc, xmlNodePtr parent, xmlBufferContent(node->content), xmlBufferLength(node->content)); #endif + }else{ + if (node->type == XML_ELEMENT_NODE) + ret->content = (void*)(long) node->content; } if (parent != NULL) xmlAddChild(parent, ret);