diff options
author | Daniel Veillard <veillard@src.gnome.org> | 2001-11-30 12:01:25 +0000 |
---|---|---|
committer | Daniel Veillard <veillard@src.gnome.org> | 2001-11-30 12:01:25 +0000 |
commit | 3efba7ccbf6169354e695619c6a315166b84e854 (patch) | |
tree | 22c1aa6910060d86c459094e6239d8c9b27d9ea3 | |
parent | b95c91c67baeb3855462eef215cb8a196a287943 (diff) | |
download | libxslt-3efba7ccbf6169354e695619c6a315166b84e854.tar.gz libxslt-3efba7ccbf6169354e695619c6a315166b84e854.tar.bz2 libxslt-3efba7ccbf6169354e695619c6a315166b84e854.zip |
revamped the mechanism to hook a debuger to use a callback setup function,
* libxslt/attributes.c libxslt/transform.c libxslt/xsltutils.c
libxslt/xsltutils.h: revamped the mechanism to hook a debuger
to use a callback setup function, deprecating libxsltbreakpoint
* xsltproc/Makefile.am configure.in breakpoint/Makefile.am: removing
dependancies on libxsltbreakpoint
Daniel
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | breakpoint/Makefile.am | 2 | ||||
-rw-r--r-- | configure.in | 35 | ||||
-rw-r--r-- | libxslt/attributes.c | 242 | ||||
-rw-r--r-- | libxslt/transform.c | 273 | ||||
-rw-r--r-- | libxslt/xsltutils.c | 101 | ||||
-rw-r--r-- | libxslt/xsltutils.h | 29 | ||||
-rw-r--r-- | xsltproc/Makefile.am | 13 |
8 files changed, 414 insertions, 289 deletions
@@ -1,3 +1,11 @@ +Fri Nov 30 12:59:05 CET 2001 Daniel Veillard <daniel@veillard.com> + + * libxslt/attributes.c libxslt/transform.c libxslt/xsltutils.c + libxslt/xsltutils.h: revamped the mechanism to hook a debuger + to use a callback setup function, deprecating libxsltbreakpoint + * xsltproc/Makefile.am configure.in breakpoint/Makefile.am: removing + dependancies on libxsltbreakpoint + Thu Nov 29 09:52:38 CET 2001 Daniel Veillard <daniel@veillard.com> Build patch from Peter Williams <peterw@ximian.com> diff --git a/breakpoint/Makefile.am b/breakpoint/Makefile.am index d7c79667..a233281c 100644 --- a/breakpoint/Makefile.am +++ b/breakpoint/Makefile.am @@ -15,7 +15,7 @@ libxsltbreakpoint_la_SOURCES = \ libxsltbreakpoint_la_LIBADD = @LIBXML_LIBS@ -libxsltbreakpoint_la_LDFLAGS = -version-info @LIBXSLT_VERSION_INFO@ +libxsltbreakpoint_la_LDFLAGS = -version-info @LIBXSLTBREAK_VERSION_INFO@ man_MANS = #breakpoint.4 diff --git a/configure.in b/configure.in index 3f0c2466..cd38f190 100644 --- a/configure.in +++ b/configure.in @@ -42,6 +42,30 @@ AC_SUBST(LIBEXSLT_VERSION) AC_SUBST(LIBEXSLT_VERSION_INFO) AC_SUBST(LIBEXSLT_VERSION_NUMBER) +dnl +dnl libxsltbreakpoint is a compatibility obsoleted library +dnl it's blocked at 1.0.8 and should be removed in default build in the +dnl future +dnl + +LIBXSLTBREAK_MAJOR_VERSION=1 +LIBXSLTBREAK_MINOR_VERSION=0 +LIBXSLTBREAK_MICRO_VERSION=8 + +LIBXSLTBREAK_VERSION=$LIBXSLTBREAK_MAJOR_VERSION.$LIBXSLTBREAK_MINOR_VERSION.$LIBXSLTBREAK_MICRO_VERSION +LIBXSLTBREAK_VERSION_INFO=`expr $LIBXSLTBREAK_MAJOR_VERSION + $LIBXSLTBREAK_MINOR_VERSION`:$LIBXSLTBREAK_MICRO_VERSION:$LIBXSLTBREAK_MINOR_VERSION + +LIBXSLTBREAK_VERSION_NUMBER=`expr $LIBXSLTBREAK_MAJOR_VERSION \* 10000 + $LIBXSLTBREAK_MINOR_VERSION \* 100 + $LIBXSLTBREAK_MICRO_VERSION` + +AC_SUBST(LIBXSLTBREAK_MAJOR_VERSION) +AC_SUBST(LIBXSLTBREAK_MINOR_VERSION) +AC_SUBST(LIBXSLTBREAK_MICRO_VERSION) +AC_SUBST(LIBXSLTBREAK_VERSION) +AC_SUBST(LIBXSLTBREAK_VERSION_INFO) +AC_SUBST(LIBXSLTBREAK_VERSION_NUMBER) + + + VERSION=${LIBXSLT_VERSION} @@ -136,7 +160,7 @@ AC_SUBST(WITH_MEM_DEBUG) dnl dnl Is debugger support requested dnl -AC_ARG_WITH(with_debugger, [ --with-debugger Add the debugging module (off)]) +AC_ARG_WITH(with_debugger, [ --with-debugger Add the debugging support (on)]) if test "$with_debugger" = "no" ; then echo Disabling debugger WITH_DEBUGGER=0 @@ -260,13 +284,8 @@ case ${host} in esac XSLT_INCLUDEDIR='-I${includedir}' -if test "${WITH_DEBUGGER}" = "1" ; then - XSLT_LIBS="-lxslt -lxsltbreakpoint $LIBXML_LIBS $M_LIBS" - EXTRA_LIBS='$(top_builddir)/breakpoint/libxsltbreakpoint.la'" $LIBXML_LIBS $M_LIBS" -else - XSLT_LIBS="-lxslt $LIBXML_LIBS $M_LIBS" - EXTRA_LIBS="$LIBXML_LIBS $M_LIBS" -fi +XSLT_LIBS="-lxslt $LIBXML_LIBS $M_LIBS" +EXTRA_LIBS="$LIBXML_LIBS $M_LIBS" AC_SUBST(XSLT_LIBDIR) AC_SUBST(XSLT_INCLUDEDIR) diff --git a/libxslt/attributes.c b/libxslt/attributes.c index c245c31b..1bfcc2e6 100644 --- a/libxslt/attributes.c +++ b/libxslt/attributes.c @@ -46,9 +46,6 @@ #include "imports.h" #include "transform.h" -#ifdef WITH_DEBUGGER -#include "../breakpoint/breakpoint.h" -#endif #ifdef WITH_XSLT_DEBUG #define WITH_XSLT_DEBUG_ATTRIBUTES #endif @@ -383,7 +380,9 @@ error: */ static void xsltAttributeInternal(xsltTransformContextPtr ctxt, xmlNodePtr node, - xmlNodePtr inst, xsltStylePreCompPtr comp, int fromset) { + xmlNodePtr inst, xsltStylePreCompPtr comp, + int fromset) +{ xmlChar *prop = NULL; xmlChar *ncname = NULL, *name, *namespace; xmlChar *prefix = NULL; @@ -394,105 +393,108 @@ xsltAttributeInternal(xsltTransformContextPtr ctxt, xmlNodePtr node, if (ctxt->insert == NULL) - return; + return; if (comp == NULL) { - xsltPrintErrorContext(ctxt, NULL, inst); - xsltGenericError(xsltGenericErrorContext, - "xsl:attribute : compilation failed\n"); - return; + xsltPrintErrorContext(ctxt, NULL, inst); + xsltGenericError(xsltGenericErrorContext, + "xsl:attribute : compilation failed\n"); + return; } - if ((ctxt == NULL) || (node == NULL) || (inst == NULL) || (comp == NULL)) - return; + if ((ctxt == NULL) || (node == NULL) || (inst == NULL) + || (comp == NULL)) + return; if (!comp->has_name) { - return; + return; } if (ctxt->insert->children != NULL) { - xsltPrintErrorContext(ctxt, NULL, inst); - xsltGenericError(xsltGenericErrorContext, - "xsl:attribute : node already has children\n"); - return; + xsltPrintErrorContext(ctxt, NULL, inst); + xsltGenericError(xsltGenericErrorContext, + "xsl:attribute : node already has children\n"); + return; } - #ifdef WITH_DEBUGGER - /* --- break point code --- */ - if (xslDebugStatus != DEBUG_NONE) { - xslHandleDebugger(inst, node, NULL, ctxt); - } + if (xslDebugStatus != XSLT_DEBUG_NONE) { + xslHandleDebugger(inst, node, NULL, ctxt); + } #endif if (comp->name == NULL) { - prop = xsltEvalAttrValueTemplate(ctxt, inst, (const xmlChar *)"name", - XSLT_NAMESPACE); - if (prop == NULL) { - xsltPrintErrorContext(ctxt, NULL, inst); - xsltGenericError(xsltGenericErrorContext, - "xsl:attribute : name is missing\n"); - goto error; - } - name = prop; + prop = + xsltEvalAttrValueTemplate(ctxt, inst, (const xmlChar *) "name", + XSLT_NAMESPACE); + if (prop == NULL) { + xsltPrintErrorContext(ctxt, NULL, inst); + xsltGenericError(xsltGenericErrorContext, + "xsl:attribute : name is missing\n"); + goto error; + } + name = prop; } else { - name = comp->name; + name = comp->name; } ncname = xmlSplitQName2(name, &prefix); if (ncname == NULL) { - prefix = NULL; + prefix = NULL; } else { - name = ncname; + name = ncname; } - if (!xmlStrncasecmp(prefix, (xmlChar *)"xml", 3)) { + if (!xmlStrncasecmp(prefix, (xmlChar *) "xml", 3)) { #ifdef WITH_XSLT_DEBUG_PARSING - xsltGenericDebug(xsltGenericDebugContext, - "xsltAttribute: xml prefix forbidden\n"); + xsltGenericDebug(xsltGenericDebugContext, + "xsltAttribute: xml prefix forbidden\n"); #endif - goto error; + goto error; } if ((comp->ns == NULL) && (comp->has_ns)) { - namespace = xsltEvalAttrValueTemplate(ctxt, inst, - (const xmlChar *)"namespace", XSLT_NAMESPACE); - if (namespace != NULL) { - ns = xsltGetSpecialNamespace(ctxt, inst, namespace, prefix, - ctxt->insert); - xmlFree(namespace); - } else { - if (prefix != NULL) { - ns = xmlSearchNs(inst->doc, inst, prefix); - if (ns == NULL) { - xsltPrintErrorContext(ctxt, NULL, inst); - xsltGenericError(xsltGenericErrorContext, - "xsl:attribute : no namespace bound to prefix %s\n", prefix); - } else { - ns = xsltGetNamespace(ctxt, inst, ns, ctxt->insert); - } - } - } + namespace = xsltEvalAttrValueTemplate(ctxt, inst, + (const xmlChar *) + "namespace", XSLT_NAMESPACE); + if (namespace != NULL) { + ns = xsltGetSpecialNamespace(ctxt, inst, namespace, prefix, + ctxt->insert); + xmlFree(namespace); + } else { + if (prefix != NULL) { + ns = xmlSearchNs(inst->doc, inst, prefix); + if (ns == NULL) { + xsltPrintErrorContext(ctxt, NULL, inst); + xsltGenericError(xsltGenericErrorContext, + "xsl:attribute : no namespace bound to prefix %s\n", + prefix); + } else { + ns = xsltGetNamespace(ctxt, inst, ns, ctxt->insert); + } + } + } } else if (comp->ns != NULL) { - ns = xsltGetSpecialNamespace(ctxt, inst, comp->ns, prefix, - ctxt->insert); + ns = xsltGetSpecialNamespace(ctxt, inst, comp->ns, prefix, + ctxt->insert); } if ((fromset) && (ns != NULL)) - URL = ns->href; + URL = ns->href; if ((fromset == 0) || (!xmlHasNsProp(ctxt->insert, name, URL))) { - value = xsltEvalTemplateString(ctxt, node, inst); - if (value == NULL) { - if (ns) { - attr = xmlSetNsProp(ctxt->insert, ns, name, - (const xmlChar *)""); - } else { - attr = xmlSetProp(ctxt->insert, name, (const xmlChar *)""); - } - } else { - if (ns) { - attr = xmlSetNsProp(ctxt->insert, ns, name, value); - } else { - attr = xmlSetProp(ctxt->insert, name, value); - } - } + value = xsltEvalTemplateString(ctxt, node, inst); + if (value == NULL) { + if (ns) { + attr = xmlSetNsProp(ctxt->insert, ns, name, + (const xmlChar *) ""); + } else { + attr = + xmlSetProp(ctxt->insert, name, (const xmlChar *) ""); + } + } else { + if (ns) { + attr = xmlSetNsProp(ctxt->insert, ns, name, value); + } else { + attr = xmlSetProp(ctxt->insert, name, value); + } + } } -error: + error: if (prop != NULL) xmlFree(prop); if (ncname != NULL) @@ -530,7 +532,9 @@ xsltAttribute(xsltTransformContextPtr ctxt, xmlNodePtr node, void xsltApplyAttributeSet(xsltTransformContextPtr ctxt, xmlNodePtr node, - xmlNodePtr inst ATTRIBUTE_UNUSED, xmlChar *attributes) { + xmlNodePtr inst ATTRIBUTE_UNUSED, + xmlChar * attributes) +{ xmlChar *ncname = NULL; xmlChar *prefix = NULL; xmlChar *attrib, *endattr; @@ -538,57 +542,61 @@ xsltApplyAttributeSet(xsltTransformContextPtr ctxt, xmlNodePtr node, xsltStylesheetPtr style; if (attributes == NULL) { - return; + return; } attrib = attributes; while (*attrib != 0) { - while (IS_BLANK(*attrib)) attrib++; - if (*attrib == 0) - break; + while (IS_BLANK(*attrib)) + attrib++; + if (*attrib == 0) + break; endattr = attrib; - while ((*endattr != 0) && (!IS_BLANK(*endattr))) endattr++; - attrib = xmlStrndup(attrib, endattr - attrib); - if (attrib) { + while ((*endattr != 0) && (!IS_BLANK(*endattr))) + endattr++; + attrib = xmlStrndup(attrib, endattr - attrib); + if (attrib) { #ifdef WITH_XSLT_DEBUG_ATTRIBUTES - xsltGenericDebug(xsltGenericDebugContext, - "apply attribute set %s\n", attrib); + xsltGenericDebug(xsltGenericDebugContext, + "apply attribute set %s\n", attrib); #endif - ncname = xmlSplitQName2(attrib, &prefix); - if (ncname == NULL) { - ncname = attrib; - attrib = NULL; - prefix = NULL; - } - - style = ctxt->style; + ncname = xmlSplitQName2(attrib, &prefix); + if (ncname == NULL) { + ncname = attrib; + attrib = NULL; + prefix = NULL; + } + + style = ctxt->style; #ifdef WITH_DEBUGGER - /* --- break point code --- */ - if (style && (xslDebugStatus != DEBUG_NONE)) { - values = xmlHashLookup2(style->attributeSets, ncname, prefix); - if (values) - xslHandleDebugger(values->attr->parent, node, NULL, ctxt); - } + if (style && (xslDebugStatus != XSLT_DEBUG_NONE)) { + values = + xmlHashLookup2(style->attributeSets, ncname, prefix); + if (values) + xslHandleDebugger(values->attr->parent, node, NULL, + ctxt); + } #endif - while (style != NULL) { - values = xmlHashLookup2(style->attributeSets, ncname, prefix); - while (values != NULL) { - if (values->attr != NULL) { - xsltAttributeInternal(ctxt, node, values->attr, - values->attr->_private, 1); - } - values = values->next; - } - style = xsltNextImport(style); - } - if (attrib != NULL) - xmlFree(attrib); - if (ncname != NULL) - xmlFree(ncname); - if (prefix != NULL) - xmlFree(prefix); - } - attrib = endattr; + while (style != NULL) { + values = + xmlHashLookup2(style->attributeSets, ncname, prefix); + while (values != NULL) { + if (values->attr != NULL) { + xsltAttributeInternal(ctxt, node, values->attr, + values->attr->_private, 1); + } + values = values->next; + } + style = xsltNextImport(style); + } + if (attrib != NULL) + xmlFree(attrib); + if (ncname != NULL) + xmlFree(ncname); + if (prefix != NULL) + xmlFree(prefix); + } + attrib = endattr; } } diff --git a/libxslt/transform.c b/libxslt/transform.c index 6707576b..1ca922cc 100644 --- a/libxslt/transform.c +++ b/libxslt/transform.c @@ -61,11 +61,6 @@ static int xsltGetHTMLIDs(const xmlChar *version, const xmlChar **publicID, const xmlChar **systemID); #endif -#ifdef WITH_DEBUGGER -#include "../breakpoint/breakpoint.h" -int xslDebugStatus; -#endif - int xsltMaxDepth = 5000; /* @@ -1017,24 +1012,6 @@ xsltProcessOneNode(xsltTransformContextPtr ctxt, xmlNodePtr node, /** - * xslHandleDebugger: - * @cur : source node being executed - * @node : data node being processed - * @templ : temlate that applies to node - * @ctxt : the xslt transform context - * - * If either cur or node are a breakpoint, or xslDebugStatus in state - * where debugging must occcur at this time then transfer control - * to the xslDebugBreak function - */ -void -xslHandleDebugger(xmlNodePtr cur ATTRIBUTE_UNUSED, xmlNodePtr node ATTRIBUTE_UNUSED, - xsltTemplatePtr templ ATTRIBUTE_UNUSED, xsltTransformContextPtr ctxt ATTRIBUTE_UNUSED) -{ - -} - -/** * xsltApplyOneTemplate: * @ctxt: a XSLT process context * @node: the node in the source tree. @@ -1049,7 +1026,7 @@ xslHandleDebugger(xmlNodePtr cur ATTRIBUTE_UNUSED, xmlNodePtr node ATTRIBUTE_UNU void xsltApplyOneTemplate(xsltTransformContextPtr ctxt, xmlNodePtr node, xmlNodePtr list, xsltTemplatePtr templ, - xsltStackElemPtr params) + xsltStackElemPtr params) { xmlNodePtr cur = NULL, insert, copy = NULL; xmlNodePtr oldInsert; @@ -1064,8 +1041,7 @@ xsltApplyOneTemplate(xsltTransformContextPtr ctxt, xmlNodePtr node, long start = 0; #ifdef WITH_DEBUGGER - /* --- break point code --- */ - if (xslDebugStatus != DEBUG_NONE) { + if (xslDebugStatus != XSLT_DEBUG_NONE) { if (templ) { addCallResult = xslAddCall(templ, templ->elem); } else { @@ -1074,8 +1050,8 @@ xsltApplyOneTemplate(xsltTransformContextPtr ctxt, xmlNodePtr node, switch (xslDebugStatus) { - case DEBUG_RUN_RESTART: - case DEBUG_QUIT: + case XSLT_DEBUG_RUN_RESTART: + case XSLT_DEBUG_QUIT: if (addCallResult) xslDropCall(); return; @@ -1084,11 +1060,10 @@ xsltApplyOneTemplate(xsltTransformContextPtr ctxt, xmlNodePtr node, if (templ) xslHandleDebugger(templ->elem, node, templ, ctxt); else if (list) - xslHandleDebugger(list, node, templ, ctxt); - else if (ctxt->inst) - xslHandleDebugger(ctxt->inst, node, templ, ctxt); + xslHandleDebugger(list, node, templ, ctxt); + else if (ctxt->inst) + xslHandleDebugger(ctxt->inst, node, templ, ctxt); } - /* -- end --- */ #endif if ((ctxt == NULL) || (list == NULL)) @@ -1096,7 +1071,7 @@ xsltApplyOneTemplate(xsltTransformContextPtr ctxt, xmlNodePtr node, CHECK_STOPPED; if (ctxt->templNr >= xsltMaxDepth) { - xsltPrintErrorContext(ctxt, NULL, list); + xsltPrintErrorContext(ctxt, NULL, list); xsltGenericError(xsltGenericErrorContext, "xsltApplyOneTemplate: loop found ???\n"); xsltGenericError(xsltGenericErrorContext, @@ -1112,21 +1087,20 @@ xsltApplyOneTemplate(xsltTransformContextPtr ctxt, xmlNodePtr node, oldInst = ctxt->inst; oldCurrent = ctxt->node; varsPush(ctxt, params); - oldBase = ctxt->varsBase; /* only needed if templ != NULL */ + oldBase = ctxt->varsBase; /* only needed if templ != NULL */ if (templ != NULL) { - ctxt->varsBase = ctxt->varsNr - 1; + ctxt->varsBase = ctxt->varsNr - 1; ctxt->node = node; - if (ctxt->profile) { - templ->nbCalls++; - start = xsltTimestamp(); - profPush(ctxt, 0); - } - templPush(ctxt, templ); + if (ctxt->profile) { + templ->nbCalls++; + start = xsltTimestamp(); + profPush(ctxt, 0); + } + templPush(ctxt, templ); #ifdef WITH_XSLT_DEBUG_PROCESS - if (templ->name != NULL) - xsltGenericDebug(xsltGenericDebugContext, - "applying template '%s'\n", - templ->name); + if (templ->name != NULL) + xsltGenericDebug(xsltGenericDebugContext, + "applying template '%s'\n", templ->name); #endif } @@ -1137,14 +1111,12 @@ xsltApplyOneTemplate(xsltTransformContextPtr ctxt, xmlNodePtr node, while (cur != NULL) { ctxt->inst = cur; #ifdef WITH_DEBUGGER - /* --- break point code --- */ switch (xslDebugStatus) { - case DEBUG_RUN_RESTART: - case DEBUG_QUIT: + case XSLT_DEBUG_RUN_RESTART: + case XSLT_DEBUG_QUIT: break; } - /* --- end --- */ #endif /* * test, we must have a valid insertion point @@ -1154,10 +1126,10 @@ xsltApplyOneTemplate(xsltTransformContextPtr ctxt, xmlNodePtr node, xsltGenericDebug(xsltGenericDebugContext, "xsltApplyOneTemplate: insert == NULL !\n"); #endif - goto error; + goto error; } #ifdef WITH_DEBUGGER - if (xslDebugStatus != DEBUG_NONE) + if (xslDebugStatus != XSLT_DEBUG_NONE) xslHandleDebugger(cur, node, templ, ctxt); #endif @@ -1171,16 +1143,16 @@ xsltApplyOneTemplate(xsltTransformContextPtr ctxt, xmlNodePtr node, if (IS_XSLT_NAME(cur, "message")) { xsltMessage(ctxt, node, cur); } else { - /* - * That's an error try to apply one of the fallback cases - */ - ctxt->insert = insert; - if (!xsltApplyFallbacks(ctxt, node, cur)) { - xsltGenericError(xsltGenericDebugContext, - "xsltApplyOneTemplate: %s was not compiled\n", - cur->name); - } - ctxt->insert = oldInsert; + /* + * That's an error try to apply one of the fallback cases + */ + ctxt->insert = insert; + if (!xsltApplyFallbacks(ctxt, node, cur)) { + xsltGenericError(xsltGenericDebugContext, + "xsltApplyOneTemplate: %s was not compiled\n", + cur->name); + } + ctxt->insert = oldInsert; } goto skip_children; } @@ -1219,14 +1191,14 @@ xsltApplyOneTemplate(xsltTransformContextPtr ctxt, xmlNodePtr node, cur->content); else if (cur->name == xmlStringTextNoenc) xsltGenericDebug(xsltGenericDebugContext, - "xsltApplyOneTemplate: copy unescaped text %s\n", + "xsltApplyOneTemplate: copy unescaped text %s\n", cur->content); else xsltGenericDebug(xsltGenericDebugContext, "xsltApplyOneTemplate: copy text %s\n", cur->content); #endif - xsltCopyText(ctxt, insert, cur); + xsltCopyText(ctxt, insert, cur); } else if ((cur->type == XML_ELEMENT_NODE) && (cur->ns != NULL) && (cur->_private != NULL)) { xsltTransformFunction function; @@ -1234,11 +1206,11 @@ xsltApplyOneTemplate(xsltTransformContextPtr ctxt, xmlNodePtr node, /* * Flagged as an extension element */ - if (cur->_private == xsltExtMarker) - function = (xsltTransformFunction) - xsltExtElementLookup(ctxt, cur->name, cur->ns->href); - else - function = ((xsltElemPreCompPtr)cur->_private)->func; + if (cur->_private == xsltExtMarker) + function = (xsltTransformFunction) + xsltExtElementLookup(ctxt, cur->name, cur->ns->href); + else + function = ((xsltElemPreCompPtr) cur->_private)->func; if (function == NULL) { xmlNodePtr child; @@ -1246,7 +1218,7 @@ xsltApplyOneTemplate(xsltTransformContextPtr ctxt, xmlNodePtr node, #ifdef WITH_XSLT_DEBUG_PROCESS xsltGenericDebug(xsltGenericDebugContext, - "xsltApplyOneTemplate: unknown extension %s\n", + "xsltApplyOneTemplate: unknown extension %s\n", cur->name); #endif /* @@ -1258,21 +1230,21 @@ xsltApplyOneTemplate(xsltTransformContextPtr ctxt, xmlNodePtr node, (IS_XSLT_NAME(child, "fallback"))) { found = 1; xsltApplyOneTemplate(ctxt, node, child->children, - NULL, NULL); + NULL, NULL); } child = child->next; } if (!found) { - xsltPrintErrorContext(ctxt, NULL, cur); + xsltPrintErrorContext(ctxt, NULL, cur); xsltGenericError(xsltGenericErrorContext, - "xsltApplyOneTemplate: failed to find extension %s\n", + "xsltApplyOneTemplate: failed to find extension %s\n", cur->name); } } else { #ifdef WITH_XSLT_DEBUG_PROCESS xsltGenericDebug(xsltGenericDebugContext, - "xsltApplyOneTemplate: extension construct %s\n", + "xsltApplyOneTemplate: extension construct %s\n", cur->name); #endif @@ -1295,41 +1267,42 @@ xsltApplyOneTemplate(xsltTransformContextPtr ctxt, xmlNodePtr node, attrs = xsltAttrListTemplateProcess(ctxt, copy, cur->properties); } - /* - * Add extra namespaces inherited from the current template - * if we are in the first level children - */ - if ((oldInsert == insert) && (ctxt->templ != NULL) && - (ctxt->templ->inheritedNs != NULL)) { - int i; - xmlNsPtr ns, ret; - - for (i = 0;i < ctxt->templ->inheritedNsNr;i++) { - ns = ctxt->templ->inheritedNs[i]; - if (ctxt->style->nsAliases != NULL) { - const xmlChar *URI; - URI = (const xmlChar *) - xmlHashLookup(ctxt->style->nsAliases, - ns->href); - if (URI == NULL) { - ret = xmlSearchNs(copy->doc, copy, ns->prefix); - if ((ret == NULL) || - (!xmlStrEqual(ret->href, ns->href))) - xmlNewNs(copy, ns->href, ns->prefix); - } else if (!xmlStrEqual(URI, XSLT_NAMESPACE)) { - ret = xmlSearchNs(copy->doc, copy, ns->prefix); - if ((ret == NULL) || - (!xmlStrEqual(ret->href, URI))) - xmlNewNs(copy, URI, ns->prefix); - } - } else { - ret = xmlSearchNs(copy->doc, copy, ns->prefix); - if ((ret == NULL) || - (!xmlStrEqual(ret->href, ns->href))) - xmlNewNs(copy, ns->href, ns->prefix); - } - } - } + /* + * Add extra namespaces inherited from the current template + * if we are in the first level children + */ + if ((oldInsert == insert) && (ctxt->templ != NULL) && + (ctxt->templ->inheritedNs != NULL)) { + int i; + xmlNsPtr ns, ret; + + for (i = 0; i < ctxt->templ->inheritedNsNr; i++) { + ns = ctxt->templ->inheritedNs[i]; + if (ctxt->style->nsAliases != NULL) { + const xmlChar *URI; + + URI = (const xmlChar *) + xmlHashLookup(ctxt->style->nsAliases, + ns->href); + if (URI == NULL) { + ret = xmlSearchNs(copy->doc, copy, ns->prefix); + if ((ret == NULL) || + (!xmlStrEqual(ret->href, ns->href))) + xmlNewNs(copy, ns->href, ns->prefix); + } else if (!xmlStrEqual(URI, XSLT_NAMESPACE)) { + ret = xmlSearchNs(copy->doc, copy, ns->prefix); + if ((ret == NULL) || + (!xmlStrEqual(ret->href, URI))) + xmlNewNs(copy, URI, ns->prefix); + } + } else { + ret = xmlSearchNs(copy->doc, copy, ns->prefix); + if ((ret == NULL) || + (!xmlStrEqual(ret->href, ns->href))) + xmlNewNs(copy, ns->href, ns->prefix); + } + } + } } /* @@ -1364,58 +1337,58 @@ xsltApplyOneTemplate(xsltTransformContextPtr ctxt, xmlNodePtr node, } } while (cur != NULL); } -error: + error: ctxt->node = oldCurrent; ctxt->inst = oldInst; ctxt->insert = oldInsert; if (params == NULL) - xsltFreeStackElemList(varsPop(ctxt)); + xsltFreeStackElemList(varsPop(ctxt)); else { - xsltStackElemPtr p, tmp = varsPop(ctxt); - if (tmp != params) { - p = tmp; - while ((p != NULL) && (p->next != params)) - p = p->next; - if (p == NULL) { - xsltFreeStackElemList(tmp); - } else { - p->next = NULL; - xsltFreeStackElemList(tmp); - } - } + xsltStackElemPtr p, tmp = varsPop(ctxt); + + if (tmp != params) { + p = tmp; + while ((p != NULL) && (p->next != params)) + p = p->next; + if (p == NULL) { + xsltFreeStackElemList(tmp); + } else { + p->next = NULL; + xsltFreeStackElemList(tmp); + } + } } if (templ != NULL) { - ctxt->varsBase = oldBase; - templPop(ctxt); - if (ctxt->profile) { - long spent, child, total, end; - - end = xsltTimestamp(); - child = profPop(ctxt); - total = end - start; - spent = total - child; - if (spent <= 0) { - /* - * Not possible unless the original calibration failed - * we can try to corret it on the fly. - */ - xsltCalibrateAdjust(spent); - spent = 0; - } + ctxt->varsBase = oldBase; + templPop(ctxt); + if (ctxt->profile) { + long spent, child, total, end; + + end = xsltTimestamp(); + child = profPop(ctxt); + total = end - start; + spent = total - child; + if (spent <= 0) { + /* + * Not possible unless the original calibration failed + * we can try to corret it on the fly. + */ + xsltCalibrateAdjust(spent); + spent = 0; + } - templ->time += spent; - if (ctxt->profNr > 0) - ctxt->profTab[ctxt->profNr - 1] += total; - } + templ->time += spent; + if (ctxt->profNr > 0) + ctxt->profTab[ctxt->profNr - 1] += total; + } } #ifdef WITH_DEBUGGER - if (xslDebugStatus != DEBUG_NONE && addCallResult) { + if ((xslDebugStatus != XSLT_DEBUG_NONE) && (addCallResult)) { xslDropCall(); } #endif } - /************************************************************************ * * * XSLT-1.1 extensions * @@ -2522,7 +2495,7 @@ xsltCallTemplate(xsltTransformContextPtr ctxt, xmlNodePtr node, cur = inst->children; while (cur != NULL) { #ifdef WITH_DEBUGGER - if (xslDebugStatus != DEBUG_NONE) + if (xslDebugStatus != XSLT_DEBUG_NONE) xslHandleDebugger(cur, node, comp->templ, ctxt); #endif if (ctxt->state == XSLT_STATE_STOPPED) break; @@ -2722,7 +2695,7 @@ xsltApplyTemplates(xsltTransformContextPtr ctxt, xmlNodePtr node, cur = inst->children; while (cur!=NULL) { #ifdef WITH_DEBUGGER - if (xslDebugStatus != DEBUG_NONE) + if (xslDebugStatus != XSLT_DEBUG_NONE) xslHandleDebugger(cur, node, comp->templ, ctxt); #endif if (ctxt->state == XSLT_STATE_STOPPED) break; @@ -2856,7 +2829,7 @@ xsltChoose(xsltTransformContextPtr ctxt, xmlNodePtr node, #ifdef WITH_DEBUGGER - if (xslDebugStatus != DEBUG_NONE) + if (xslDebugStatus != XSLT_DEBUG_NONE) xslHandleDebugger(when, node, comp->templ, ctxt); #endif @@ -2912,7 +2885,7 @@ xsltChoose(xsltTransformContextPtr ctxt, xmlNodePtr node, } if (IS_XSLT_ELEM(replacement) && (IS_XSLT_NAME(replacement, "otherwise"))) { #ifdef WITH_DEBUGGER - if (xslDebugStatus != DEBUG_NONE) + if (xslDebugStatus != XSLT_DEBUG_NONE) xslHandleDebugger(replacement, node, comp->templ, ctxt); #endif @@ -3101,7 +3074,7 @@ xsltForEach(xsltTransformContextPtr ctxt, xmlNodePtr node, sorts[nbsorts++] = replacement; } #ifdef WITH_DEBUGGER - if (xslDebugStatus != DEBUG_NONE) + if (xslDebugStatus != XSLT_DEBUG_NONE) xslHandleDebugger(replacement, node, NULL, ctxt); #endif replacement = replacement->next; diff --git a/libxslt/xsltutils.c b/libxslt/xsltutils.c index 0b810069..61c748ba 100644 --- a/libxslt/xsltutils.c +++ b/libxslt/xsltutils.c @@ -32,6 +32,7 @@ #include "templates.h" #include "xsltInternals.h" #include "imports.h" +#include "transform.h" /* gettimeofday on Windows ??? */ #ifdef WIN32 @@ -1246,3 +1247,103 @@ xsltSaveProfiling(xsltTransformContextPtr ctxt, FILE *output) { xmlFree(templates); } +/************************************************************************ + * * + * Hooks for the debugger * + * * + ************************************************************************/ + +/* + * There is currently only 3 debugging callback defined + * Debugger callbacks are disabled by default + */ +#define XSLT_CALLBACK_NUMBER 3 + +typedef struct _xsltDebuggerCallbacks xsltDebuggerCallbacks; +typedef xsltDebuggerCallbacks *xsltDebuggerCallbacksPtr; +struct _xsltDebuggerCallbacks { + xsltHandleDebuggerCallback handler; + xsltAddCallCallback add; + xsltDropCallCallback drop; +}; + +static xsltDebuggerCallbacks xsltDebuggerCurrentCallbacks = { + NULL, /* handler */ + NULL, /* add */ + NULL /* drop */ +}; + +int xslDebugStatus; + +/** + * xslSetDebuggerCallbacks: + * @no : number of callbacks + * @block : the block of callbacks + * + * This function allow to plug a debugger into the XSLT library + * @block points to a block of memory containing the address of @no + * callback routines. + * + * Returns 0 in case of success and -1 in case of error + */ +int +xsltSetDebuggerCallbacks(int no, void *block) +{ + xsltDebuggerCallbacksPtr callbacks; + + if ((block == NULL) || (no != 1)) + return(-1); + + callbacks = (xsltDebuggerCallbacksPtr) block; + xsltDebuggerCurrentCallbacks.handler = callbacks->handler; + return(0); +} + +/** + * xslHandleDebugger: + * @cur : source node being executed + * @node : data node being processed + * @templ : temlate that applies to node + * @ctxt : the xslt transform context + * + * If either cur or node are a breakpoint, or xslDebugStatus in state + * where debugging must occcur at this time then transfer control + * to the xslDebugBreak function + */ +void +xslHandleDebugger(xmlNodePtr cur, xmlNodePtr node, xsltTemplatePtr templ, + xsltTransformContextPtr ctxt) +{ + if (xsltDebuggerCurrentCallbacks.handler != NULL) + xsltDebuggerCurrentCallbacks.handler(cur, node, templ, ctxt); +} + +/** + * xslAddCall: + * @templ : current template being applied + * @source : the source node being processed + * + * Add template "call" to call stack + * Returns : 1 on sucess 0 otherwise an error may be printed if + * WITH_XSLT_DEBUG_BREAKPOINTS is defined + */ +int +xslAddCall(xsltTemplatePtr templ, xmlNodePtr source) +{ + if (xsltDebuggerCurrentCallbacks.add != NULL) + return(xsltDebuggerCurrentCallbacks.add(templ, source)); + return(0); +} + +/** + * xslDropCall : + * + * Drop the topmost item off the call stack + */ +void +xslDropCall(void) +{ + if (xsltDebuggerCurrentCallbacks.drop != NULL) + xsltDebuggerCurrentCallbacks.drop(); +} + diff --git a/libxslt/xsltutils.h b/libxslt/xsltutils.h index 70cdc905..4513f4f6 100644 --- a/libxslt/xsltutils.h +++ b/libxslt/xsltutils.h @@ -154,6 +154,35 @@ void xsltCalibrateAdjust (long delta); #define XSLT_TIMESTAMP_TICS_PER_SEC 100000l +/* + * Hooks for the debugger + */ + +typedef enum { + XSLT_DEBUG_NONE = 0, /* no debugging allowed */ + XSLT_DEBUG_INIT, + XSLT_DEBUG_STEP, + XSLT_DEBUG_STEPOUT, + XSLT_DEBUG_NEXT, + XSLT_DEBUG_STOP, + XSLT_DEBUG_CONT, + XSLT_DEBUG_RUN, + XSLT_DEBUG_RUN_RESTART, + XSLT_DEBUG_QUIT +} xsltDebugStatusCodes; + +LIBXSLT_PUBLIC extern int xslDebugStatus; + +typedef void (*xsltHandleDebuggerCallback) (xmlNodePtr cur, xmlNodePtr node, + xsltTemplatePtr templ, xsltTransformContextPtr ctxt); +typedef int (*xsltAddCallCallback) (xsltTemplatePtr templ, xmlNodePtr source); +typedef void (*xsltDropCallCallback) (void); + +int xsltSetDebuggerCallbacks (int no, void *block); +int xslAddCall (xsltTemplatePtr templ, + xmlNodePtr source); +void xslDropCall (void); + #ifdef __cplusplus } #endif diff --git a/xsltproc/Makefile.am b/xsltproc/Makefile.am index b92f42a6..931a4786 100644 --- a/xsltproc/Makefile.am +++ b/xsltproc/Makefile.am @@ -11,22 +11,9 @@ xsltproc_LDFLAGS = xsltproc_DEPENDENCIES = $(DEPS) xsltproc_LDADD = $(LDADDS) -if WITH_DEBUGGER DEPS = $(top_builddir)/libxslt/libxslt.la \ - $(top_builddir)/breakpoint/libxsltbreakpoint.la \ $(top_builddir)/libexslt/libexslt.la -else -DEPS = $(top_builddir)/libxslt/libxslt.la \ - $(top_builddir)/libexslt/libexslt.la -endif -if WITH_DEBUGGER -LDADDS = $(top_builddir)/libxslt/libxslt.la \ - $(top_builddir)/libexslt/libexslt.la \ - $(top_builddir)/breakpoint/libxsltbreakpoint.la \ - @LIBXML_LIBS@ $(EXTRA_LIBS) -else LDADDS = $(top_builddir)/libxslt/libxslt.la \ $(top_builddir)/libexslt/libexslt.la \ @LIBXML_LIBS@ $(EXTRA_LIBS) -endif |