- libxslt/preproc.c libxslt/xslt.c libxslt/xsltInternals.h
authorDaniel Veillard <veillard@src.gnome.org>
Mon, 30 Apr 2001 17:33:47 +0000 (17:33 +0000)
committerDaniel Veillard <veillard@src.gnome.org>
Mon, 30 Apr 2001 17:33:47 +0000 (17:33 +0000)
  libxslt/xsltproc.c: counting errors and warnings at compilation
  time. Stop processing in case of error.
- tests/docs/bug-1[89]* tests/general/-1[89]* tests/general/inner.xsl:
  added more namespace related bug checks
Daniel

14 files changed:
ChangeLog
libxslt/preproc.c
libxslt/xslt.c
libxslt/xsltInternals.h
libxslt/xsltproc.c
tests/docs/Makefile.am
tests/docs/bug-18-.xml [new file with mode: 0644]
tests/docs/bug-19-.xml [new file with mode: 0644]
tests/general/Makefile.am
tests/general/bug-18-.out [new file with mode: 0644]
tests/general/bug-18-.xsl [new file with mode: 0644]
tests/general/bug-19-.out [new file with mode: 0644]
tests/general/bug-19-.xsl [new file with mode: 0644]
tests/general/inner.xsl [new file with mode: 0644]

index 298c2a2..fb4bed5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+Mon Apr 30 19:29:34 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+       * libxslt/preproc.c libxslt/xslt.c libxslt/xsltInternals.h
+         libxslt/xsltproc.c: counting errors and warnings at compilation
+         time. Stop processing in case of error.
+       * tests/docs/bug-1[89]* tests/general/-1[89]* tests/general/inner.xsl:
+         added more namespace related bug checks
+
 Mon Apr 30 13:47:11 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
 
        * libxslt/preproc.c libxslt/variables.c: found the source of a
