Re: Spurious error on recursive invocation of fn:transform

Michael Kay <mike-JkSD5nQpfvpWk0Htik3J/[email protected]> Mon, 23 Nov 2020 20:16:34 +0000
Newsgroups gmane.text.xml.saxon.help
Message-ID <[email protected]>
doc("") only works if the static base URI of the (relevant part of the) stylesheet is known, and my guess here is that repeated building of the stylesheet in successive calls loses knowledge of the static base URI.

It would be nice if we only compiled the stylesheet once when the same stylesheet-node is passed to fn:transform() repeatedly, but perhaps we're not being smart enough to do that.

Having a stylesheet read it's own source code using doc("") is a pretty dreadful hack and really has no place in modern XSLT code. In the general case where compiled stylesheets are deployed around the world, the source code isn't available at execution time anyway.

Michael Kay
Saxonica

> On 23 Nov 2020, at 17:15, Ihe Onwuka <[email protected]> wrote:
> 
>   XTSE0150  The supplied file does not appear to be a stylesheet
> at function local:generateNextVersion in translator.xsl:
>      invoked by function call
> 
> I have
> 
> <xsl:variable name="currentStylesheet" as="document-node()" select="doc('')"/>
> 
> and then the recursive function
> 
>    <xsl:function name="local:generateNextVersion" as="document-node()">
>       <xsl:param name="currentVersion" as="document-node()"/>
>       <xsl:variable name="isFinalVersion" as="xs:boolean" select="namespace-uri($currentVersion/*) => contains($finalTarget)"/>
>       <xsl:sequence select="if ($isFinalVersion)
>                             then $currentVersion
>                             else local:generateNextVersion(fn:transform(map { 
>                                                                      'stylesheet-node' :  $currentStylesheet,
>                                                                      'source-node'     :  $currentVersion
>                                                             })?output)"/> 
>    </xsl:function>
> 
> This functions works through the first 2 recursion cycles. When I have a situation that would cause it to recurse a 3rd time the reported error shows up.
> Whatever is wrong with the program it cannot be what is being reported because the stylesheet node is being directly populated by doc('') and that doesn't magically stop being a recursive call to the current stylesheet after a set number of iterations.
> 
> 
> _______________________________________________
> saxon-help mailing list archived at http://saxon.markmail.org/
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/saxon-help

_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[email protected]
https://lists.sourceforge.net/lists/listinfo/saxon-help