From 6f01c32a40f986ba2dfbecd1a52b086649ebdb08 Mon Sep 17 00:00:00 2001 From: Daniel Veillard Date: Sun, 22 Apr 2001 20:31:17 +0000 Subject: [PATCH] - transform.c: fixed #53401 - configure.in libxslt/*.c: allowed to suppress debug reporting functionalities but it brings not noticeable improvements - doc/xslt.html doc/html/*: updated and regenerated docs Daniel --- README | 4 +- configure.in | 9 ++ doc/html/libxslt-attributes.html | 28 ++--- doc/html/libxslt-functions.html | 38 +++--- doc/html/libxslt-imports.html | 54 ++++----- doc/html/libxslt-keys.html | 44 +++---- doc/html/libxslt-namespaces.html | 48 ++++---- doc/html/libxslt-numbersinternals.html | 26 ++--- doc/html/libxslt-pattern.html | 38 +++--- doc/html/libxslt-templates.html | 52 ++++----- doc/html/libxslt-transform.html | 207 ++++++++++++++++++--------------- doc/html/libxslt-variables.html | 199 +++++++++++++++++++++++-------- doc/html/libxslt-xsltinternals.html | 126 ++++++++++---------- doc/html/libxslt-xsltutils.html | 114 +++++++++--------- doc/xslt.html | 20 ++++ libxslt/attributes.c | 14 ++- libxslt/documents.c | 4 +- libxslt/extensions.c | 4 +- libxslt/extra.c | 4 +- libxslt/functions.c | 4 +- libxslt/keys.c | 20 ++-- libxslt/pattern.c | 8 +- libxslt/preproc.c | 12 +- libxslt/templates.c | 12 +- libxslt/transform.c | 122 ++++++++++--------- libxslt/variables.c | 46 ++++---- libxslt/xslt.c | 51 ++++---- libxslt/xsltconfig.h.in | 4 + tests/XSLTMark/metric.out | 12 +- tests/docs/bug-9-.xml | 3 + tests/general/bug-5-.out | 20 ++-- tests/general/bug-9-.xsl | 10 ++ 32 files changed, 780 insertions(+), 577 deletions(-) create mode 100644 tests/docs/bug-9-.xml create mode 100644 tests/general/bug-9-.xsl diff --git a/README b/README index 99f7775..c71e1d8 100644 --- a/README +++ b/README @@ -3,12 +3,12 @@ http://xmlsoft.org/ - Requires libxml2 >= 2.3.0 with XPath support. It won't even compile + Requires libxml2 >= 2.3.6 with XPath support. It won't even compile otherwise. Check the FEATURES file for informations about completeness Check the Changelog too to keep track of progresses. - report bugs to xml@rpmfind.net or on the bugzilla.gnome.org base. + report bugs to xslt@gnome.org or on the bugzilla.gnome.org base. Daniel Veillard diff --git a/configure.in b/configure.in index eccab75..91ab74c 100644 --- a/configure.in +++ b/configure.in @@ -48,6 +48,15 @@ if test "${LOGNAME}" = "veillard" -a "`pwd`" = "/u/veillard/XSLT" ; then CFLAGS="-Wall -g -O -ansi -pedantic -W -Wunused -Wimplicit -Wreturn-type -Wswitch -Wcomment -Wtrigraphs -Wformat -Wchar-subscripts -Wuninitialized -Wparentheses -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline " fi +AC_ARG_WITH(debug, [ --with-debug Add the debugging code (on)]) +if test "$with_mem_debug" = "no" ; then + echo Disabling debug support + WITH_XSLT_DEBUG=0 +else + WITH_XSLT_DEBUG=1 +fi +AC_SUBST(WITH_XSLT_DEBUG) + AC_ARG_WITH(mem_debug, [ --with-mem-debug Add the memory debugging module (off)]) if test "$with_mem_debug" = "yes" ; then echo Enabling memory debug support diff --git a/doc/html/libxslt-attributes.html b/doc/html/libxslt-attributes.html index b7daf10..5c83a6c 100644 --- a/doc/html/libxslt-attributes.html +++ b/doc/html/libxslt-attributes.html @@ -121,7 +121,7 @@ NAME="LIBXSLT-ATTRIBUTES" >

Name

Synopsis

Description

Details

style ::cur ::

style ::

ctxt ::node ::inst ::attributes ::ctxt ::nargs ::ctxt ::nargs ::ctxt ::nargs ::ctxt ::nargs ::ctxt ::nargs ::ctxt ::nargs ::ctxt ::nargs ::ctxt ::nargs ::ctxt ::nargs ::ctxt ::

Name

Synopsis

Description

Details

res ::style ::name ::

res ::style ::name ::

style ::cur ::

style ::cur ::

style ::

ctxt ::node ::

ctxt ::name ::nameURI ::

Name

Synopsis

Description

Details

style ::name ::nameURI ::match ::use ::

ctxt ::name ::nameURI ::value ::

ctxt ::doc ::

style ::

doc ::

Name

Synopsis

Description

Details

style ::node ::

ctxt ::cur ::ns ::out ::

ctxt ::cur ::URI ::prefix ::out ::

ctxt ::node ::cur ::

style ::

Name

Synopsis

Description

Details

Param1 ::Param2 ::Param3 ::Param4 ::

Param1 ::Param2 ::Param3 ::pattern ::doc ::node ::comp ::ctxt ::node ::comp ::style ::cur ::mode ::modeURI ::ctxt ::node ::style ::style ::style ::ctxt ::node ::pattern ::ctxt ::comp ::ctxt ::node ::parent ::ctxt ::node ::name ::ns ::ctxt ::node ::name ::ns ::found ::ctxt ::comp ::ctxt ::node ::ctxt ::target ::cur ::ctxt ::target ::attr ::ctxt ::attr ::xmlDocPtr doc); +> doc, + const char **params); void xsltApplyOneTemplatexmlDocPtr doc); doc, + const char **params);style ::doc ::params: a NULL terminated arry of parameters names/values tuplesReturns

ctxt ::node ::list ::real ::

ctxt ::node ::inst ::comp ::

ctxt ::node ::inst ::comp ::

ctxt ::node ::inst ::comp ::

ctxt ::node ::inst ::comp ::

ctxt ::node ::inst ::comp ::

ctxt ::node ::inst ::comp ::

ctxt ::node ::inst ::comp ::

ctxt ::node ::inst ::comp ::

ctxt ::node ::inst ::comp ::

ctxt ::node ::inst ::comp ::

ctxt ::node ::inst ::comp ::

ctxt ::node ::inst ::comp ::

ctxt ::node ::inst ::comp ::

ctxt ::node ::inst ::comp ::

ctxt ::node ::inst ::comp ::

ctxt ::node ::inst ::comp ::

ctxt ::node ::inst ::comp ::

Name

Synopsis

xsltTransformContextPtr ctxt); +int xsltEvalUserParams (xsltTransformContextPtr ctxt, + const char **params); void xsltPushStack

Description

Details


xsltEvalUserParams ()

int         xsltEvalUserParams              (xsltTransformContextPtr ctxt,
+                                             const char **params);

Evaluate the global variables of a stylesheet. This need to be +done on parsed stylesheets before starting to apply transformations

:::::::::::::::::::::::::::
:::
ctxt:params: a NULL terminated arry of parameters names/values tuples
Returns


cur :
cur :
cur :
cur :
cur :
elems :

name :ns_uri :
name :ns_uri :select :tree :param :
name :ns_uri :

Name

Synopsis

Description

Details












node :inst :comp :




#define CHECK_STOPPED if (ctxt->state == XSLT_STATE_STOPPED) return;
#define CHECK_STOPPED if (ctxt-state == XSLT_STATE_STOPPED) return;

#define CHECK_STOPPEDE if (ctxt->state == XSLT_STATE_STOPPED) goto error;
#define CHECK_STOPPEDE if (ctxt-state == XSLT_STATE_STOPPED) goto error;

#define CHECK_STOPPED0 if (ctxt->state == XSLT_STATE_STOPPED) return(0);
#define CHECK_STOPPED0 if (ctxt-state == XSLT_STATE_STOPPED) return(0);


filename ::

sheet ::

str ::

elem ::

sheet ::name ::

ret ::doc ::

style ::cur ::

doc ::

ctxt ::data ::node ::

self ::format ::number ::result ::

Name

Synopsis

Description

Details

name ::

name ::prefix ::

ctxt ::nargs ::



n ::

n ::val ::





ctxt ::node ::inst ::

ctx ::handler ::

ctx ::handler ::

list ::

list ::results ::descending ::number ::

buf ::result ::style ::

URI ::result ::style ::compression ::

file ::result ::style ::

fd ::result ::style ::Changelog file for a really accurate description

+

0.8.0: Apr 22 2001

+
    +
  • fixed ansidecl.h problem
  • +
  • fixed unparsed-entity-uri() and generate-id()
  • +
  • sort semantic fixes and priority prob from William M. Brack
  • +
  • fixed namespace handling problems in XPath expression computations + (requires libxml-2.3.7)
  • +
  • fixes to current() and key()
  • +
  • other, smaller fixes, lots of testing with N Walsh DocBook HTML + stylesheets
  • +
