Subject: Re: [xsl] passing a function as a parameter to transform() From: "Michael Kay mike@xxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Fri, 14 May 2021 13:05:25 -0000 |
You're calling <xsl:sequence select="local:tiny('away')" />, but there is no function named local:tiny in scope. What there is is a variable (parameter) named local:tiny, whose value is a function. So you need a dynamic call on the function held in the variable, not a static call on a function named local:tiny(). That is, you need <xsl:sequence select="$local:tiny('away')" /> Michael Kay Saxonica > On 14 May 2021, at 13:15, Graydon graydon@xxxxxxxxx <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote: > > On Thu, May 13, 2021 at 09:20:49PM -0000, Michael Kay mike@xxxxxxxxxxxx scripsit: >> To pass the function itself, rather than the result of a function call, use local:getString#2. > > Thank you! > > That moves the error into the stylesheet called by transform(): > > Engine name: Saxon-EE 10.3 (External) > Severity: error > Description: Cannot find a 1-argument function named Q{data:,dpc}tiny() > > The tiny test example has an "outer" stylesheet: > > <?xml version="1.0" encoding="UTF-8"?> > <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > xmlns:xs="http://www.w3.org/2001/XMLSchema" > xmlns:math="http://www.w3.org/2005/xpath-functions/math" > xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl" > xmlns:local="data:,dpc" > exclude-result-prefixes="xs math xd local" > version="3.0"> > <xd:doc scope="stylesheet"> > <xd:desc> > <xd:p><xd:b>Created on:</xd:b> May 13, 2021</xd:p> > <xd:p><xd:b>Author:</xd:b> graydon</xd:p> > <xd:p>pass a function to a transform() call</xd:p> > </xd:desc> > </xd:doc> > <xd:doc> > <xd:desc>minimalist function</xd:desc> > <xd:param name="in">whatever string we're called with</xd:param> > </xd:doc> > <xsl:function name="local:tiny" as="text()"> > <xsl:param name="in" as="xs:string" /> > <xsl:value-of select="$in" /> > </xsl:function> > > <!-- test content --> > <xsl:variable name="consume" as="document-node()"> > <xsl:document> > <stuff> > <goes> > <here>Around the words</here> > </goes> > </stuff> > </xsl:document> > </xsl:variable> > > <xd:doc> > <xd:desc>do the thing</xd:desc> > </xd:doc> > <xsl:template name="xsl:initial-template"> > <xsl:variable name="testResult"> > <xsl:sequence select=" > transform(map { > 'stylesheet-location': 'functionTest.xsl', > 'source-node': $consume, > 'stylesheet-params': map { > QName('local', 'tiny'): local:tiny#1 > } > })?output" /> > </xsl:variable> > <xsl:sequence select="$testResult" /> > </xsl:template> > </xsl:stylesheet> > > calling > > <?xml version="1.0" encoding="UTF-8"?> > <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > xmlns:xs="http://www.w3.org/2001/XMLSchema" > xmlns:math="http://www.w3.org/2005/xpath-functions/math" > xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl" > xmlns:local="data:,dpc" > exclude-result-prefixes="xs math xd local" > version="3.0"> > <xd:doc scope="stylesheet"> > <xd:desc> > <xd:p><xd:b>Created on:</xd:b> May 13, 2021</xd:p> > <xd:p><xd:b>Author:</xd:b> graydon</xd:p> > <xd:p></xd:p> > </xd:desc> > </xd:doc> > <xsl:param name="local:tiny" as="function(xs:string) as text()" /> > > <xsl:mode on-no-match="shallow-copy"/> > > <xd:doc> > <xd:desc>this is the test case</xd:desc> > </xd:doc> > <xsl:template match="goes"> > <xsl:copy> > <xsl:sequence select="local:tiny('away')" /> > </xsl:copy> > </xsl:template> > </xsl:stylesheet> > > presumably I have not set the parameter up correctly to be recognized as > a function in the stylesheet being called by transform(), but I'm > finding myself at a loss as to how not. > > What am I doing wrong, here? > > Thanks! > > -- > Graydon Saunders | graydonish@xxxxxxxxx > CC&s oferC)ode, C0isses swC! mC&g. > -- Deor ("That passed, so may this.")
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: Re: Re: [xsl] passing a func, Graydon graydon@xxxx | Thread | Re: [xsl] passing a function as a p, Graydon graydon@xxxx |
Aw: Re: [xsl] passing a function as, Martin Honnen martin | Date | Re: Re: [xsl] passing a function a, Graydon graydon@xxxx |
Month |