index 8448d3e..d0d8bdf 100644 (file)
@@ -66,6 +66,7 @@ xsltNewStylePreComp(xsltStylesheetPtr style, xsltStyleType type) {
     if (cur == NULL) {
         xsltGenericError(xsltGenericErrorContext,
                "xsltNewStylePreComp : malloc failed\n");
+       style->errors++;
        return(NULL);
     }
     memset(cur, 0, sizeof(xsltStylePreComp));
@@ -118,6 +119,7 @@ xsltNewStylePreComp(xsltStylesheetPtr style, xsltStyleType type) {
        if (cur->func == NULL) {
            xsltGenericError(xsltGenericErrorContext,
                    "xsltNewStylePreComp : no function for type %d\n", type);
+           style->errors++;
        }
     }
     cur->next = style->preComps;
@@ -224,7 +226,7 @@ xsltDocumentComp(xsltStylesheetPtr style, xmlNodePtr inst) {
        filename = xsltEvalStaticAttrValueTemplate(style, inst,
                         (const xmlChar *)"href",
                         XSLT_XT_NAMESPACE, &comp->has_filename);
-       if (filename == NULL) {
+       if (comp->has_filename == 0) {
 #ifdef WITH_XSLT_DEBUG_EXTRA
            xsltGenericDebug(xsltGenericDebugContext,
                "Found xslt11:document construct\n");
@@ -244,6 +246,7 @@ xsltDocumentComp(xsltStylesheetPtr style, xmlNodePtr inst) {
     if (!comp->has_filename) {
        xsltGenericError(xsltGenericErrorContext,
            "xsltDocumentComp: could not find the href\n");
+       style->errors++;
        goto error;
     }
 
@@ -256,6 +259,7 @@ xsltDocumentComp(xsltStylesheetPtr style, xmlNodePtr inst) {
        if (URL == NULL) {
            xsltGenericError(xsltGenericErrorContext,
                "xsltDocumentComp: URL computation failed %s\n", filename);
+           style->warnings++;
            comp->filename = xmlStrdup(filename);
        } else {
            comp->filename = URL;
@@ -309,6 +313,7 @@ xsltSortComp(xsltStylesheetPtr style, xmlNodePtr inst) {
            xsltGenericError(xsltGenericErrorContext,
                 "xsltSortComp: no support for data-type = %s\n", comp->stype);
            comp->number = -1;
+           style->warnings++;
        }
     }
     comp->order = xsltEvalStaticAttrValueTemplate(style, inst,
@@ -323,6 +328,7 @@ xsltSortComp(xsltStylesheetPtr style, xmlNodePtr inst) {
            xsltGenericError(xsltGenericErrorContext,
                 "xsltSortComp: invalid value %s for order\n", comp->order);
            comp->descending = -1;
+           style->warnings++;
        }
     }
     /* TODO: xsl:sort lang attribute */
@@ -399,6 +405,7 @@ xsltTextComp(xsltStylesheetPtr style, xmlNodePtr inst) {
                                (const xmlChar *)"no")){
            xsltGenericError(xsltGenericErrorContext,
 "xslt:text: disable-output-escaping allow only yes or no\n");
+           style->warnings++;
        }
        xmlFree(prop);
     }
@@ -537,6 +544,7 @@ xsltCopyOfComp(xsltStylesheetPtr style, xmlNodePtr inst) {
     if (comp->select == NULL) {
        xsltGenericError(xsltGenericErrorContext,
             "xslt:copy-of : select is missing\n");
+       style->errors++;
     }
 }
 
@@ -570,6 +578,7 @@ xsltValueOfComp(xsltStylesheetPtr style, xmlNodePtr inst) {
                                (const xmlChar *)"no")){
            xsltGenericError(xsltGenericErrorContext,
 "value-of: disable-output-escaping allow only yes or no\n");
+           style->warnings++;
        }
        xmlFree(prop);
     }
@@ -578,6 +587,7 @@ xsltValueOfComp(xsltStylesheetPtr style, xmlNodePtr inst) {
     if (comp->select == NULL) {
        xsltGenericError(xsltGenericErrorContext,
             "xslt:value-of : select is missing\n");
+       style->errors++;
     }
 }
 
@@ -611,6 +621,7 @@ xsltWithParamComp(xsltStylesheetPtr style, xmlNodePtr inst) {
     if (prop == NULL) {
        xsltGenericError(xsltGenericErrorContext,
             "xslt:with-param : name is missing\n");
+       style->errors++;
     } else {
 
        ncname = xmlSplitQName2(prop, &prefix);
@@ -624,6 +635,7 @@ xsltWithParamComp(xsltStylesheetPtr style, xmlNodePtr inst) {
            if (ns == NULL) {
                xsltGenericError(xsltGenericErrorContext,
                "xslt:with-param : no namespace bound to prefix %s\n", prefix);
+               style->warnings++;
            }
        }
        comp->name = xmlStrdup(ncname);
@@ -641,6 +653,7 @@ xsltWithParamComp(xsltStylesheetPtr style, xmlNodePtr inst) {
        if (inst->children != NULL)
            xsltGenericError(xsltGenericErrorContext,
            "xsl:param : content should be empty since select is present \n");
+       style->warnings++;
     }
     comp->comp = NULL;
 
@@ -700,6 +713,7 @@ xsltNumberComp(xsltStylesheetPtr style, xmlNodePtr cur) {
        } else {
            xsltGenericError(xsltGenericErrorContext,
                         "xsl:number : invalid value %s for level\n", prop);
+           style->warnings++;
            xmlFree(prop);
        }
     }
@@ -713,17 +727,25 @@ xsltNumberComp(xsltStylesheetPtr style, xmlNodePtr cur) {
     prop = xmlGetNsProp(cur, (const xmlChar *)"letter-value", XSLT_NAMESPACE);
     if (prop != NULL) {
        if (xmlStrEqual(prop, BAD_CAST("alphabetic"))) {
+           xsltGenericError(xsltGenericErrorContext,
+                "xsl:number : letter-value 'alphabetic' not implemented\n");
+           style->warnings++;
            TODO; /* xsl:number letter-value attribute alphabetic */
        } else if (xmlStrEqual(prop, BAD_CAST("traditional"))) {
+           xsltGenericError(xsltGenericErrorContext,
+                "xsl:number : letter-value 'traditional' not implemented\n");
+           style->warnings++;
            TODO; /* xsl:number letter-value attribute traditional */
        } else {
            xsltGenericError(xsltGenericErrorContext,
                     "xsl:number : invalid value %s for letter-value\n", prop);
+           style->warnings++;
        }
        xmlFree(prop);
     }
     
-    prop = xmlGetNsProp(cur, (const xmlChar *)"grouping-separator", XSLT_NAMESPACE);
+    prop = xmlGetNsProp(cur, (const xmlChar *)"grouping-separator",
+                       XSLT_NAMESPACE);
     if (prop != NULL) {
        comp->numdata.groupingCharacter = prop[0];
        xmlFree(prop);
@@ -796,6 +818,7 @@ xsltCallTemplateComp(xsltStylesheetPtr style, xmlNodePtr inst) {
     if (prop == NULL) {
        xsltGenericError(xsltGenericErrorContext,
             "xslt:call-template : name is missing\n");
+       style->errors++;
     } else {
 
        ncname = xmlSplitQName2(prop, &prefix);
@@ -809,6 +832,7 @@ xsltCallTemplateComp(xsltStylesheetPtr style, xmlNodePtr inst) {
            if (ns == NULL) {
                xsltGenericError(xsltGenericErrorContext,
        "xslt:call-template : no namespace bound to prefix %s\n", prefix);
+               style->warnings++;
            }
        }
        comp->name = xmlStrdup(ncname);
@@ -865,6 +889,7 @@ xsltApplyTemplatesComp(xsltStylesheetPtr style, xmlNodePtr inst) {
                if (ns == NULL) {
                    xsltGenericError(xsltGenericErrorContext,
                        "no namespace bound to prefix %s\n", prefix);
+                   style->warnings++;
                    xmlFree(prefix);
                    xmlFree(comp->mode);
                    comp->mode = prop;
@@ -932,6 +957,7 @@ xsltIfComp(xsltStylesheetPtr style, xmlNodePtr inst) {
     if (comp->test == NULL) {
        xsltGenericError(xsltGenericErrorContext,
             "xslt:if : test is not defined\n");
+       style->errors++;
        return;
     }
 }
@@ -959,6 +985,7 @@ xsltWhenComp(xsltStylesheetPtr style, xmlNodePtr inst) {
     if (comp->test == NULL) {
        xsltGenericError(xsltGenericErrorContext,
             "xsl:when : test is not defined\n");
+       style->errors++;
        return;
     }
 }
@@ -1018,6 +1045,7 @@ xsltVariableComp(xsltStylesheetPtr style, xmlNodePtr inst) {
     if (prop == NULL) {
        xsltGenericError(xsltGenericErrorContext,
             "xslt:variable : name is missing\n");
+       style->errors++;
     } else {
        ncname = xmlSplitQName2(prop, &prefix);
        if (ncname == NULL) {
@@ -1030,6 +1058,7 @@ xsltVariableComp(xsltStylesheetPtr style, xmlNodePtr inst) {
            if (ns == NULL) {
                xsltGenericError(xsltGenericErrorContext,
                "xsl:variable no namespace bound to prefix %s\n", prefix);
+               style->warnings++;
            }
        }
        comp->name = xmlStrdup(ncname);
@@ -1047,6 +1076,7 @@ xsltVariableComp(xsltStylesheetPtr style, xmlNodePtr inst) {
        if (inst->children != NULL)
            xsltGenericError(xsltGenericErrorContext,
        "xsl:variable : content should be empty since select is present \n");
+       style->warnings++;
     }
 
     if (prop != NULL)
@@ -1087,6 +1117,7 @@ xsltParamComp(xsltStylesheetPtr style, xmlNodePtr inst) {
     if (prop == NULL) {
        xsltGenericError(xsltGenericErrorContext,
             "xslt:param : name is missing\n");
+       style->errors++;
     } else {
        ncname = xmlSplitQName2(prop, &prefix);
        if (ncname == NULL) {
@@ -1099,6 +1130,7 @@ xsltParamComp(xsltStylesheetPtr style, xmlNodePtr inst) {
            if (ns == NULL) {
                xsltGenericError(xsltGenericErrorContext,
                    "xsl:param no namespace bound to prefix %s\n", prefix);
+               style->warnings++;
            }
        }
        comp->name = xmlStrdup(ncname);
@@ -1116,6 +1148,7 @@ xsltParamComp(xsltStylesheetPtr style, xmlNodePtr inst) {
        if (inst->children != NULL)
            xsltGenericError(xsltGenericErrorContext,
        "xsl:variable : content should be empty since select is present \n");
+       style->warnings++;
     }
 
     if (prop != NULL)
@@ -1251,6 +1284,7 @@ xsltStylePreCompute(xsltStylesheetPtr style, xmlNodePtr inst) {
        } else {
            xsltGenericError(xsltGenericDebugContext,
                 "xsltStylePreCompute: unknown xslt:%s\n", inst->name);
+           style->warnings++;
        }
        /*
         * Add the namespace lookup here, this code can be shared by
index b8237ec..b181cdc 100644 (file)
@@ -255,6 +255,8 @@ xsltNewStylesheet(void) {
     cur->standalone = -1;
     cur->decimalFormat = xsltNewDecimalFormat(NULL);
     cur->indent = -1;
+    cur->errors = 0;
+    cur->warnings = 0;
     return(cur);
 }
 
@@ -374,6 +376,7 @@ xsltParseStylesheetOutput(xsltStylesheetPtr style, xmlNodePtr cur) {
                if (ns == NULL) {
                    xsltGenericError(xsltGenericErrorContext,
                        "no namespace bound to prefix %s\n", prefix);
+                   style->warnings++;
                    xmlFree(prefix);
                    xmlFree(ncname);
                    style->method = prop;
@@ -395,6 +398,7 @@ xsltParseStylesheetOutput(xsltStylesheetPtr style, xmlNodePtr cur) {
            } else {
                xsltGenericError(xsltGenericErrorContext,
                    "invalid value for method: %s\n", prop);
+               style->warnings++;
            }
        }
     }
@@ -421,6 +425,7 @@ xsltParseStylesheetOutput(xsltStylesheetPtr style, xmlNodePtr cur) {
        } else {
            xsltGenericError(xsltGenericErrorContext,
                "invalid value for standalone: %s\n", prop);
+           style->warnings++;
        }
        xmlFree(prop);
     }
@@ -435,6 +440,7 @@ xsltParseStylesheetOutput(xsltStylesheetPtr style, xmlNodePtr cur) {
        } else {
            xsltGenericError(xsltGenericErrorContext,
                "invalid value for indent: %s\n", prop);
+           style->warnings++;
        }
        xmlFree(prop);
     }
@@ -449,6 +455,7 @@ xsltParseStylesheetOutput(xsltStylesheetPtr style, xmlNodePtr cur) {
        } else {
            xsltGenericError(xsltGenericErrorContext,
                "invalid value for omit-xml-declaration: %s\n", prop);
+           style->warnings++;
        }
        xmlFree(prop);
     }
@@ -493,45 +500,49 @@ xsltParseStylesheetOutput(xsltStylesheetPtr style, xmlNodePtr cur) {
  * and record the formatting characteristics
  */
 static void
-xsltParseStylesheetDecimalFormat(xsltStylesheetPtr sheet, xmlNodePtr cur)
+xsltParseStylesheetDecimalFormat(xsltStylesheetPtr style, xmlNodePtr cur)
 {
     xmlChar *prop;
     xsltDecimalFormatPtr format;
     xsltDecimalFormatPtr iter;
     
-    if ((cur == NULL) || (sheet == NULL))
+    if ((cur == NULL) || (style == NULL))
        return;
 
-    format = sheet->decimalFormat;
+    format = style->decimalFormat;
     
     prop = xmlGetNsProp(cur, BAD_CAST("name"), XSLT_NAMESPACE);
     if (prop != NULL) {
-       format = xsltDecimalFormatGetByName(sheet, prop);
+       format = xsltDecimalFormatGetByName(style, prop);
        if (format != NULL) {
            xsltGenericError(xsltGenericErrorContext,
-                            "xsltParseStylesheetDecimalFormat: %s already exists\n", prop);
+        "xsltParseStylestyleDecimalFormat: %s already exists\n", prop);
+           style->warnings++;
            return;
        }
        format = xsltNewDecimalFormat(prop);
        if (format == NULL) {
            xsltGenericError(xsltGenericErrorContext,
-                            "xsltParseStylesheetDecimalFormat: failed creating new decimal-format\n");
+     "xsltParseStylestyleDecimalFormat: failed creating new decimal-format\n");
+           style->errors++;
            return;
        }
        /* Append new decimal-format structure */
-       for (iter = sheet->decimalFormat; iter->next; iter = iter->next)
+       for (iter = style->decimalFormat; iter->next; iter = iter->next)
            ;
        if (iter)
            iter->next = format;
     }
 
-    prop = xmlGetNsProp(cur, (const xmlChar *)"decimal-separator", XSLT_NAMESPACE);
+    prop = xmlGetNsProp(cur, (const xmlChar *)"decimal-separator",
+                       XSLT_NAMESPACE);
     if (prop != NULL) {
        if (format->decimalPoint != NULL) xmlFree(format->decimalPoint);
        format->decimalPoint  = prop;
     }
     
-    prop = xmlGetNsProp(cur, (const xmlChar *)"grouping-separator", XSLT_NAMESPACE);
+    prop = xmlGetNsProp(cur, (const xmlChar *)"grouping-separator",
+                       XSLT_NAMESPACE);
     if (prop != NULL) {
        if (format->grouping != NULL) xmlFree(format->grouping);
        format->grouping  = prop;
@@ -579,7 +590,8 @@ xsltParseStylesheetDecimalFormat(xsltStylesheetPtr sheet, xmlNodePtr cur)
        format->digit  = prop;
     }
     
-    prop = xmlGetNsProp(cur, (const xmlChar *)"pattern-separator", XSLT_NAMESPACE);
+    prop = xmlGetNsProp(cur, (const xmlChar *)"pattern-separator",
+                       XSLT_NAMESPACE);
     if (prop != NULL) {
        if (format->patternSeparator != NULL) xmlFree(format->patternSeparator);
        format->patternSeparator  = prop;
@@ -607,6 +619,7 @@ xsltParseStylesheetPreserveSpace(xsltStylesheetPtr style, xmlNodePtr cur) {
     if (elements == NULL) {
        xsltGenericError(xsltGenericErrorContext,
            "xsltParseStylesheetPreserveSpace: missing elements attribute\n");
+       style->warnings++;
        return;
     }
 
@@ -683,6 +696,7 @@ xsltParseStylesheetExtPrefix(xsltStylesheetPtr style, xmlNodePtr cur) {
                xsltGenericError(xsltGenericErrorContext,
            "xsl:extension-element-prefix : undefined namespace %s\n",
                                 prefix);
+               style->warnings++;
            } else {
 #ifdef WITH_XSLT_DEBUG_PARSING
                xsltGenericDebug(xsltGenericDebugContext,
@@ -718,6 +732,7 @@ xsltParseStylesheetStripSpace(xsltStylesheetPtr style, xmlNodePtr cur) {
     if (elements == NULL) {
        xsltGenericError(xsltGenericErrorContext,
            "xsltParseStylesheetStripSpace: missing elements attribute\n");
+       style->warnings++;
        return;
     }
 
@@ -872,6 +887,7 @@ xsltGatherNamespaces(xsltStylesheetPtr style) {
                        if (style->nsHash == NULL) {
                            xsltGenericError(xsltGenericErrorContext,
                 "xsltGatherNamespaces: failed to create hash table\n");
+                           style->errors++;
                            return;
                        }
                    }
@@ -879,6 +895,7 @@ xsltGatherNamespaces(xsltStylesheetPtr style) {
                    if ((URI != NULL) && (!xmlStrEqual(URI, ns->href))) {
                        xsltGenericError(xsltGenericErrorContext,
             "Namespaces prefix %s used for multiple namespaces\n");
+                       style->warnings++;
                    } else if (URI == NULL) {
                        xmlHashUpdateEntry(style->nsHash, ns->prefix,
                            (void *) ns->href, (xmlHashDeallocator)xmlFree);
@@ -964,6 +981,7 @@ xsltParseTemplateContent(xsltStylesheetPtr style, xsltTemplatePtr ret,
                        (cur->children->next != NULL)) {
                        xsltGenericError(xsltGenericErrorContext,
             "xsltParseTemplateContent: xslt:text content problem\n");
+                       style->errors++;
                    } else {
                        xmlChar *prop;
                        xmlNodePtr text = cur->children;
@@ -982,6 +1000,7 @@ xsltParseTemplateContent(xsltStylesheetPtr style, xsltTemplatePtr ret,
                                                    (const xmlChar *)"no")){
                                xsltGenericError(xsltGenericErrorContext,
                 "xslt:text: disable-output-escaping allow only yes or no\n");
+                               style->warnings++;
 
                            }
                            xmlFree(prop);
@@ -1061,6 +1080,7 @@ skip_children:
             cur = cur->next;
            xsltGenericError(xsltGenericErrorContext,
                "xsltParseStylesheetTop: ignoring misplaced param element\n");
+           style->warnings++;
            xmlUnlinkNode(param);
            xmlFreeNode(param);
            continue;
@@ -1107,6 +1127,7 @@ xsltParseStylesheetKey(xsltStylesheetPtr style, xmlNodePtr key) {
                if (ns == NULL) {
                    xsltGenericError(xsltGenericErrorContext,
                        "no namespace bound to prefix %s\n", prefix);
+                   style->warnings++;
                    xmlFree(prefix);
                    xmlFree(name);
                    name = prop;
@@ -1131,6 +1152,7 @@ xsltParseStylesheetKey(xsltStylesheetPtr style, xmlNodePtr key) {
     } else {
        xsltGenericError(xsltGenericErrorContext,
            "xsl:key : error missing name\n");
+       style->errors++;
        goto error;
     }
 
@@ -1138,6 +1160,7 @@ xsltParseStylesheetKey(xsltStylesheetPtr style, xmlNodePtr key) {
     if (match == NULL) {
        xsltGenericError(xsltGenericErrorContext,
            "xsl:key : error missing match\n");
+       style->errors++;
        goto error;
     }
 
@@ -1145,6 +1168,7 @@ xsltParseStylesheetKey(xsltStylesheetPtr style, xmlNodePtr key) {
     if (use == NULL) {
        xsltGenericError(xsltGenericErrorContext,
            "xsl:key : error missing use\n");
+       style->errors++;
        goto error;
     }
 
@@ -1209,6 +1233,7 @@ xsltParseStylesheetTemplate(xsltStylesheetPtr style, xmlNodePtr template) {
                if (ns == NULL) {
                    xsltGenericError(xsltGenericErrorContext,
                        "no namespace bound to prefix %s\n", prefix);
+                   style->warnings++;
                    xmlFree(prefix);
                    xmlFree(mode);
                    mode = prop;
@@ -1266,6 +1291,7 @@ xsltParseStylesheetTemplate(xsltStylesheetPtr style, xmlNodePtr template) {
                if (ns == NULL) {
                    xsltGenericError(xsltGenericErrorContext,
                        "no namespace bound to prefix %s\n", prefix);
+                   style->warnings++;
                    xmlFree(prefix);
                    xmlFree(ncname);
                    ret->name = prop;
@@ -1319,11 +1345,13 @@ xsltParseStylesheetTop(xsltStylesheetPtr style, xmlNodePtr top) {
     if (prop == NULL) {
        xsltGenericError(xsltGenericErrorContext,
            "xsl:version is missing: document may not be a stylesheet\n");
+       style->warnings++;
     } else {
        if (!xmlStrEqual(prop, (const xmlChar *)"1.0")) {
            xsltGenericError(xsltGenericErrorContext,
                "xsl:version: only 1.0 features are supported\n");
             /* TODO set up compatibility when not XSLT 1.0 */
+           style->warnings++;
        }
        xmlFree(prop);
     }
@@ -1365,6 +1393,7 @@ xsltParseStylesheetTop(xsltStylesheetPtr style, xmlNodePtr top) {
        if (IS_XSLT_NAME(cur, "import")) {
            xsltGenericError(xsltGenericErrorContext,
                "xsltParseStylesheetTop: ignoring misplaced import element\n");
+           style->errors++;
         } else if (IS_XSLT_NAME(cur, "include")) {
            xsltParseStylesheetInclude(style, cur);
         } else if (IS_XSLT_NAME(cur, "strip-space")) {
@@ -1394,6 +1423,7 @@ xsltParseStylesheetTop(xsltStylesheetPtr style, xmlNodePtr top) {
            xsltGenericError(xsltGenericErrorContext,
                "xsltParseStylesheetTop: ignoring unknown %s element\n",
                             cur->name);
+           style->warnings++;
        }
        cur = cur->next;
     }
@@ -1471,6 +1501,7 @@ xsltParseStylesheetProcess(xsltStylesheetPtr ret, xmlDocPtr doc) {
            xsltGenericError(xsltGenericErrorContext,
                "xsl:version: only 1.0 features are supported\n");
             /* TODO set up compatibility when not XSLT 1.0 */
+           ret->warnings++;
        }
        xmlFree(prop);
 
index b2839f6..9031bb1 100644 (file)
@@ -270,6 +270,8 @@ struct _xsltStylesheet {
      * Precomputed blocks
      */
     xsltStylePreCompPtr preComps;      /* list of precomputed blocks */
+    int warnings;              /* number of warnings found at compilation */
+    int errors;                        /* number of errors found at compilation */
 };
 
 /*
index ec6cb1b..0adb551 100644 (file)
@@ -157,7 +157,7 @@ main(int argc, char **argv) {
                
        }
     }
-    if (cur != NULL) {
+    if ((cur != NULL) && (cur->errors == 0)) {
        for (;i < argc ; i++) {
            if (timing)
                gettimeofday(&begin, NULL);
index 6fa3ea1..aba7c9d 100644 (file)
@@ -22,6 +22,8 @@ EXTRA_DIST =  \
        bug-15-.xml \
        bug-16-.xml \
        bug-17-.xml \
+       bug-18-.xml \
+       bug-19-.xml \
        character.xml \
        items.xml
 
diff --git a/tests/docs/bug-18-.xml b/tests/docs/bug-18-.xml
new file mode 100644 (file)
index 0000000..f706ec4
--- /dev/null
@@ -0,0 +1,3 @@
+<ns:root xmlns:ns="whatever">
+  <something/>
+</ns:root>
diff --git a/tests/docs/bug-19-.xml b/tests/docs/bug-19-.xml
new file mode 100644 (file)
index 0000000..f706ec4
--- /dev/null
@@ -0,0 +1,3 @@
+<ns:root xmlns:ns="whatever">
+  <something/>
+</ns:root>
index 47bc11a..93d951c 100644 (file)
@@ -21,9 +21,12 @@ EXTRA_DIST = \
     bug-15-.out bug-15-.xsl \
     bug-16-.out bug-16-.xsl \
     bug-17-.out bug-17-.xsl \
+    bug-18-.out bug-18-.xsl \
+    bug-19-.out bug-19-.xsl \
     character.out character.xsl \
     character2.out character2.xsl \
-    itemschoose.out itemschoose.xsl
+    itemschoose.out itemschoose.xsl \
+    inner.xsl
 
 
 all: test
diff --git a/tests/general/bug-18-.out b/tests/general/bug-18-.out
new file mode 100644 (file)
index 0000000..a230542
--- /dev/null
@@ -0,0 +1,2 @@
+
+  RIGHT
diff --git a/tests/general/bug-18-.xsl b/tests/general/bug-18-.xsl
new file mode 100644 (file)
index 0000000..3b1c22d
--- /dev/null
@@ -0,0 +1,17 @@
+<xsl:stylesheet
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:ns2="whatever"
+ xmlns:ns="another"
+ version="1.0">
+
+<xsl:output method="text"/>
+
+<xsl:template match="ns2:root">
+  RIGHT
+</xsl:template>
+
+<xsl:template match="ns:root">
+  WRONG
+</xsl:template>
+
+</xsl:stylesheet>
diff --git a/tests/general/bug-19-.out b/tests/general/bug-19-.out
new file mode 100644 (file)
index 0000000..a230542
--- /dev/null
@@ -0,0 +1,2 @@
+
+  RIGHT
diff --git a/tests/general/bug-19-.xsl b/tests/general/bug-19-.xsl
new file mode 100644 (file)
index 0000000..97a273f
--- /dev/null
@@ -0,0 +1,17 @@
+<xsl:stylesheet
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:ns2="whatever"
+ xmlns:ns="another"
+ version="1.0">
+
+<xsl:output method="text"/>
+
+<xsl:template match="ns:root">
+  WRONG
+</xsl:template>
+
+<xsl:template match="ns2:root">
+  RIGHT
+</xsl:template>
+
+</xsl:stylesheet>
diff --git a/tests/general/inner.xsl b/tests/general/inner.xsl
new file mode 100644 (file)
index 0000000..aeddc4c
--- /dev/null
@@ -0,0 +1,12 @@
+<?xml version= "1.0"?>
+
+<xsl:stylesheet version="1.0"
+  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+  xmlns:my="http://my/namespace"
+  exclude-result-prefixes="my">
+
+  <xsl:template match="my:document">
+    Big <xsl:apply-templates select="my:item"/>
+  </xsl:template>
+
+</xsl:stylesheet>