Re: [xslt] Non-existent variable => error?
- From: Daniel Veillard <veillard redhat com>
- To: xslt gnome org
- Subject: Re: [xslt] Non-existent variable => error?
- Date: Tue, 15 Oct 2002 07:30:58 -0400
On Wed, Oct 02, 2002 at 02:36:04PM -0700, Jerome Pesenti wrote:
> Hi,
>
> The following style sheet:
>
> <xsl:stylesheet
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> version="1.0">
> <xsl:template match="/">
> foo<B span="{$foo}"/>foo2
> </xsl:template>
> </xsl:stylesheet>
>
>
> gives
>
> <?xml version="1.0"?>
>
> foo<B span=""/>
>
> (independently of the XML input....)
>
> without returning an error, i.e., it fails silently
> after trying to evaluate the variable $foo which
> hasn't been defined. Is that proper behavior? I would
> have expected an error...
Replying here with my answer to the bug-report #94933:
"without returning an error, i.e., it fails silently"
does not sounds an accurate description of the behaviour.
There is an error printed:
paphio:~/XSLT/xsltproc -> ./xsltproc tst.xsl tst.xsl
runtime error: file tst.xsl line 5 element B
unregistered variable foo
xmlXPathCompiledEval: evaluation failed
<?xml version="1.0"?>
foo<B span=""/>
paphio:~/XSLT/xsltproc ->
The state of the transformation context is set to XSLT_STATE_ERROR
(gdb) p ctxt->state
$1 = XSLT_STATE_ERROR
There is a number of possible errors. What if exslt:document
cannot write to a resource, should the transformation be completely
voided ? I can do that very easilly:
*** libxslt/transform.c 10 Oct 2002 15:26:25 -0000 1.189
--- libxslt/transform.c 15 Oct 2002 11:28:19 -0000
***************
*** 3688,3693 ****
--- 3688,3702 ----
if (profile != NULL) {
xsltSaveProfiling(ctxt, profile);
}
+
+ /*
+ * Be pedantic.
+ */
+ if ((ctxt != NULL) && (ctxt->state == XSLT_STATE_ERROR)) {
+ xmlFreeDoc(res);
+ res = NULL;
+ }
+
if ((ctxt != NULL) && (userCtxt == NULL))
xsltFreeTransformContext(ctxt);
this is likely to also annoy a number of people
because what was benign error become fatal ones.
Daniel
--
Daniel Veillard | Red Hat Network https://rhn.redhat.com/
veillard@redhat.com | libxml GNOME XML XSLT toolkit http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]