+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
if (cur == NULL) {
xsltGenericError(xsltGenericErrorContext,
"xsltNewStylePreComp : malloc failed\n");
+ style->errors++;
return(NULL);
}
memset(cur, 0, sizeof(xsltStylePreComp));
if (cur->func == NULL) {
xsltGenericError(xsltGenericErrorContext,
"xsltNewStylePreComp : no function for type %d\n", type);
+ style->errors++;
}
}
cur->next = style->preComps;
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");
if (!comp->has_filename) {
xsltGenericError(xsltGenericErrorContext,
"xsltDocumentComp: could not find the href\n");
+ style->errors++;
goto error;
}
if (URL == NULL) {
xsltGenericError(xsltGenericErrorContext,
"xsltDocumentComp: URL computation failed %s\n", filename);
+ style->warnings++;
comp->filename = xmlStrdup(filename);
} else {
comp->filename = URL;
xsltGenericError(xsltGenericErrorContext,
"xsltSortComp: no support for data-type = %s\n", comp->stype);
comp->number = -1;
+ style->warnings++;
}
}
comp->order = xsltEvalStaticAttrValueTemplate(style, inst,
xsltGenericError(xsltGenericErrorContext,
"xsltSortComp: invalid value %s for order\n", comp->order);
comp->descending = -1;
+ style->warnings++;
}
}
/* TODO: xsl:sort lang attribute */
(const xmlChar *)"no")){
xsltGenericError(xsltGenericErrorContext,
"xslt:text: disable-output-escaping allow only yes or no\n");
+ style->warnings++;
}
xmlFree(prop);
}
if (comp->select == NULL) {
xsltGenericError(xsltGenericErrorContext,
"xslt:copy-of : select is missing\n");
+ style->errors++;
}
}
(const xmlChar *)"no")){
xsltGenericError(xsltGenericErrorContext,
"value-of: disable-output-escaping allow only yes or no\n");
+ style->warnings++;
}
xmlFree(prop);
}
if (comp->select == NULL) {
xsltGenericError(xsltGenericErrorContext,
"xslt:value-of : select is missing\n");
+ style->errors++;
}
}
if (prop == NULL) {
xsltGenericError(xsltGenericErrorContext,
"xslt:with-param : name is missing\n");
+ style->errors++;
} else {
ncname = xmlSplitQName2(prop, &prefix);
if (ns == NULL) {
xsltGenericError(xsltGenericErrorContext,
"xslt:with-param : no namespace bound to prefix %s\n", prefix);
+ style->warnings++;
}
}
comp->name = xmlStrdup(ncname);
if (inst->children != NULL)
xsltGenericError(xsltGenericErrorContext,
"xsl:param : content should be empty since select is present \n");
+ style->warnings++;
}
comp->comp = NULL;
} else {
xsltGenericError(xsltGenericErrorContext,
"xsl:number : invalid value %s for level\n", prop);
+ style->warnings++;
xmlFree(prop);
}
}
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);
if (prop == NULL) {
xsltGenericError(xsltGenericErrorContext,
"xslt:call-template : name is missing\n");
+ style->errors++;
} else {
ncname = xmlSplitQName2(prop, &prefix);
if (ns == NULL) {
xsltGenericError(xsltGenericErrorContext,
"xslt:call-template : no namespace bound to prefix %s\n", prefix);
+ style->warnings++;
}
}
comp->name = xmlStrdup(ncname);
if (ns == NULL) {
xsltGenericError(xsltGenericErrorContext,
"no namespace bound to prefix %s\n", prefix);
+ style->warnings++;
xmlFree(prefix);
xmlFree(comp->mode);
comp->mode = prop;
if (comp->test == NULL) {
xsltGenericError(xsltGenericErrorContext,
"xslt:if : test is not defined\n");
+ style->errors++;
return;
}
}
if (comp->test == NULL) {
xsltGenericError(xsltGenericErrorContext,
"xsl:when : test is not defined\n");
+ style->errors++;
return;
}
}
if (prop == NULL) {
xsltGenericError(xsltGenericErrorContext,
"xslt:variable : name is missing\n");
+ style->errors++;
} else {
ncname = xmlSplitQName2(prop, &prefix);
if (ncname == NULL) {
if (ns == NULL) {
xsltGenericError(xsltGenericErrorContext,
"xsl:variable no namespace bound to prefix %s\n", prefix);
+ style->warnings++;
}
}
comp->name = xmlStrdup(ncname);
if (inst->children != NULL)
xsltGenericError(xsltGenericErrorContext,
"xsl:variable : content should be empty since select is present \n");
+ style->warnings++;
}
if (prop != NULL)
if (prop == NULL) {
xsltGenericError(xsltGenericErrorContext,
"xslt:param : name is missing\n");
+ style->errors++;
} else {
ncname = xmlSplitQName2(prop, &prefix);
if (ncname == NULL) {
if (ns == NULL) {
xsltGenericError(xsltGenericErrorContext,
"xsl:param no namespace bound to prefix %s\n", prefix);
+ style->warnings++;
}
}
comp->name = xmlStrdup(ncname);
if (inst->children != NULL)
xsltGenericError(xsltGenericErrorContext,
"xsl:variable : content should be empty since select is present \n");
+ style->warnings++;
}
if (prop != NULL)
} else {
xsltGenericError(xsltGenericDebugContext,
"xsltStylePreCompute: unknown xslt:%s\n", inst->name);
+ style->warnings++;
}
/*
* Add the namespace lookup here, this code can be shared by
cur->standalone = -1;
cur->decimalFormat = xsltNewDecimalFormat(NULL);
cur->indent = -1;
+ cur->errors = 0;
+ cur->warnings = 0;
return(cur);
}
if (ns == NULL) {
xsltGenericError(xsltGenericErrorContext,
"no namespace bound to prefix %s\n", prefix);
+ style->warnings++;
xmlFree(prefix);
xmlFree(ncname);
style->method = prop;
} else {
xsltGenericError(xsltGenericErrorContext,
"invalid value for method: %s\n", prop);
+ style->warnings++;
}
}
}
} else {
xsltGenericError(xsltGenericErrorContext,
"invalid value for standalone: %s\n", prop);
+ style->warnings++;
}
xmlFree(prop);
}
} else {
xsltGenericError(xsltGenericErrorContext,
"invalid value for indent: %s\n", prop);
+ style->warnings++;
}
xmlFree(prop);
}
} else {
xsltGenericError(xsltGenericErrorContext,
"invalid value for omit-xml-declaration: %s\n", prop);
+ style->warnings++;
}
xmlFree(prop);
}
* 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;
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;
if (elements == NULL) {
xsltGenericError(xsltGenericErrorContext,
"xsltParseStylesheetPreserveSpace: missing elements attribute\n");
+ style->warnings++;
return;
}
xsltGenericError(xsltGenericErrorContext,
"xsl:extension-element-prefix : undefined namespace %s\n",
prefix);
+ style->warnings++;
} else {
#ifdef WITH_XSLT_DEBUG_PARSING
xsltGenericDebug(xsltGenericDebugContext,
if (elements == NULL) {
xsltGenericError(xsltGenericErrorContext,
"xsltParseStylesheetStripSpace: missing elements attribute\n");
+ style->warnings++;
return;
}
if (style->nsHash == NULL) {
xsltGenericError(xsltGenericErrorContext,
"xsltGatherNamespaces: failed to create hash table\n");
+ style->errors++;
return;
}
}
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);
(cur->children->next != NULL)) {
xsltGenericError(xsltGenericErrorContext,
"xsltParseTemplateContent: xslt:text content problem\n");
+ style->errors++;
} else {
xmlChar *prop;
xmlNodePtr text = cur->children;
(const xmlChar *)"no")){
xsltGenericError(xsltGenericErrorContext,
"xslt:text: disable-output-escaping allow only yes or no\n");
+ style->warnings++;
}
xmlFree(prop);
cur = cur->next;
xsltGenericError(xsltGenericErrorContext,
"xsltParseStylesheetTop: ignoring misplaced param element\n");
+ style->warnings++;
xmlUnlinkNode(param);
xmlFreeNode(param);
continue;
if (ns == NULL) {
xsltGenericError(xsltGenericErrorContext,
"no namespace bound to prefix %s\n", prefix);
+ style->warnings++;
xmlFree(prefix);
xmlFree(name);
name = prop;
} else {
xsltGenericError(xsltGenericErrorContext,
"xsl:key : error missing name\n");
+ style->errors++;
goto error;
}
if (match == NULL) {
xsltGenericError(xsltGenericErrorContext,
"xsl:key : error missing match\n");
+ style->errors++;
goto error;
}
if (use == NULL) {
xsltGenericError(xsltGenericErrorContext,
"xsl:key : error missing use\n");
+ style->errors++;
goto error;
}
if (ns == NULL) {
xsltGenericError(xsltGenericErrorContext,
"no namespace bound to prefix %s\n", prefix);
+ style->warnings++;
xmlFree(prefix);
xmlFree(mode);
mode = prop;
if (ns == NULL) {
xsltGenericError(xsltGenericErrorContext,
"no namespace bound to prefix %s\n", prefix);
+ style->warnings++;
xmlFree(prefix);
xmlFree(ncname);
ret->name = prop;
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);
}
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")) {
xsltGenericError(xsltGenericErrorContext,
"xsltParseStylesheetTop: ignoring unknown %s element\n",
cur->name);
+ style->warnings++;
}
cur = cur->next;
}
xsltGenericError(xsltGenericErrorContext,
"xsl:version: only 1.0 features are supported\n");
/* TODO set up compatibility when not XSLT 1.0 */
+ ret->warnings++;
}
xmlFree(prop);
* Precomputed blocks
*/
xsltStylePreCompPtr preComps; /* list of precomputed blocks */
+ int warnings; /* number of warnings found at compilation */
+ int errors; /* number of errors found at compilation */
};
/*
}
}
- if (cur != NULL) {
+ if ((cur != NULL) && (cur->errors == 0)) {
for (;i < argc ; i++) {
if (timing)
gettimeofday(&begin, NULL);
bug-15-.xml \
bug-16-.xml \
bug-17-.xml \
+ bug-18-.xml \
+ bug-19-.xml \
character.xml \
items.xml
--- /dev/null
+<ns:root xmlns:ns="whatever">
+ <something/>
+</ns:root>
--- /dev/null
+<ns:root xmlns:ns="whatever">
+ <something/>
+</ns:root>
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
--- /dev/null
+<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>
--- /dev/null
+<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>
--- /dev/null
+<?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>