+ +

0.7.0: Apr 10 2001

+
    +
  • cleanup using stricter compiler flags
  • +
  • command line parameter passing
  • +
  • fix to xsltApplyTemplates from William M. Brack
  • +
  • added the XSLTMark in the regression tests as well as document()
  • +
+

0.6.0: Mar 22 2001

  • another beta
  • diff --git a/libxslt/attributes.c b/libxslt/attributes.c index 83f6aaa..dde13ed 100644 --- a/libxslt/attributes.c +++ b/libxslt/attributes.c @@ -46,7 +46,9 @@ #include "imports.h" #include "transform.h" -#define DEBUG_ATTRIBUTES +#ifdef WITH_XSLT_DEBUG +#define WITH_XSLT_DEBUG_ATTRIBUTES +#endif /* * TODO: merge attribute sets from different import precedence. @@ -265,7 +267,7 @@ xsltParseStylesheetAttributeSet(xsltStylesheetPtr style, xmlNodePtr cur) { } if (style->attributeSets == NULL) { -#ifdef DEBUG_ATTRIBUTES +#ifdef WITH_XSLT_DEBUG_ATTRIBUTES xsltGenericDebug(xsltGenericDebugContext, "creating attribute set table\n"); #endif @@ -289,7 +291,7 @@ xsltParseStylesheetAttributeSet(xsltStylesheetPtr style, xmlNodePtr cur) { list->name); delete = list; } else { -#ifdef DEBUG_ATTRIBUTES +#ifdef WITH_XSLT_DEBUG_ATTRIBUTES xsltGenericDebug(xsltGenericDebugContext, "add attribute to list %s\n", ncname); #endif @@ -326,7 +328,7 @@ xsltParseStylesheetAttributeSet(xsltStylesheetPtr style, xmlNodePtr cur) { xmlChar *ncname2 = NULL; xmlChar *prefix2 = NULL; xsltAttrElemPtr values2; -#ifdef DEBUG_ATTRIBUTES +#ifdef WITH_XSLT_DEBUG_ATTRIBUTES xsltGenericDebug(xsltGenericDebugContext, "xslt:attribute-set : %s adds use %s\n", ncname, attribute); #endif @@ -355,7 +357,7 @@ done: * Update the value */ xmlHashUpdateEntry2(style->attributeSets, ncname, prefix, values, NULL); -#ifdef DEBUG_ATTRIBUTES +#ifdef WITH_XSLT_DEBUG_ATTRIBUTES xsltGenericDebug(xsltGenericDebugContext, "updated attribute list %s\n", ncname); #endif @@ -401,7 +403,7 @@ xsltApplyAttributeSet(xsltTransformContextPtr ctxt, xmlNodePtr node, while ((*end != 0) && (!IS_BLANK(*end))) end++; attribute = xmlStrndup(attribute, end - attribute); if (attribute) { -#ifdef DEBUG_ATTRIBUTES +#ifdef WITH_XSLT_DEBUG_ATTRIBUTES xsltGenericDebug(xsltGenericDebugContext, "apply attribute set %s\n", attribute); #endif diff --git a/libxslt/documents.c b/libxslt/documents.c index e461799..40108e0 100644 --- a/libxslt/documents.c +++ b/libxslt/documents.c @@ -19,7 +19,9 @@ #include "documents.h" #include "keys.h" -#define DEBUG_DOCUMENTS +#ifdef WITH_XSLT_DEBUG +#define WITH_XSLT_DEBUG_DOCUMENTS +#endif /************************************************************************ diff --git a/libxslt/extensions.c b/libxslt/extensions.c index b028791..d6d60ef 100644 --- a/libxslt/extensions.c +++ b/libxslt/extensions.c @@ -23,7 +23,9 @@ #include "xsltutils.h" #include "extensions.h" -#define DEBUG_EXTENSIONS +#ifdef WITH_XSLT_DEBUG +#define WITH_XSLT_DEBUG_EXTENSIONS +#endif typedef struct _xsltExtDef xsltExtDef; typedef xsltExtDef *xsltExtDefPtr; diff --git a/libxslt/extra.c b/libxslt/extra.c index 2c19311..354d2e6 100644 --- a/libxslt/extra.c +++ b/libxslt/extra.c @@ -28,7 +28,9 @@ #include "transform.h" #include "extra.h" -#define DEBUG_EXTRA +#ifdef WITH_XSLT_DEBUG +#define WITH_XSLT_DEBUG_EXTRA +#endif /************************************************************************ * * diff --git a/libxslt/functions.c b/libxslt/functions.c index 0aad6fd..30f3166 100644 --- a/libxslt/functions.c +++ b/libxslt/functions.c @@ -39,7 +39,9 @@ #include "keys.h" #include "documents.h" -#define DEBUG_FUNCTION +#ifdef WITH_XSLT_DEBUG +#define WITH_XSLT_DEBUG_FUNCTION +#endif /************************************************************************ diff --git a/libxslt/keys.c b/libxslt/keys.c index 0fd61f5..dc49926 100644 --- a/libxslt/keys.c +++ b/libxslt/keys.c @@ -27,7 +27,9 @@ #include "templates.h" #include "keys.h" -#define DEBUG_KEYS +#ifdef WITH_XSLT_DEBUG +#define WITH_XSLT_DEBUG_KEYS +#endif typedef struct _xsltKeyDef xsltKeyDef; typedef xsltKeyDef *xsltKeyDefPtr; @@ -226,7 +228,7 @@ xsltAddKey(xsltStylesheetPtr style, const xmlChar *name, if ((style == NULL) || (name == NULL) || (match == NULL) || (use == NULL)) return(-1); -#ifdef DEBUG_KEYS +#ifdef WITH_XSLT_DEBUG_KEYS xsltGenericDebug(xsltGenericDebugContext, "Add key %s, match %s, use %s\n", name, match, use); #endif @@ -259,7 +261,7 @@ xsltGetKey(xsltTransformContextPtr ctxt, const xmlChar *name, if ((ctxt == NULL) || (name == NULL) || (value == NULL)) return(NULL); -#ifdef DEBUG_KEYS +#ifdef WITH_XSLT_DEBUG_KEYS xsltGenericDebug(xsltGenericDebugContext, "Get key %s, value %s\n", name, value); #endif @@ -328,21 +330,21 @@ xsltInitCtxtKey(xsltTransformContextPtr ctxt, xsltDocumentPtr doc, if (res != NULL) { if (res->type == XPATH_NODESET) { nodelist = res->nodesetval; -#ifdef DEBUG_KEYS +#ifdef WITH_XSLT_DEBUG_KEYS if (nodelist != NULL) xsltGenericDebug(xsltGenericDebugContext, "xsltInitCtxtKey: %s evaluates to %d nodes\n", pattern, nodelist->nodeNr); #endif } else { -#ifdef DEBUG_KEYS +#ifdef WITH_XSLT_DEBUG_KEYS xsltGenericDebug(xsltGenericDebugContext, "xsltInitCtxtKey: %s is not a node set\n", pattern); #endif goto error; } } else { -#ifdef DEBUG_KEYS +#ifdef WITH_XSLT_DEBUG_KEYS xsltGenericDebug(xsltGenericDebugContext, "xsltInitCtxtKey: %s evaluation failed\n", pattern); #endif @@ -366,7 +368,7 @@ xsltInitCtxtKey(xsltTransformContextPtr ctxt, xsltDocumentPtr doc, ctxt->node = nodelist->nodeTab[i]; str = xsltEvalXPathString(ctxt, comp); if (str != NULL) { -#ifdef DEBUG_KEYS +#ifdef WITH_XSLT_DEBUG_KEYS xsltGenericDebug(xsltGenericDebugContext, "xsl:key : node associated to(%s,%s)\n", keyd->name, str); @@ -380,7 +382,7 @@ xsltInitCtxtKey(xsltTransformContextPtr ctxt, xsltDocumentPtr doc, } nodelist->nodeTab[i]->_private = keyd; xmlFree(str); -#ifdef DEBUG_KEYS +#ifdef WITH_XSLT_DEBUG_KEYS } else { xsltGenericDebug(xsltGenericDebugContext, "xsl:key : use %s failed to return a string\n", @@ -415,7 +417,7 @@ xsltInitCtxtKeys(xsltTransformContextPtr ctxt, xsltDocumentPtr doc) { if ((ctxt == NULL) || (doc == NULL)) return; -#ifdef DEBUG_KEYS +#ifdef WITH_XSLT_DEBUG_KEYS xsltGenericDebug(xsltGenericDebugContext, "Initializing keys on %s\n", doc->doc->URL); #endif diff --git a/libxslt/pattern.c b/libxslt/pattern.c index 7b5532f..5eaba15 100644 --- a/libxslt/pattern.c +++ b/libxslt/pattern.c @@ -32,7 +32,9 @@ #include "keys.h" #include "pattern.h" -#define DEBUG_PATTERN +#ifdef WITH_XSLT_DEBUG +#define WITH_XSLT_DEBUG_PATTERN +#endif /* * Types are private: @@ -1358,7 +1360,7 @@ xsltCompilePattern(const xmlChar *pattern, xmlDocPtr doc, xmlNodePtr node) { return(NULL); } -#ifdef DEBUG_PATTERN +#ifdef WITH_XSLT_DEBUG_PATTERN xsltGenericDebug(xsltGenericDebugContext, "xsltCompilePattern : parsing '%s'\n", pattern); #endif @@ -1612,7 +1614,7 @@ xsltAddTemplate(xsltStylesheetPtr style, xsltTemplatePtr cur, xsltFreeCompMatch(pat); return(-1); } -#ifdef DEBUG_PATTERN +#ifdef WITH_XSLT_DEBUG_PATTERN if (mode) xsltGenericDebug(xsltGenericDebugContext, "added pattern : '%s' mode '%s' priority %f\n", diff --git a/libxslt/preproc.c b/libxslt/preproc.c index e0f08cb..ab5f298 100644 --- a/libxslt/preproc.c +++ b/libxslt/preproc.c @@ -37,7 +37,9 @@ #include "extra.h" #include "imports.h" -#define DEBUG_PREPROC +#ifdef WITH_XSLT_DEBUG +#define WITH_XSLT_DEBUG_PREPROC +#endif /************************************************************************ @@ -197,7 +199,7 @@ xsltDocumentComp(xsltTransformContextPtr ctxt, xmlNodePtr inst) { comp->ver11 = 0; if (xmlStrEqual(inst->name, (const xmlChar *) "output")) { -#ifdef DEBUG_EXTRA +#ifdef WITH_XSLT_DEBUG_EXTRA xsltGenericDebug(xsltGenericDebugContext, "Found saxon:output extension\n"); #endif @@ -205,7 +207,7 @@ xsltDocumentComp(xsltTransformContextPtr ctxt, xmlNodePtr inst) { (const xmlChar *)"file", XSLT_SAXON_NAMESPACE, &comp->has_filename); } else if (xmlStrEqual(inst->name, (const xmlChar *) "write")) { -#ifdef DEBUG_EXTRA +#ifdef WITH_XSLT_DEBUG_EXTRA xsltGenericDebug(xsltGenericDebugContext, "Found xalan:write extension\n"); #endif @@ -217,7 +219,7 @@ xsltDocumentComp(xsltTransformContextPtr ctxt, xmlNodePtr inst) { (const xmlChar *)"href", XSLT_XT_NAMESPACE, &comp->has_filename); if (filename == NULL) { -#ifdef DEBUG_EXTRA +#ifdef WITH_XSLT_DEBUG_EXTRA xsltGenericDebug(xsltGenericDebugContext, "Found xslt11:document construct\n"); #endif @@ -226,7 +228,7 @@ xsltDocumentComp(xsltTransformContextPtr ctxt, xmlNodePtr inst) { XSLT_NAMESPACE, &comp->has_filename); comp->ver11 = 1; } else { -#ifdef DEBUG_EXTRA +#ifdef WITH_XSLT_DEBUG_EXTRA xsltGenericDebug(xsltGenericDebugContext, "Found xt:document extension\n"); #endif diff --git a/libxslt/templates.c b/libxslt/templates.c index 96a54fa..db21a2a 100644 --- a/libxslt/templates.c +++ b/libxslt/templates.c @@ -28,7 +28,9 @@ #include "namespaces.h" #include "attributes.h" -#define DEBUG_TEMPLATES +#ifdef WITH_XSLT_DEBUG +#define WITH_XSLT_DEBUG_TEMPLATES +#endif /************************************************************************ * * @@ -62,12 +64,12 @@ xsltEvalXPathPredicate(xsltTransformContextPtr ctxt, if (res != NULL) { ret = xmlXPathEvalPredicate(ctxt->xpathCtxt, res); xmlXPathFreeObject(res); -#ifdef DEBUG_TEMPLATES +#ifdef WITH_XSLT_DEBUG_TEMPLATES xsltGenericDebug(xsltGenericDebugContext, "xsltEvalXPathPredicate: returns %d\n", ret); #endif } else { -#ifdef DEBUG_TEMPLATES +#ifdef WITH_XSLT_DEBUG_TEMPLATES xsltGenericDebug(xsltGenericDebugContext, "xsltEvalXPathPredicate: failed\n"); #endif @@ -108,7 +110,7 @@ xsltEvalXPathString(xsltTransformContextPtr ctxt, xmlXPathCompExprPtr comp) { } xmlXPathFreeObject(res); } -#ifdef DEBUG_TEMPLATES +#ifdef WITH_XSLT_DEBUG_TEMPLATES xsltGenericDebug(xsltGenericDebugContext, "xsltEvalXPathString: returns %s\n", ret); #endif @@ -249,7 +251,7 @@ xsltEvalAttrValueTemplate(xsltTransformContextPtr ctxt, xmlNodePtr node, */ ret = xsltAttrTemplateValueProcess(ctxt, expr); -#ifdef DEBUG_TEMPLATES +#ifdef WITH_XSLT_DEBUG_TEMPLATES xsltGenericDebug(xsltGenericDebugContext, "xsltEvalXPathString: %s returns %s\n", expr, ret); #endif diff --git a/libxslt/transform.c b/libxslt/transform.c index 10fab3c..45473a8 100644 --- a/libxslt/transform.c +++ b/libxslt/transform.c @@ -49,7 +49,9 @@ #include "extra.h" #include "preproc.h" -#define DEBUG_PROCESS +#ifdef WITH_XSLT_DEBUG +#define WITH_XSLT_DEBUG_PROCESS +#endif int xsltMaxDepth = 250; @@ -458,7 +460,7 @@ xsltDefaultProcessOneNode(xsltTransformContextPtr ctxt, xmlNodePtr node) { if (template) { xmlNodePtr oldNode; -#ifdef DEBUG_PROCESS +#ifdef WITH_XSLT_DEBUG_PROCESS xsltGenericDebug(xsltGenericDebugContext, "xsltDefaultProcessOneNode: applying template for CDATA %s\n", node->content); @@ -470,7 +472,7 @@ xsltDefaultProcessOneNode(xsltTransformContextPtr ctxt, xmlNodePtr node) { templPop(ctxt); ctxt->node = oldNode; } else /* if (ctxt->mode == NULL) */ { -#ifdef DEBUG_PROCESS +#ifdef WITH_XSLT_DEBUG_PROCESS xsltGenericDebug(xsltGenericDebugContext, "xsltDefaultProcessOneNode: copy CDATA %s\n", node->content); @@ -489,7 +491,7 @@ xsltDefaultProcessOneNode(xsltTransformContextPtr ctxt, xmlNodePtr node) { if (template) { xmlNodePtr oldNode; -#ifdef DEBUG_PROCESS +#ifdef WITH_XSLT_DEBUG_PROCESS xsltGenericDebug(xsltGenericDebugContext, "xsltDefaultProcessOneNode: applying template for text %s\n", node->content); @@ -501,7 +503,7 @@ xsltDefaultProcessOneNode(xsltTransformContextPtr ctxt, xmlNodePtr node) { templPop(ctxt); ctxt->node = oldNode; } else /* if (ctxt->mode == NULL) */ { -#ifdef DEBUG_PROCESS +#ifdef WITH_XSLT_DEBUG_PROCESS if (node->content == NULL) xsltGenericDebug(xsltGenericDebugContext, "xsltDefaultProcessOneNode: copy empty text\n"); @@ -586,7 +588,7 @@ xsltDefaultProcessOneNode(xsltTransformContextPtr ctxt, xmlNodePtr node) { nbchild++; break; default: -#ifdef DEBUG_PROCESS +#ifdef WITH_XSLT_DEBUG_PROCESS xsltGenericDebug(xsltGenericDebugContext, "xsltDefaultProcessOneNode: skipping node type %d\n", cur->type); @@ -595,7 +597,7 @@ xsltDefaultProcessOneNode(xsltTransformContextPtr ctxt, xmlNodePtr node) { } cur = cur->next; if (delete != NULL) { -#ifdef DEBUG_PROCESS +#ifdef WITH_XSLT_DEBUG_PROCESS xsltGenericDebug(xsltGenericDebugContext, "xsltDefaultProcessOneNode: removing ignorable blank node\n"); #endif @@ -642,7 +644,7 @@ xsltDefaultProcessOneNode(xsltTransformContextPtr ctxt, xmlNodePtr node) { if (template) { xmlNodePtr oldNode; -#ifdef DEBUG_PROCESS +#ifdef WITH_XSLT_DEBUG_PROCESS xsltGenericDebug(xsltGenericDebugContext, "xsltDefaultProcessOneNode: applying template for CDATA %s\n", node->content); @@ -654,7 +656,7 @@ xsltDefaultProcessOneNode(xsltTransformContextPtr ctxt, xmlNodePtr node) { templPop(ctxt); ctxt->node = oldNode; } else /* if (ctxt->mode == NULL) */ { -#ifdef DEBUG_PROCESS +#ifdef WITH_XSLT_DEBUG_PROCESS xsltGenericDebug(xsltGenericDebugContext, "xsltDefaultProcessOneNode: copy CDATA %s\n", node->content); @@ -673,7 +675,7 @@ xsltDefaultProcessOneNode(xsltTransformContextPtr ctxt, xmlNodePtr node) { if (template) { xmlNodePtr oldNode; -#ifdef DEBUG_PROCESS +#ifdef WITH_XSLT_DEBUG_PROCESS xsltGenericDebug(xsltGenericDebugContext, "xsltDefaultProcessOneNode: applying template for text %s\n", node->content); @@ -687,7 +689,7 @@ xsltDefaultProcessOneNode(xsltTransformContextPtr ctxt, xmlNodePtr node) { templPop(ctxt); ctxt->node = oldNode; } else /* if (ctxt->mode == NULL) */ { -#ifdef DEBUG_PROCESS +#ifdef WITH_XSLT_DEBUG_PROCESS if (cur->content == NULL) xsltGenericDebug(xsltGenericDebugContext, "xsltDefaultProcessOneNode: copy empty text\n"); @@ -755,7 +757,7 @@ xsltProcessOneNode(xsltTransformContextPtr ctxt, xmlNodePtr node) { cur = cur->next; if (delete != NULL) { -#ifdef DEBUG_PROCESS +#ifdef WITH_XSLT_DEBUG_PROCESS xsltGenericDebug(xsltGenericDebugContext, "xsltDefaultProcessOneNode: removing ignorable blank node\n"); #endif @@ -771,7 +773,7 @@ xsltProcessOneNode(xsltTransformContextPtr ctxt, xmlNodePtr node) { * If no template is found, apply the default rule. */ if (template == NULL) { -#ifdef DEBUG_PROCESS +#ifdef WITH_XSLT_DEBUG_PROCESS if (node->type == XML_DOCUMENT_NODE) xsltGenericDebug(xsltGenericDebugContext, "xsltProcessOneNode: no template found for /\n"); @@ -790,7 +792,7 @@ xsltProcessOneNode(xsltTransformContextPtr ctxt, xmlNodePtr node) { } if (node->type == XML_ATTRIBUTE_NODE) { -#ifdef DEBUG_PROCESS +#ifdef WITH_XSLT_DEBUG_PROCESS xsltGenericDebug(xsltGenericDebugContext, "xsltProcessOneNode: applying template for attribute %s\n", node->name); @@ -799,7 +801,7 @@ xsltProcessOneNode(xsltTransformContextPtr ctxt, xmlNodePtr node) { xsltApplyOneTemplate(ctxt, node, template->content, 1); templPop(ctxt); } else { -#ifdef DEBUG_PROCESS +#ifdef WITH_XSLT_DEBUG_PROCESS if (node->type == XML_DOCUMENT_NODE) xsltGenericDebug(xsltGenericDebugContext, "xsltProcessOneNode: applying template for /\n"); @@ -864,7 +866,7 @@ xsltApplyOneTemplate(xsltTransformContextPtr ctxt, xmlNodePtr node, * test, we must have a valid insertion point */ if (insert == NULL) { -#ifdef DEBUG_PROCESS +#ifdef WITH_XSLT_DEBUG_PROCESS xsltGenericDebug(xsltGenericDebugContext, "xsltApplyOneTemplate: insert == NULL !\n"); #endif @@ -904,14 +906,19 @@ xsltApplyOneTemplate(xsltTransformContextPtr ctxt, xmlNodePtr node, } CHECK_STOPPED; goto skip_children; - } else if (cur->type == XML_TEXT_NODE) { + } else if ((cur->type == XML_TEXT_NODE) || + (cur->type == XML_CDATA_SECTION_NODE)) { /* * This text comes from the stylesheet * For stylesheets, the set of whitespace-preserving * element names consists of just xsl:text. */ -#ifdef DEBUG_PROCESS - if (cur->name == xmlStringTextNoenc) +#ifdef WITH_XSLT_DEBUG_PROCESS + if (cur->type == XML_CDATA_SECTION_NODE) + xsltGenericDebug(xsltGenericDebugContext, + "xsltApplyOneTemplate: copy CDATA text %s\n", + cur->content); + else if (cur->name == xmlStringTextNoenc) xsltGenericDebug(xsltGenericDebugContext, "xsltApplyOneTemplate: copy unescaped text %s\n", cur->content); @@ -919,7 +926,7 @@ xsltApplyOneTemplate(xsltTransformContextPtr ctxt, xmlNodePtr node, xsltGenericDebug(xsltGenericDebugContext, "xsltApplyOneTemplate: copy text %s\n", cur->content); #endif - copy = xmlCopyNode(cur, 0); + copy = xmlNewText(cur->content); if (copy != NULL) { xmlAddChild(insert, copy); } else { @@ -939,7 +946,7 @@ xsltApplyOneTemplate(xsltTransformContextPtr ctxt, xmlNodePtr node, "xsltApplyOneTemplate: failed to find extension %s\n", cur->name); } else { -#ifdef DEBUG_PROCESS +#ifdef WITH_XSLT_DEBUG_PROCESS xsltGenericDebug(xsltGenericDebugContext, "xsltApplyOneTemplate: extension construct %s\n", cur->name); #endif @@ -954,7 +961,7 @@ xsltApplyOneTemplate(xsltTransformContextPtr ctxt, xmlNodePtr node, } goto skip_children; } else if (cur->type == XML_ELEMENT_NODE) { -#ifdef DEBUG_PROCESS +#ifdef WITH_XSLT_DEBUG_PROCESS xsltGenericDebug(xsltGenericDebugContext, "xsltApplyOneTemplate: copy node %s\n", cur->name); #endif @@ -1044,7 +1051,7 @@ xsltDocumentElem(xsltTransformContextPtr ctxt, xmlNodePtr node, xmlChar *base = NULL; xmlChar *URL = NULL; if (xmlStrEqual(inst->name, (const xmlChar *) "output")) { -#ifdef DEBUG_EXTRA +#ifdef WITH_XSLT_DEBUG_EXTRA xsltGenericDebug(xsltGenericDebugContext, "Found saxon:output extension\n"); #endif @@ -1052,7 +1059,7 @@ xsltDocumentElem(xsltTransformContextPtr ctxt, xmlNodePtr node, (const xmlChar *)"file", XSLT_SAXON_NAMESPACE); } else if (xmlStrEqual(inst->name, (const xmlChar *) "write")) { -#ifdef DEBUG_EXTRA +#ifdef WITH_XSLT_DEBUG_EXTRA xsltGenericDebug(xsltGenericDebugContext, "Found xalan:write extension\n"); #endif @@ -1064,7 +1071,7 @@ xsltDocumentElem(xsltTransformContextPtr ctxt, xmlNodePtr node, (const xmlChar *)"href", XSLT_XT_NAMESPACE); if (filename == NULL) { -#ifdef DEBUG_EXTRA +#ifdef WITH_XSLT_DEBUG_EXTRA xsltGenericDebug(xsltGenericDebugContext, "Found xslt11:document construct\n"); #endif @@ -1073,7 +1080,7 @@ xsltDocumentElem(xsltTransformContextPtr ctxt, xmlNodePtr node, XSLT_NAMESPACE); comp->ver11 = 1; } else { -#ifdef DEBUG_EXTRA +#ifdef WITH_XSLT_DEBUG_EXTRA xsltGenericDebug(xsltGenericDebugContext, "Found xt:document extension\n"); #endif @@ -1141,7 +1148,7 @@ xsltDocumentElem(xsltTransformContextPtr ctxt, xmlNodePtr node, xsltGenericError(xsltGenericErrorContext, "xsltDocumentElem: unable to save to %s\n", filename); } else { -#ifdef DEBUG_EXTRA +#ifdef WITH_XSLT_DEBUG_EXTRA xsltGenericDebug(xsltGenericDebugContext, "Wrote %d bytes to %s\n", ret, , filename); #endif @@ -1237,7 +1244,7 @@ xsltSort(xsltTransformContextPtr ctxt, xmlNodePtr node, if (res->type == XPATH_NUMBER) { results[i] = res; } else { -#ifdef DEBUG_PROCESS +#ifdef WITH_XSLT_DEBUG_PROCESS xsltGenericDebug(xsltGenericDebugContext, "xsltSort: select didn't evaluate to a number\n"); #endif @@ -1247,7 +1254,7 @@ xsltSort(xsltTransformContextPtr ctxt, xmlNodePtr node, if (res->type == XPATH_STRING) { results[i] = res; } else { -#ifdef DEBUG_PROCESS +#ifdef WITH_XSLT_DEBUG_PROCESS xsltGenericDebug(xsltGenericDebugContext, "xsltSort: select didn't evaluate to a string\n"); #endif @@ -1289,7 +1296,7 @@ xsltCopy(xsltTransformContextPtr ctxt, xmlNodePtr node, case XML_HTML_DOCUMENT_NODE: break; case XML_ELEMENT_NODE: -#ifdef DEBUG_PROCESS +#ifdef WITH_XSLT_DEBUG_PROCESS xsltGenericDebug(xsltGenericDebugContext, "xsl:copy: node %s\n", node->name); #endif @@ -1300,7 +1307,7 @@ xsltCopy(xsltTransformContextPtr ctxt, xmlNodePtr node, } break; case XML_ATTRIBUTE_NODE: { -#ifdef DEBUG_PROCESS +#ifdef WITH_XSLT_DEBUG_PROCESS xsltGenericDebug(xsltGenericDebugContext, "xsl:copy: attribute %s\n", node->name); #endif @@ -1363,7 +1370,8 @@ xsltText(xsltTransformContextPtr ctxt, xmlNodePtr node ATTRIBUTE_UNUSED, xmlNodePtr copy; if (inst->children != NULL) { - if ((inst->children->type != XML_TEXT_NODE) || + if (((inst->children->type != XML_TEXT_NODE) && + (inst->children->type != XML_CDATA_SECTION_NODE)) || (inst->children->next != NULL)) { xsltGenericError(xsltGenericErrorContext, "xslt:text has content problem !\n"); @@ -1372,7 +1380,7 @@ xsltText(xsltTransformContextPtr ctxt, xmlNodePtr node ATTRIBUTE_UNUSED, copy = xmlNewDocText(ctxt->output, text->content); if (comp->noescape) { -#ifdef DEBUG_PARSING +#ifdef WITH_XSLT_DEBUG_PARSING xsltGenericDebug(xsltGenericDebugContext, "Disable escaping: %s\n", text->content); #endif @@ -1444,7 +1452,7 @@ xsltElement(xsltTransformContextPtr ctxt, xmlNodePtr node, } else { if (prefix != NULL) { if (!xmlStrncasecmp(prefix, (xmlChar *)"xml", 3)) { -#ifdef DEBUG_PARSING +#ifdef WITH_XSLT_DEBUG_PARSING xsltGenericDebug(xsltGenericDebugContext, "xslt:element : xml prefix forbidden\n"); #endif @@ -1559,7 +1567,7 @@ xsltAttribute(xsltTransformContextPtr ctxt, xmlNodePtr node, name = ncname; } if (!xmlStrncasecmp(prefix, (xmlChar *)"xml", 3)) { -#ifdef DEBUG_PARSING +#ifdef WITH_XSLT_DEBUG_PARSING xsltGenericDebug(xsltGenericDebugContext, "xslt:attribute : xml prefix forbidden\n"); #endif @@ -1633,7 +1641,7 @@ xsltComment(xsltTransformContextPtr ctxt, xmlNodePtr node, value = xsltEvalTemplateString(ctxt, node, inst); /* TODO: use or generate the compiled form */ /* TODO: check that there is no -- sequence and doesn't end up with - */ -#ifdef DEBUG_PROCESS +#ifdef WITH_XSLT_DEBUG_PROCESS if (value == NULL) xsltGenericDebug(xsltGenericDebugContext, "xsl:comment: empty\n"); @@ -1687,7 +1695,7 @@ xsltProcessingInstruction(xsltTransformContextPtr ctxt, xmlNodePtr node, value = xsltEvalTemplateString(ctxt, node, inst); /* TODO: check that there is no ?> sequence */ -#ifdef DEBUG_PROCESS +#ifdef WITH_XSLT_DEBUG_PROCESS if (value == NULL) xsltGenericDebug(xsltGenericDebugContext, "xsl:processing-instruction: %s empty\n", ncname); @@ -1734,7 +1742,7 @@ xsltCopyOf(xsltTransformContextPtr ctxt, xmlNodePtr node, if (comp->comp == NULL) return; } -#ifdef DEBUG_PROCESS +#ifdef WITH_XSLT_DEBUG_PROCESS xsltGenericDebug(xsltGenericDebugContext, "xsltCopyOf: select %s\n", comp->select); #endif @@ -1790,7 +1798,7 @@ xsltCopyOf(xsltTransformContextPtr ctxt, xmlNodePtr node, xsltGenericError(xsltGenericErrorContext, "xsltCopyOf: text copy failed\n"); } -#ifdef DEBUG_PROCESS +#ifdef WITH_XSLT_DEBUG_PROCESS else xsltGenericDebug(xsltGenericDebugContext, "xslcopyOf: result %s\n", res->stringval); @@ -1829,7 +1837,7 @@ xsltValueOf(xsltTransformContextPtr ctxt, xmlNodePtr node, return; } -#ifdef DEBUG_PROCESS +#ifdef WITH_XSLT_DEBUG_PROCESS xsltGenericDebug(xsltGenericDebugContext, "xsltValueOf: select %s\n", comp->select); #endif @@ -1858,7 +1866,7 @@ xsltValueOf(xsltTransformContextPtr ctxt, xmlNodePtr node, xsltGenericError(xsltGenericErrorContext, "xsltDefaultProcessOneNode: text copy failed\n"); } -#ifdef DEBUG_PROCESS +#ifdef WITH_XSLT_DEBUG_PROCESS else xsltGenericDebug(xsltGenericDebugContext, "xsltValueOf: result %s\n", res->stringval); @@ -2010,7 +2018,7 @@ xsltApplyTemplates(xsltTransformContextPtr ctxt, xmlNodePtr node, if ((ctxt == NULL) || (node == NULL) || (inst == NULL) || (comp == NULL)) return; -#ifdef DEBUG_PROCESS +#ifdef WITH_XSLT_DEBUG_PROCESS xsltGenericDebug(xsltGenericDebugContext, "xsltApplyTemplates: node: %s\n", node->name); #endif @@ -2030,7 +2038,7 @@ xsltApplyTemplates(xsltTransformContextPtr ctxt, xmlNodePtr node, if (comp->comp == NULL) goto error; } -#ifdef DEBUG_PROCESS +#ifdef WITH_XSLT_DEBUG_PROCESS xsltGenericDebug(xsltGenericDebugContext, "xsltApplyTemplates: select %s\n", comp->select); #endif @@ -2052,7 +2060,7 @@ xsltApplyTemplates(xsltTransformContextPtr ctxt, xmlNodePtr node, } } if (list == NULL) { -#ifdef DEBUG_PROCESS +#ifdef WITH_XSLT_DEBUG_PROCESS xsltGenericDebug(xsltGenericDebugContext, "xsltApplyTemplates: select didn't evaluate to a node list\n"); #endif @@ -2089,7 +2097,7 @@ xsltApplyTemplates(xsltTransformContextPtr ctxt, xmlNodePtr node, xmlXPathNodeSetAdd(list, cur); break; default: -#ifdef DEBUG_PROCESS +#ifdef WITH_XSLT_DEBUG_PROCESS xsltGenericDebug(xsltGenericDebugContext, "xsltApplyTemplates: skipping cur type %d\n", cur->type); @@ -2098,7 +2106,7 @@ xsltApplyTemplates(xsltTransformContextPtr ctxt, xmlNodePtr node, } cur = cur->next; if (delete != NULL) { -#ifdef DEBUG_PROCESS +#ifdef WITH_XSLT_DEBUG_PROCESS xsltGenericDebug(xsltGenericDebugContext, "xsltApplyTemplates: removing ignorable blank cur\n"); #endif @@ -2109,7 +2117,7 @@ xsltApplyTemplates(xsltTransformContextPtr ctxt, xmlNodePtr node, } } -#ifdef DEBUG_PROCESS +#ifdef WITH_XSLT_DEBUG_PROCESS if (list != NULL) xsltGenericDebug(xsltGenericDebugContext, "xsltApplyTemplates: list of %d nodes\n", list->nodeNr); @@ -2238,7 +2246,7 @@ xsltChoose(xsltTransformContextPtr ctxt, xmlNodePtr node, "xsl:when: test is not defined\n"); return; } -#ifdef DEBUG_PROCESS +#ifdef WITH_XSLT_DEBUG_PROCESS xsltGenericDebug(xsltGenericDebugContext, "xsl:when: test %s\n", prop); #endif @@ -2261,7 +2269,7 @@ xsltChoose(xsltTransformContextPtr ctxt, xmlNodePtr node, if (res->type == XPATH_BOOLEAN) doit = res->boolval; else { -#ifdef DEBUG_PROCESS +#ifdef WITH_XSLT_DEBUG_PROCESS xsltGenericDebug(xsltGenericDebugContext, "xsl:when: test didn't evaluate to a boolean\n"); #endif @@ -2269,7 +2277,7 @@ xsltChoose(xsltTransformContextPtr ctxt, xmlNodePtr node, } } -#ifdef DEBUG_PROCESS +#ifdef WITH_XSLT_DEBUG_PROCESS xsltGenericDebug(xsltGenericDebugContext, "xsl:when: test evaluate to %d\n", doit); #endif @@ -2294,7 +2302,7 @@ xsltChoose(xsltTransformContextPtr ctxt, xmlNodePtr node, replacement = replacement->next; } if (replacement != NULL) { -#ifdef DEBUG_PROCESS +#ifdef WITH_XSLT_DEBUG_PROCESS xsltGenericDebug(xsltGenericDebugContext, "xsl:otherwise: applying default fallback\n"); #endif @@ -2342,7 +2350,7 @@ xsltIf(xsltTransformContextPtr ctxt, xmlNodePtr node, return; } -#ifdef DEBUG_PROCESS +#ifdef WITH_XSLT_DEBUG_PROCESS xsltGenericDebug(xsltGenericDebugContext, "xsltIf: test %s\n", comp->test); #endif @@ -2361,7 +2369,7 @@ xsltIf(xsltTransformContextPtr ctxt, xmlNodePtr node, if (res->type == XPATH_BOOLEAN) doit = res->boolval; else { -#ifdef DEBUG_PROCESS +#ifdef WITH_XSLT_DEBUG_PROCESS xsltGenericDebug(xsltGenericDebugContext, "xsltIf: test didn't evaluate to a boolean\n"); #endif @@ -2369,7 +2377,7 @@ xsltIf(xsltTransformContextPtr ctxt, xmlNodePtr node, } } -#ifdef DEBUG_PROCESS +#ifdef WITH_XSLT_DEBUG_PROCESS xsltGenericDebug(xsltGenericDebugContext, "xsltIf: test evaluate to %d\n", doit); #endif @@ -2418,7 +2426,7 @@ xsltForEach(xsltTransformContextPtr ctxt, xmlNodePtr node, return; } -#ifdef DEBUG_PROCESS +#ifdef WITH_XSLT_DEBUG_PROCESS xsltGenericDebug(xsltGenericDebugContext, "xsltForEach: select %s\n", comp->select); #endif @@ -2436,14 +2444,14 @@ xsltForEach(xsltTransformContextPtr ctxt, xmlNodePtr node, list = res->nodesetval; } if (list == NULL) { -#ifdef DEBUG_PROCESS +#ifdef WITH_XSLT_DEBUG_PROCESS xsltGenericDebug(xsltGenericDebugContext, "xsltForEach: select didn't evaluate to a node list\n"); #endif goto error; } -#ifdef DEBUG_PROCESS +#ifdef WITH_XSLT_DEBUG_PROCESS xsltGenericDebug(xsltGenericDebugContext, "xsltForEach: select evaluate to %d nodes\n", list->nodeNr); #endif diff --git a/libxslt/variables.c b/libxslt/variables.c index 1e5c9e3..8730de5 100644 --- a/libxslt/variables.c +++ b/libxslt/variables.c @@ -29,7 +29,9 @@ #include "transform.h" #include "imports.h" -#define DEBUG_VARIABLE +#ifdef WITH_XSLT_DEBUG +#define WITH_XSLT_DEBUG_VARIABLE +#endif /************************************************************************ * * @@ -248,7 +250,7 @@ int oldProximityPosition, oldContextSize; if ((ctxt == NULL) || (elem == NULL)) return(-1); -#ifdef DEBUG_VARIABLE +#ifdef WITH_XSLT_DEBUG_VARIABLE xsltGenericDebug(xsltGenericDebugContext, "Evaluating variable %s\n", elem->name); #endif @@ -273,7 +275,7 @@ int oldProximityPosition, oldContextSize; xsltGenericError(xsltGenericErrorContext, "Evaluating variable %s failed\n", elem->name); } else { -#ifdef DEBUG_VARIABLE +#ifdef WITH_XSLT_DEBUG_VARIABLE #ifdef LIBXML_DEBUG_ENABLED if ((xsltGenericDebugContext == stdout) || (xsltGenericDebugContext == stderr)) @@ -314,7 +316,7 @@ int oldProximityPosition, oldContextSize; if (elem->value == NULL) { elem->value = xmlXPathNewCString(""); } -#ifdef DEBUG_VARIABLE +#ifdef WITH_XSLT_DEBUG_VARIABLE #ifdef LIBXML_DEBUG_ENABLED if ((xsltGenericDebugContext == stdout) || (xsltGenericDebugContext == stderr)) @@ -345,7 +347,7 @@ xsltEvalGlobalVariables(xsltTransformContextPtr ctxt) { if (ctxt == NULL) return(-1); -#ifdef DEBUG_VARIABLE +#ifdef WITH_XSLT_DEBUG_VARIABLE xsltGenericDebug(xsltGenericDebugContext, "Evaluating global variables\n"); #endif @@ -390,7 +392,7 @@ xsltRegisterGlobalVariable(xsltStylesheetPtr style, const xmlChar *name, if (name == NULL) return(-1); -#ifdef DEBUG_VARIABLE +#ifdef WITH_XSLT_DEBUG_VARIABLE if (param) xsltGenericDebug(xsltGenericDebugContext, "Defining global param %s\n", name); @@ -449,7 +451,7 @@ xsltEvalUserParams(xsltTransformContextPtr ctxt, const char **params) { if ((name == NULL) || (value == NULL)) break; -#ifdef DEBUG_VARIABLE +#ifdef WITH_XSLT_DEBUG_VARIABLE xsltGenericDebug(xsltGenericDebugContext, "Evaluating user parameter %s=%s\n", name, value); #endif @@ -505,7 +507,7 @@ xsltBuildVariable(xsltTransformContextPtr ctxt, const xmlChar *name, if (name == NULL) return(NULL); -#ifdef DEBUG_VARIABLE +#ifdef WITH_XSLT_DEBUG_VARIABLE xsltGenericDebug(xsltGenericDebugContext, "Building variable %s", name); if (select != NULL) @@ -560,7 +562,7 @@ xsltRegisterVariable(xsltTransformContextPtr ctxt, const xmlChar *name, xsltGenericError(xsltGenericErrorContext, "xsl:variable : redefining %s\n", name); } -#ifdef DEBUG_VARIABLE +#ifdef WITH_XSLT_DEBUG_VARIABLE else xsltGenericDebug(xsltGenericDebugContext, "param %s defined by caller", name); @@ -615,7 +617,7 @@ xsltGlobalVariableLookup(xsltTransformContextPtr ctxt, const xmlChar *name, return(NULL); if (!elem->computed) { -#ifdef DEBUG_VARIABLE +#ifdef WITH_XSLT_DEBUG_VARIABLE xsltGenericDebug(xsltGenericDebugContext, "uncomputed global variable %s\n", name); #endif @@ -623,7 +625,7 @@ xsltGlobalVariableLookup(xsltTransformContextPtr ctxt, const xmlChar *name, } if (elem->value != NULL) return(xmlXPathObjectCopy(elem->value)); -#ifdef DEBUG_VARIABLE +#ifdef WITH_XSLT_DEBUG_VARIABLE xsltGenericDebug(xsltGenericDebugContext, "global variable not found %s\n", name); #endif @@ -654,7 +656,7 @@ xsltVariableLookup(xsltTransformContextPtr ctxt, const xmlChar *name, return(xsltGlobalVariableLookup(ctxt, name, ns_uri)); } if (!elem->computed) { -#ifdef DEBUG_VARIABLE +#ifdef WITH_XSLT_DEBUG_VARIABLE xsltGenericDebug(xsltGenericDebugContext, "uncomputed variable %s\n", name); #endif @@ -662,7 +664,7 @@ xsltVariableLookup(xsltTransformContextPtr ctxt, const xmlChar *name, } if (elem->value != NULL) return(xmlXPathObjectCopy(elem->value)); -#ifdef DEBUG_VARIABLE +#ifdef WITH_XSLT_DEBUG_VARIABLE xsltGenericDebug(xsltGenericDebugContext, "variable not found %s\n", name); #endif @@ -697,7 +699,7 @@ xsltParseStylesheetCallerParam(xsltTransformContextPtr ctxt, xmlNodePtr cur) { return(NULL); } -#ifdef DEBUG_VARIABLE +#ifdef WITH_XSLT_DEBUG_VARIABLE xsltGenericDebug(xsltGenericDebugContext, "Parsing param %s\n", name); #endif @@ -706,7 +708,7 @@ xsltParseStylesheetCallerParam(xsltTransformContextPtr ctxt, xmlNodePtr cur) { if (select == NULL) { tree = cur->children; } else { -#ifdef DEBUG_VARIABLE +#ifdef WITH_XSLT_DEBUG_VARIABLE xsltGenericDebug(xsltGenericDebugContext, " select %s\n", select); #endif @@ -769,7 +771,7 @@ xsltParseStylesheetParam(xsltTransformContextPtr ctxt, xmlNodePtr cur) { return; } -#ifdef DEBUG_VARIABLE +#ifdef WITH_XSLT_DEBUG_VARIABLE xsltGenericDebug(xsltGenericDebugContext, "Parsing param %s\n", name); #endif @@ -778,7 +780,7 @@ xsltParseStylesheetParam(xsltTransformContextPtr ctxt, xmlNodePtr cur) { if (select == NULL) { tree = cur->children; } else { -#ifdef DEBUG_VARIABLE +#ifdef WITH_XSLT_DEBUG_VARIABLE xsltGenericDebug(xsltGenericDebugContext, " select %s\n", select); #endif @@ -840,7 +842,7 @@ xsltParseGlobalVariable(xsltStylesheetPtr style, xmlNodePtr cur) { return; } -#ifdef DEBUG_VARIABLE +#ifdef WITH_XSLT_DEBUG_VARIABLE xsltGenericDebug(xsltGenericDebugContext, "Parsing global variable %s\n", name); #endif @@ -909,7 +911,7 @@ xsltParseGlobalParam(xsltStylesheetPtr style, xmlNodePtr cur) { return; } -#ifdef DEBUG_VARIABLE +#ifdef WITH_XSLT_DEBUG_VARIABLE xsltGenericDebug(xsltGenericDebugContext, "Parsing global param %s\n", name); #endif @@ -977,7 +979,7 @@ xsltParseStylesheetVariable(xsltTransformContextPtr ctxt, xmlNodePtr cur) { return; } -#ifdef DEBUG_VARIABLE +#ifdef WITH_XSLT_DEBUG_VARIABLE xsltGenericDebug(xsltGenericDebugContext, "Parsing variable %s\n", name); #endif @@ -1039,7 +1041,7 @@ xsltXPathVariableLookup(void *ctxt, const xmlChar *name, if ((ctxt == NULL) || (name == NULL)) return(NULL); -#ifdef DEBUG_VARIABLE +#ifdef WITH_XSLT_DEBUG_VARIABLE xsltGenericDebug(xsltGenericDebugContext, "Lookup variable %s\n", name); #endif @@ -1049,7 +1051,7 @@ xsltXPathVariableLookup(void *ctxt, const xmlChar *name, xsltGenericError(xsltGenericErrorContext, "unregistered variable %s\n", name); } -#ifdef DEBUG_VARIABLE +#ifdef WITH_XSLT_DEBUG_VARIABLE if (ret != NULL) xsltGenericDebug(xsltGenericDebugContext, "found variable %s\n", name); diff --git a/libxslt/xslt.c b/libxslt/xslt.c index 845db24..1ba7106 100644 --- a/libxslt/xslt.c +++ b/libxslt/xslt.c @@ -33,8 +33,10 @@ #include "documents.h" #include "extensions.h" -#define DEBUG_PARSING -/* #define DEBUG_BLANKS */ +#ifdef WITH_XSLT_DEBUG +#define WITH_XSLT_DEBUG_PARSING +/* #define WITH_XSLT_DEBUG_BLANKS */ +#endif /* * Useful macros @@ -466,7 +468,7 @@ xsltParseStylesheetOutput(xsltStylesheetPtr style, xmlNodePtr cur) { while ((*end != 0) && (!IS_BLANK(*end))) end++; element = xmlStrndup(element, end - element); if (element) { -#ifdef DEBUG_PARSING +#ifdef WITH_XSLT_DEBUG_PARSING xsltGenericDebug(xsltGenericDebugContext, "add cdata section output element %s\n", element); #endif @@ -620,7 +622,7 @@ xsltParseStylesheetPreserveSpace(xsltStylesheetPtr style, xmlNodePtr cur) { while ((*end != 0) && (!IS_BLANK(*end))) end++; element = xmlStrndup(element, end - element); if (element) { -#ifdef DEBUG_PARSING +#ifdef WITH_XSLT_DEBUG_PARSING xsltGenericDebug(xsltGenericDebugContext, "add preserved space element %s\n", element); #endif @@ -680,7 +682,7 @@ xsltParseStylesheetExtPrefix(xsltStylesheetPtr style, xmlNodePtr cur) { "xsl:extension-element-prefix : undefined namespace %s\n", prefix); } else { -#ifdef DEBUG_PARSING +#ifdef WITH_XSLT_DEBUG_PARSING xsltGenericDebug(xsltGenericDebugContext, "add extension prefix %s\n", prefix); #endif @@ -731,7 +733,7 @@ xsltParseStylesheetStripSpace(xsltStylesheetPtr style, xmlNodePtr cur) { while ((*end != 0) && (!IS_BLANK(*end))) end++; element = xmlStrndup(element, end - element); if (element) { -#ifdef DEBUG_PARSING +#ifdef WITH_XSLT_DEBUG_PARSING xsltGenericDebug(xsltGenericDebugContext, "add stripped space element %s\n", element); #endif @@ -771,7 +773,7 @@ xsltParseRemoveBlanks(xsltStylesheetPtr style) { delete = NULL; while (cur != NULL) { if (delete != NULL) { -#ifdef DEBUG_BLANKS +#ifdef WITH_XSLT_DEBUG_BLANKS xsltGenericDebug(xsltGenericDebugContext, "xsltParseRemoveBlanks: removing ignorable blank node\n"); #endif @@ -823,7 +825,7 @@ skip_children: } while (cur != NULL); } if (delete != NULL) { -#ifdef DEBUG_PARSING +#ifdef WITH_XSLT_DEBUG_PARSING xsltGenericDebug(xsltGenericDebugContext, "xsltParseRemoveBlanks: removing ignorable blank node\n"); #endif @@ -873,7 +875,7 @@ xsltGatherNamespaces(xsltStylesheetPtr style) { xmlHashUpdateEntry(style->nsHash, ns->prefix, (void *) ns->href, (xmlHashDeallocator)xmlFree); -#ifdef DEBUG_PARSING +#ifdef WITH_XSLT_DEBUG_PARSING xsltGenericDebug(xsltGenericDebugContext, "Added namespace: %s mapped to %s\n", ns->prefix, ns->href); #endif @@ -938,7 +940,7 @@ xsltParseTemplateContent(xsltStylesheetPtr style, xsltTemplatePtr ret, delete = NULL; while (cur != NULL) { if (delete != NULL) { -#ifdef DEBUG_BLANKS +#ifdef WITH_XSLT_DEBUG_BLANKS xsltGenericDebug(xsltGenericDebugContext, "xsltParseTemplateContent: removing text\n"); #endif @@ -949,10 +951,11 @@ xsltParseTemplateContent(xsltStylesheetPtr style, xsltTemplatePtr ret, if (IS_XSLT_ELEM(cur)) { if (IS_XSLT_NAME(cur, "text")) { if (cur->children != NULL) { - if ((cur->children->type != XML_TEXT_NODE) || + if (((cur->children->type != XML_TEXT_NODE) && + (cur->children->type != XML_CDATA_SECTION_NODE)) || (cur->children->next != NULL)) { xsltGenericError(xsltGenericErrorContext, - "xsltParseStylesheetTemplate: xslt:text content problem\n"); + "xsltParseTemplateContent: xslt:text content problem\n"); } else { xmlChar *prop; xmlNodePtr text = cur->children; @@ -961,7 +964,7 @@ xsltParseTemplateContent(xsltStylesheetPtr style, xsltTemplatePtr ret, (const xmlChar *)"disable-output-escaping", XSLT_NAMESPACE); if (prop != NULL) { -#ifdef DEBUG_PARSING +#ifdef WITH_XSLT_DEBUG_PARSING xsltGenericDebug(xsltGenericDebugContext, "Disable escaping: %s\n", text->content); #endif @@ -1021,7 +1024,7 @@ skip_children: } while (cur != NULL); } if (delete != NULL) { -#ifdef DEBUG_PARSING +#ifdef WITH_XSLT_DEBUG_PARSING xsltGenericDebug(xsltGenericDebugContext, "xsltParseStylesheetTemplate: removing text\n"); #endif @@ -1113,7 +1116,7 @@ xsltParseStylesheetKey(xsltStylesheetPtr style, xmlNodePtr key) { name = prop; nameURI = NULL; } -#ifdef DEBUG_PARSING +#ifdef WITH_XSLT_DEBUG_PARSING xsltGenericDebug(xsltGenericDebugContext, "xslt:key: name %s\n", name); #endif @@ -1215,7 +1218,7 @@ xsltParseStylesheetTemplate(xsltStylesheetPtr style, xmlNodePtr template) { mode = prop; modeURI = NULL; } -#ifdef DEBUG_PARSING +#ifdef WITH_XSLT_DEBUG_PARSING xsltGenericDebug(xsltGenericDebugContext, "xslt:template: mode %s\n", mode); #endif @@ -1297,7 +1300,7 @@ static void xsltParseStylesheetTop(xsltStylesheetPtr style, xmlNodePtr top) { xmlNodePtr cur; xmlChar *prop; -#ifdef DEBUG_PARSING +#ifdef WITH_XSLT_DEBUG_PARSING int templates = 0; #endif @@ -1327,7 +1330,7 @@ xsltParseStylesheetTop(xsltStylesheetPtr style, xmlNodePtr top) { continue; } if (!(IS_XSLT_ELEM(cur))) { -#ifdef DEBUG_PARSING +#ifdef WITH_XSLT_DEBUG_PARSING xsltGenericDebug(xsltGenericDebugContext, "xsltParseStylesheetTop : found foreign element %s\n", cur->name); @@ -1343,7 +1346,7 @@ xsltParseStylesheetTop(xsltStylesheetPtr style, xmlNodePtr top) { } while (cur != NULL) { if (!(IS_XSLT_ELEM(cur))) { -#ifdef DEBUG_PARSING +#ifdef WITH_XSLT_DEBUG_PARSING xsltGenericDebug(xsltGenericDebugContext, "xsltParseStylesheetTop : found foreign element %s\n", cur->name); @@ -1373,7 +1376,7 @@ xsltParseStylesheetTop(xsltStylesheetPtr style, xmlNodePtr top) { } else if (IS_XSLT_NAME(cur, "param")) { xsltParseGlobalParam(style, cur); } else if (IS_XSLT_NAME(cur, "template")) { -#ifdef DEBUG_PARSING +#ifdef WITH_XSLT_DEBUG_PARSING templates++; #endif xsltParseStylesheetTemplate(style, cur); @@ -1386,7 +1389,7 @@ xsltParseStylesheetTop(xsltStylesheetPtr style, xmlNodePtr top) { } cur = cur->next; } -#ifdef DEBUG_PARSING +#ifdef WITH_XSLT_DEBUG_PARSING xsltGenericDebug(xsltGenericDebugContext, "parsed %d templates\n", templates); #endif @@ -1428,7 +1431,7 @@ xsltParseStylesheetProcess(xsltStylesheetPtr ret, xmlDocPtr doc) { if ((IS_XSLT_ELEM(cur)) && ((IS_XSLT_NAME(cur, "stylesheet")) || (IS_XSLT_NAME(cur, "transform")))) { -#ifdef DEBUG_PARSING +#ifdef WITH_XSLT_DEBUG_PARSING xsltGenericDebug(xsltGenericDebugContext, "xsltParseStylesheetProcess : found stylesheet\n"); #endif @@ -1449,7 +1452,7 @@ xsltParseStylesheetProcess(xsltStylesheetPtr ret, xmlDocPtr doc) { return(NULL); } -#ifdef DEBUG_PARSING +#ifdef WITH_XSLT_DEBUG_PARSING xsltGenericDebug(xsltGenericDebugContext, "xsltParseStylesheetProcess : document is stylesheet\n"); #endif @@ -1528,7 +1531,7 @@ xsltParseStylesheetFile(const xmlChar* filename) { if (filename == NULL) return(NULL); -#ifdef DEBUG_PARSING +#ifdef WITH_XSLT_DEBUG_PARSING xsltGenericDebug(xsltGenericDebugContext, "xsltParseStylesheetFile : parse %s\n", filename); #endif diff --git a/libxslt/xsltconfig.h.in b/libxslt/xsltconfig.h.in index 9d21a81..cc4a8c8 100644 --- a/libxslt/xsltconfig.h.in +++ b/libxslt/xsltconfig.h.in @@ -15,6 +15,10 @@ extern "C" { #endif +#if @WITH_XSLT_DEBUG@ +#define WITH_XSLT_DEBUG +#endif + #if @WITH_MEM_DEBUG@ #define DEBUG_MEMORY #define DEBUG_MEMORY_LOCATION diff --git a/tests/XSLTMark/metric.out b/tests/XSLTMark/metric.out index 7c024f6..b6f05a3 100644 --- a/tests/XSLTMark/metric.out +++ b/tests/XSLTMark/metric.out @@ -1,16 +1,16 @@ 12362180 - 521.647199999 + 521.6472 276683.33 - 0.000136701399 - 1.275587996 + 0.0001367014 + 1.275588 1332004.8 - 95012.388419899 + 95012.3884199 0.00250598521 39370 8.612395272 - 0.0470252298 - 0.0000893530059 + 0.04702523 + 0.000089353006 3031490 diff --git a/tests/docs/bug-9-.xml b/tests/docs/bug-9-.xml new file mode 100644 index 0000000..f381066 --- /dev/null +++ b/tests/docs/bug-9-.xml @@ -0,0 +1,3 @@ + + + diff --git a/tests/general/bug-5-.out b/tests/general/bug-5-.out index d849c28..b1d9e89 100644 --- a/tests/general/bug-5-.out +++ b/tests/general/bug-5-.out @@ -29,9 +29,9 @@ ACT PROD "/>OrangeProj. Rev: 1743250Actual Rev: 10695.229999999OrangeProj. Rev: 1743250Actual Rev: 10695.23PICKProj. Rev: 1159000Act. Rev: 9964.479999999
    Non-RecurringNumber: 229Proj. Rev: 0Act. Rev: 8300
    SegmentNumberProj. RevAct. Rev
    Pine3401420
    Almond1025
    Birch80300
    Elm18606555
    RecurringNumber: 284Proj. Rev: 1159000Act. Rev: 1664.479999999
    SegmentNumberProj. RevAct. Rev
    Pine36171000221.3
    Elm2409500001412.34
    Birch83800030.84
    PICKProj. Rev: 1159000Act. Rev: 9964.48
    Non-RecurringNumber: 229Proj. Rev: 0Act. Rev: 8300
    SegmentNumberProj. RevAct. Rev
    Pine3401420
    Almond1025
    Birch80300
    Elm18606555
    RecurringNumber: 284Proj. Rev: 1159000Act. Rev: 1664.48
    SegmentNumberProj. RevAct. Rev
    Pine36171000221.3
    Elm2409500001412.34
    Birch83800030.84
    SQUEEZEProj. Rev: 584250Act. Rev: 730.749999999
    RecurringNumber: 123Proj. Rev: 584250Act. Rev: 730.749999999
    SegmentNumberProj. RevAct. Rev
    Pine36171000221.3
    Elm80380000470.78
    Birch41900015.42
    Almond31425023.25
    SQUEEZEProj. Rev: 584250Act. Rev: 730.75
    RecurringNumber: 123Proj. Rev: 584250Act. Rev: 730.75
    SegmentNumberProj. RevAct. Rev
    Pine36171000221.3
    Elm80380000470.78
    Birch41900015.42
    Almond31425023.25
    PineappleProj. Rev: 36250Actual Rev: 73.129999999PineappleProj. Rev: 36250Actual Rev: 73.13PICKProj. Rev: 23750Act. Rev: 68.75
    Non-RecurringNumber: 1Proj. Rev: 0Act. Rev: 50
    SegmentNumberProj. RevAct. Rev
    Pine1050
    RecurringNumber: 3Proj. Rev: 23750Act. Rev: 18.75
    SegmentNumberProj. RevAct. Rev
    Pine2175008.75
    Birch1625010
    SQUEEZEProj. Rev: 12500Act. Rev: 4.379999999
    RecurringNumber: 2Proj. Rev: 12500Act. Rev: 4.379999999
    SegmentNumberProj. RevAct. Rev
    Elm2125004.38
    SQUEEZEProj. Rev: 12500Act. Rev: 4.38
    RecurringNumber: 2Proj. Rev: 12500Act. Rev: 4.38
    SegmentNumberProj. RevAct. Rev
    Elm2125004.38
    GuavaProj. Rev: 14995Actual Rev: -19.489999999GuavaProj. Rev: 14995Actual Rev: -19.49SQUEEZEProj. Rev: 14995Act. Rev: -19.489999999
    RecurringNumber: 1Proj. Rev: 14995Act. Rev: -19.489999999
    SegmentNumberProj. RevAct. Rev
    Pine114995-19.49
    SQUEEZEProj. Rev: 14995Act. Rev: -19.49
    RecurringNumber: 1Proj. Rev: 14995Act. Rev: -19.49
    SegmentNumberProj. RevAct. Rev
    Pine114995-19.49
    RaisinProj. Rev: 299925Actual Rev: 227.949999999RaisinProj. Rev: 299925Actual Rev: 227.95EATProj. Rev: 0Act. Rev: 0
    Non-RecurringNumber: 17Proj. Rev: 0Act. Rev: 0
    SegmentNumberProj. RevAct. Rev
    Oak1700
    SQUEEZEProj. Rev: 299925Act. Rev: 227.949999999
    RecurringNumber: 15Proj. Rev: 299925Act. Rev: 227.949999999
    SegmentNumberProj. RevAct. Rev
    Oak15299925227.95
    SQUEEZEProj. Rev: 299925Act. Rev: 227.95
    RecurringNumber: 15Proj. Rev: 299925Act. Rev: 227.95
    SegmentNumberProj. RevAct. Rev
    Oak15299925227.95
    FigProj. Rev: 74990Actual Rev: 136.24PICKProj. Rev: 74990Act. Rev: 136.24
    Non-RecurringNumber: 1Proj. Rev: 0Act. Rev: 50
    SegmentNumberProj. RevAct. Rev
    Oak1050
    RecurringNumber: 2Proj. Rev: 74990Act. Rev: 86.239999999
    SegmentNumberProj. RevAct. Rev
    Oak27499086.24
    PICKProj. Rev: 74990Act. Rev: 136.24
    Non-RecurringNumber: 1Proj. Rev: 0Act. Rev: 50
    SegmentNumberProj. RevAct. Rev
    Oak1050
    RecurringNumber: 2Proj. Rev: 74990Act. Rev: 86.24
    SegmentNumberProj. RevAct. Rev
    Oak27499086.24
    + + + + +Success + + + -- 2.7.4