Re: [xml] xsltproc does not set error code when parsing faulty xsl
- From: Stefan Kost <kost imn htwk-leipzig de>
- To: veillard redhat com
- Cc: xml gnome org
- Subject: Re: [xml] xsltproc does not set error code when parsing faulty xsl
- Date: Thu, 22 Jan 2004 18:10:18 +0100
Hi Daniel,
I've read the section once and twice. Attached is a patch that checks the
version of the stylesheet and in case there is a version and it is equal to
"1.0" the flaw will be considered as an error otherwise as a warning.
Ciao
Stefan
Daniel Veillard wrote:
On Wed, Jan 21, 2004 at 06:50:43PM +0100, Stefan Kost wrote:
hi Daniel,
is it intensional that xsltpro not returns an error incase of invalid xslt files.
I've inserted an mistyped elements (xsl:ooutput) and run xsltpro as below:
xsltproc typo.xsl && echo $?
Parsing stylesheet typo.xsl took 6 ms
compilation error: file typo.xsl line 19 element ooutput
xsltStylePreCompute: unknown xsl:ooutput
compilation error: file typo.xsl line 19 element ooutput
xsltParseStylesheetTop: ignoring unknown ooutput element
0
xsltStylePreCompute: only increments the warning-counter
xsltParseStylesheetTop: says it is an error, but increments the warning counter
xsltTransformError(NULL, style, cur,
"xsltParseStylesheetTop: ignoring unknown %s element\n",
cur->name);
if (style != NULL) style->warnings++;
}
The rational I would like to treat such warnings as errors is, that I use
xsltpro as part of my 'make test' target to see if all stylesheets I package
compile.
Hum, in that case the element is in the XSLT namespace, it then
need to be linked to version compatibility processing, see
http://www.w3.org/TR/xslt#stylesheet-element
it depends on the version indicated, but it's probably right that this should
be labelled as an error.
Daniel
--
\|/ Stefan Kost
<@ @> private business
+-oOO-(_)-OOo------------------------------------------------------ - - - - -
| __ Address Simildenstr. 5 HTWK Leipzig, Fb IMN, Postfach 301166
| /// 04277 Leipzig 04251 Leipzig
| __ /// Germany Germany
| \\\/// Phone +49341 2253538 +49341 30766101
| \__/ EMail st_kost_at_gmx.net kost_at_imn.htwk-leipzig.de
| WWW www.sonicpulse.de www.imn.htwk-leipzig.de/~kost/about.html
===-=-=--=---=---------------------------------- - - - - -
--- xslt.c.orig Wed Jan 21 18:51:16 2004
+++ xslt.c Thu Jan 22 18:07:50 2004
@@ -1858,10 +1858,19 @@
} else if (IS_XSLT_NAME(cur, "namespace-alias")) {
xsltNamespaceAlias(style, cur);
} else {
- xsltTransformError(NULL, style, cur,
+ if ((style != NULL) && (style->doc->version != NULL) && (!strncmp(style->doc->version,"1.0",3)))
{
+ xsltTransformError(NULL, style, cur,
+ "xsltParseStylesheetTop: unknown %s element\n",
+ cur->name);
+ if (style != NULL) style->errors++;
+ }
+ else {
+ /* do Forwards-Compatible Processing */
+ xsltTransformError(NULL, style, cur,
"xsltParseStylesheetTop: ignoring unknown %s element\n",
cur->name);
- if (style != NULL) style->warnings++;
+ if (style != NULL) style->warnings++;
+ }
}
cur = cur->next;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]