Fwd: Spurious error on recursive invocation of fn:transform

Ihe Onwuka <[email protected]> Tue, 24 Nov 2020 06:10:32 -0500
Newsgroups gmane.text.xml.saxon.help
Message-ID <CALfs7+xY4xBmvh881FmfEW8BxsD-v8AyY_GsZQwE64DrzuwNxw@mail.gmail.com>
On Mon, Nov 23, 2020 at 3:16 PM Michael Kay <mike-JkSD5nQpfvpWk0Htik3J/[email protected]> wrote:

> 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.
>
> The usage of doc('') is not the causation here

stylesheet-node :
doc('fullpathToTheStylesheetAsGeneratedWithdocument-uri/myStylesheet.xsl')

the exact same result.


> 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.
>
>
The original plan was for an eXist-db XQuery function that would
recursively call the compiled stylesheet generated by their
transform:transform function.
However that gave me stylesheet compilation errors ( before I implemented
the recursion in the stylesheet) that I am not smart enough to debug given
that the stylesheet ran fine from my command line.

Calling fn:transform from XSLT was a workaround so I could get my stuff
done.


> 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