Chasing bugs in XSLT, hard ...:
authorDaniel Veillard <veillard@src.gnome.org>
Mon, 12 Feb 2001 17:32:42 +0000 (17:32 +0000)
committerDaniel Veillard <veillard@src.gnome.org>
Mon, 12 Feb 2001 17:32:42 +0000 (17:32 +0000)
- libxslt/FEATURES libxslt/transform.c: added support for
  disable-output-escaping in xsl:copy-of
- xmlspec/Makefile.am libxslt/variables.c libxslt/transform.c:
  give more debugging info
Daniel

ChangeLog
FEATURES
libxslt/transform.c
libxslt/variables.c
tests/xmlspec/Makefile.am

index b99ae37..b73f03e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Mon Feb 12 18:30:26 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/FEATURES libxslt/transform.c: added support for
+         disable-output-escaping in xsl:copy-of
+       * xmlspec/Makefile.am libxslt/variables.c libxslt/transform.c:
+         give more debugging info
+
 Sun Feb 11 21:08:35 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
 
        * libxslt/documents.[ch] libxslt/functions.c libxslt/imports.c
index e3b38a5..f4e8949 100644 (file)
--- a/FEATURES
+++ b/FEATURES
@@ -114,7 +114,7 @@ YES                         use-attribute-sets = qnames
 
 YES                        xsl:value-of
 YES                            select = string-expression 
-NO                             disable-output-escaping = "yes" | "no"
+YES                            disable-output-escaping = "yes" | "no"
 
 YES                        xsl:number
 PARTIAL                                level = "single" | "multiple" | "any"
index 294d5a5..b67ba56 100644 (file)
@@ -22,6 +22,7 @@
 #include <libxml/encoding.h>
 #include <libxml/xmlerror.h>
 #include <libxml/xpath.h>
+#include <libxml/parserInternals.h>
 #include <libxml/xpathInternals.h>
 #include <libxml/HTMLtree.h>
 #include "xslt.h"
