Re: Fwd: Spurious error on recursive invocation of fn:transform
Ihe Onwuka <[email protected]> Tue, 24 Nov 2020 09:57:17 -0500
| Newsgroups | gmane.text.xml.saxon.help |
|---|---|
| Message-ID | <CALfs7+x-jcYf8GuxmxHXZaETKE6DjgQEkZQ6CQiWkq85cE0iig@mail.gmail.com> |
On Tue, Nov 24, 2020 at 7:32 AM Michael Kay <mike-JkSD5nQpfvpWk0Htik3J/[email protected]> wrote: > >> The usage of doc('') is not the causation here > > stylesheet-node : > doc('fullpathToTheStylesheetAsGeneratedWithdocument-uri/myStylesheet.xsl') > > the exact same result. > > >> > It's not so much the use of doc(""), as the reliance on preservation of a > base URI. > > Having said that, if you can put together a repro we'll be happy to look > at it. I think it's fairly clear the problem is happening because the base > URI is being lost through the call on fn:transform(), but whether losing it > is a bug or an application error is something we can only determine if we > study the detail. > > Michael Kay > Saxonica > Here. Here is bug.xsl <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fn="http://www.w3.org/2005/xpath-functions" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:local="urn:local" version="3.0" > <xsl:mode on-no-match="shallow-copy"/> <xsl:function name="local:generateNextVersion" as="document-node()"> <xsl:param name="currentVersion" as="document-node()"/> <xsl:variable name="isFinalVersion" as="xs:boolean" select="$currentVersion/* eq '3'"/> <xsl:sequence select="if ($isFinalVersion) then $currentVersion else local:generateNextVersion(fn:transform(map { 'stylesheet-node' : doc(''), 'source-node' : $currentVersion })?output)"/> </xsl:function> <xsl:template match="*"> <xsl:message select="."/> <xsl:copy> <xsl:sequence select="let $customizedResult := fn:transform(map { 'stylesheet-node' : doc('bugs2.xsl'), 'source-node' : / })?output return local:generateNextVersion($customizedResult)"/> </xsl:copy> </xsl:template> </xsl:stylesheet> Here is bugs2.xsl <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fn="http://www.w3.org/2005/xpath-functions" version="3.0" > <xsl:mode on-no-match="shallow-copy"/> <xsl:template match="*"> <xsl:copy> <xsl:value-of select=". + 1"/> </xsl:copy> </xsl:template> </xsl:stylesheet> Here is input XML <bug>1</bug> Reproduction instructions. Run the transform bug.xsl against input bug.xml and see the xsl:message output below <bug>1</bug> <bug>2</bug> Change bug.xsl to test for $currentVersion eq '4' instead of 3 crashes as below <bug>1</bug> <bug>2</bug> Error in bugs2.xsl: XTSE0150 The supplied file does not appear to be a stylesheet Static error in bugs2.xsl: XTSE0150 The supplied file does not appear to be a stylesheet Error in bugs2.xsl: XTSE0150 The supplied file does not appear to be a stylesheet at function local:generateNextVersion in bug.xsl: invoked by function call In template rule with match="*" of bug.xsl invoked by built-in template rule (shallow-copy) The supplied file does not appear to be a stylesheet _______________________________________________ saxon-help mailing list archived at http://saxon.markmail.org/ [email protected] https://lists.sourceforge.net/lists/listinfo/saxon-help