[xquery-talk] Issues with recursive fn:transform
Ihe Onwuka
ihe.onwuka at gmail.com
Mon Nov 16 11:59:37 PST 2020
I have got the recursive function to work by simplifying the call to
eliminate the accumulator.
I think the error message is an issue. I shouldn't have got that.
On Mon, Nov 16, 2020 at 11:07 AM Ihe Onwuka <ihe.onwuka at gmail.com> wrote:
> Below is a recursive fn:transform function.
> Takes 2 arguments - the XML and the accumulator and recursively calls a
> translator.xsl to generate a translation of the XML into the next version.
> That's what is supposed to happen, it infinitely loops because the next
> version of the XML is being generated so the base case is never true -
> can't see a reason why that should happen but for now I will settle for
> hopefully understanding something more straightforward
>
> <xsl:function name="local:x" as="element()+">
> <xsl:param name="currentVersion" as="element()"/>
> <xsl:param name="accum" as="element()+"/>
> <xsl:sequence select="if (namespace-uri($currentVersion/*) =>
> contains($finalTarget))
> then ($currentVersion,$accum)
> else local:x(fn:transform(map {
> 'stylesheet-node' :
> doc(''),
> 'source-node' : $currentVersion
> })?output/*,
> $accum)"/>
> </xsl:function>
>
> I have used the old doc('') trick to pass the current stylesheet (the name
> is translator.xsl) to the recursive call but that is not the value supplied
> as the first argument of local:x but the error message says it is
>
> XPTY0004 The required item type of the first argument of local:x() is
> element(); the
> supplied value doc(.../translator.xsl) does not match. The supplied
> value is a document node
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://x-query.com/pipermail/talk/attachments/20201116/8cfe817f/attachment.html>
More information about the talk
mailing list