Re: [xslt] Element fake in func:function error: bug or feature?



On Tue, Apr 22, 2008 at 02:19:11PM +0200, Mark Howe wrote:
> Hi,
> 
> If I run
> 
> <xsl:stylesheet version="1.0"
>     xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
>     xmlns:baa="foo"
>     xmlns:func="http://exslt.org/functions";
> 
>     extension-element-prefixes="baa">
> 
>    <xsl:template match="/">
>      <xsl:copy-of select="baa:frob()"/>
>    </xsl:template>
> 
>    <func:function name="baa:frob">
>      <frob/>
>    </func:function>
> 
> </xsl:stylesheet>
> 
> through xsltproc (using the stylesheet as its own input) I get
> 
>    ELEMENT fake
> element fake: error : Node has no parent
>      ELEMENT frob
> {foo}frob: cannot write to result tree while executing a function
> xmlXPathCompiledEval: evaluation failed
> 
> The second bit is fair enough (there's a missing func:result), but the 
> fake element bit is a bit alarming, and since it produces a tree of the 
> attempted output it can result in absolutely huge log entries (I have 
> examples exceeding 500 lines).
> 
> Also, in our application the backtrace appears on the console (so 
> presumably STDOUT or STDERR), even though we send other LibXSLT errors 
> to a log file.

  Hard coded in libexslt. 
------------------------------- functions.c --------------------------
    /*
     * It is an error if the instantiation of the template results in
     * the generation of result nodes.
     */
    if (fake->children != NULL) {
#ifdef LIBXML_DEBUG_ENABLED
        xmlDebugDumpNode (stderr, fake, 1);
#endif
        xsltGenericError(xsltGenericErrorContext,
                         "{%s}%s: cannot write to result tree while "
                         "executing a function\n",
                         ctxt->context->functionURI, ctxt->context->function);
-----------------------------------------------------------------------

> So I guess my questions are
> 
> 1: Are we supposed to get the fake element thing, and, if not, would it 

  yes you are assuming you used the EXSLT extension for functions in
your stylesheet and you managed to break the associated generation of
the template result.

> be possible to turn it off?

  by patching/recompiling

> 2: If we are supposed to get it, is there any way to control which 
> stream it writes to?

  no it's stderr, see the code.

Daniel

-- 
Red Hat Virtualization group http://redhat.com/virtualization/
Daniel Veillard      | virtualization library  http://libvirt.org/
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]