Re: [xslt] Why is an invalid stylesheet parameter value not an error?


For me it doesn't look like a bug.
XSLT for normal does not produce error messages.

Instead of:

# xsltproc --param value "ival" test.xslt test.xml


# xsltproc --param value "'ival'" test.xslt test.xml


# xsltproc --stirngparam value "ival" test.xslt test.xml


Stefan Behnel wrote:

any comments on this one? It's based on a bug reported for lxml that I would
like to fix.

This can be reproduced with xsltproc, BTW, using this XML file:


and this XSLT file:

<xsl:stylesheet xmlns:xsl="";
    <xsl:template match="/">
        <a><xsl:value-of select="$value"/></a>

with this command:

    # xsltproc --param value "ival" test.xslt test.xml

The output is:

<?xml version="1.0"?>

It would really be helpful to get some kind of an error here, instead of
silently returning an unexpected result.


Stefan Behnel wrote:
in variables.c, function xsltProcessUserParamInternal(), it says:

        if (result == NULL) {
            xsltTransformError(ctxt, style, NULL,
                "Evaluating user parameter %s failed\n", name);
            ctxt->state = XSLT_STATE_STOPPED;

So an invalid value for a stylesheet parameter will stop processing but will
not signal an error in "state", which is explicitly reset from ERROR to
STOPPED here. Is that correct?

At a quick glance, I didn't find anything in the spec about this, but I would
actually like to see this signaled to the application level (other than a
plain string message).

Is there an easy way to find out that this case has occurred?

xslt mailing list, project page
xslt gnome org

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]