@@ -642,6 +643,12 @@ xsltCopyOf(xsltTransformContextPtr ctxt, xmlNodePtr node,
     if ((ctxt == NULL) || (node == NULL) || (inst == NULL))
        return;
 
+    prop = xmlGetNsProp(inst, (const xmlChar *)"select", XSLT_NAMESPACE);
+    if (prop == NULL) {
+       xsltGenericError(xsltGenericErrorContext,
+            "xslt:copy-of : select is missing\n");
+       goto error;
+    }
 #ifdef DEBUG_PROCESS
     xsltGenericDebug(xsltGenericDebugContext,
         "xsltCopyOf: select %s\n", prop);
@@ -752,9 +759,6 @@ xsltValueOf(xsltTransformContextPtr ctxt, xmlNodePtr node,
                 "invalud value %s for disable-output-escaping\n", prop);
 
        xmlFree(prop);
-       if (disableEscaping) {
-           TODO /* disable-output-escaping */
-       }
     }
     prop = xmlGetNsProp(inst, (const xmlChar *)"select", XSLT_NAMESPACE);
     if (prop == NULL) {
@@ -785,6 +789,8 @@ xsltValueOf(xsltTransformContextPtr ctxt, xmlNodePtr node,
        if (res->type == XPATH_STRING) {
             copy = xmlNewText(res->stringval);
            if (copy != NULL) {
+               if (disableEscaping)
+                   copy->name = xmlStringTextNoenc;
                xmlAddChild(ctxt->insert, copy);
            }
        }
@@ -947,11 +953,21 @@ xsltDefaultProcessOneNode(xsltTransformContextPtr ctxt, xmlNodePtr node) {
            if (template) {
                xmlNodePtr oldNode;
 
+#ifdef DEBUG_PROCESS
+               xsltGenericDebug(xsltGenericDebugContext,
+                "xsltDefaultProcessOneNode: applying template for text %s\n",
+                                node->content);
+#endif
                oldNode = ctxt->node;
                ctxt->node = node;
                xsltApplyOneTemplate(ctxt, node, template->content);
                ctxt->node = oldNode;
-           } else if (ctxt->mode == NULL) {
+           } else /* if (ctxt->mode == NULL) */ {
+#ifdef DEBUG_PROCESS
+               xsltGenericDebug(xsltGenericDebugContext,
+                "xsltDefaultProcessOneNode: copy text %s\n",
+                                node->content);
+#endif
                copy = xmlCopyNode(node, 0);
                if (copy != NULL) {
                    xmlAddChild(ctxt->insert, copy);
@@ -1081,13 +1097,23 @@ xsltDefaultProcessOneNode(xsltTransformContextPtr ctxt, xmlNodePtr node) {
                if (template) {
                    xmlNodePtr oldNode;
 
+#ifdef DEBUG_PROCESS
+                   xsltGenericDebug(xsltGenericDebugContext,
+                "xsltDefaultProcessOneNode: applying template for text %s\n",
+                                    node->content);
+#endif
                    oldNode = ctxt->node;
                    ctxt->node = cur;
                    ctxt->xpathCtxt->contextSize = nbchild;
                    ctxt->xpathCtxt->proximityPosition = childno;
                    xsltApplyOneTemplate(ctxt, cur, template->content);
                    ctxt->node = oldNode;
-               } else if (ctxt->mode == NULL) {
+               } else /* if (ctxt->mode == NULL) */ {
+#ifdef DEBUG_PROCESS
+                   xsltGenericDebug(xsltGenericDebugContext,
+                    "xsltDefaultProcessOneNode: copy text %s\n",
+                                    node->content);
+#endif
                    copy = xmlCopyNode(cur, 0);
                    if (copy != NULL) {
                        xmlAddChild(ctxt->insert, copy);
@@ -1537,8 +1563,13 @@ xsltApplyOneTemplate(xsltTransformContextPtr ctxt, xmlNodePtr node,
             * element names consists of just xsl:text.
             */
 #ifdef DEBUG_PROCESS
-           xsltGenericDebug(xsltGenericDebugContext,
-                "xsltApplyOneTemplate: copy text %s\n", cur->content);
+           if (cur->name == xmlStringTextNoenc)
+               xsltGenericDebug(xsltGenericDebugContext,
+                    "xsltApplyOneTemplate: copy unescaped text %s\n",
+                                cur->content);
+           else
+               xsltGenericDebug(xsltGenericDebugContext,
+                    "xsltApplyOneTemplate: copy text %s\n", cur->content);
 #endif
            copy = xmlCopyNode(cur, 0);
            if (copy != NULL) {
index e19a030..4ea0175 100644 (file)
@@ -324,6 +324,12 @@ xsltEvalVariables(xsltTransformContextPtr ctxt, xsltStackElemPtr elem) {
        if (xpathParserCtxt != NULL)
            xmlXPathFreeParserContext(xpathParserCtxt);
        if (result != NULL) {
+#ifdef DEBUG_VARIABLE
+           if ((xsltGenericDebugContext == stdout) ||
+               (xsltGenericDebugContext == stderr))
+               xmlXPathDebugDumpObject((FILE *)xsltGenericDebugContext,
+                                       result, 0);
+#endif
            if (elem->value != NULL)
                xmlXPathFreeObject(elem->value);
            elem->value = result;
@@ -468,7 +474,11 @@ xsltRegisterVariable(xsltTransformContextPtr ctxt, const xmlChar *name,
 
 #ifdef DEBUG_VARIABLE
     xsltGenericDebug(xsltGenericDebugContext,
-                    "Defineing variable %s\n", name);
+                    "Defineing variable %s", name);
+    if (select != NULL)
+       xsltGenericDebug(xsltGenericDebugContext,
+                        " select %s",  select);
+    xsltGenericDebug(xsltGenericDebugContext, "\n");
 #endif
     elem = xsltNewStackElem();
     if (elem == NULL)
@@ -478,7 +488,10 @@ xsltRegisterVariable(xsltTransformContextPtr ctxt, const xmlChar *name,
     else
        elem->type = XSLT_ELEM_VARIABLE;
     elem->name = xmlStrdup(name);
-    elem->select = xmlStrdup(select);
+    if (select != NULL)
+       elem->select = xmlStrdup(select);
+    else
+       elem->select = NULL;
     if (ns_uri)
        elem->nameURI = xmlStrdup(ns_uri);
     elem->tree = tree;
@@ -846,7 +859,7 @@ xsltParseStylesheetVariable(xsltTransformContextPtr ctxt, xmlNodePtr cur) {
     } else {
        if (cur->children != NULL)
            xsltGenericError(xsltGenericErrorContext,
-           "xsl:variable : content shuld be empty since select is present \n");
+       "xsl:variable : content should be empty since select is present \n");
     }
 
     ncname = xmlSplitQName2(name, &prefix);
index e3d10f1..f1cf513 100644 (file)
@@ -12,7 +12,7 @@ test tests: $(top_builddir)/libxslt/xsltproc
        @(rm -f .memdump ; touch .memdump)
        @($(top_builddir)/libxslt/xsltproc -timing -v xmlspec.xsl REC-xml-20001006.xml > REC-xml-20001006.html 2> debug ; \
        grep implemented debug | sort | uniq -c ; \
-       grep "ms$$" debug ; \
+       grep " ms$$" debug ; \
        grep "MORY ALLO" .memdump  | grep -v "MEMORY ALLOCATED : 0";\
        rm -f doc.res)