[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: passing a function as a parameter to transform()

Subject: Re: passing a function as a parameter to transform()
From: "Michael Kay mike@xxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 13 May 2021 21:20:43 -0000
Re:  passing a function as a parameter to transform()
> On 13 May 2021, at 22:05, Graydon graydon@xxxxxxxxx
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
>
> Hello --
>
> Using Saxon 10.3 and XSLT 3.0 (from inside oXygen 23), can I pass a function
as
> a parameter to transform()?
>
> <xsl:sequence select="
> transform(map {
>   'stylesheet-location': 'tidy.xsl',
>   'source-node': $tableMerge,
>   'stylesheet-params': map {
>     QName('', 'defaultLang'): $defaultLang,
>     QName('', 'overrideStringMap'): $overrideStringMap,
>     QName('', 'lang2key2autotextMap'): $lang2key2autotextMap,
>     QName('local','getString') : local:getString(xs:string,xs:string)
>   }
> })?output" />
>
> is syntactically acceptable.

yes, but you aren't passing a function, you are passing the result of calling
local:getString with parameters child::xs:string and child::xs:string. Unless
you have any child elements called xs:string, which is unlikely, the actual
parameter values are empty sequences, which is probably why the function is
complaining.

To pass the function itself, rather than the result of a function call, use
local:getString#2.

Michael Kay
Saxonica

>
> Inside tidy.xsl,
>
> <xsl:param as="xs:string" name="defaultLang" />
>  <xsl:param as="map(*)" name="overrideStringMap" />
>  <xsl:param as="map(*)" name="lang2key2autotextMap" />
>  <xsl:param as="function(xs:string,xs:string) as xs:string"
name="local:getString" />
>
> is syntactically acceptable (though oXygen complains about the actual
function calls and not being able to find the function).
>
> If I run the transform, though, I get:
> Engine name: Saxon-EE 10.3 (External)
> Severity: error
> Description: An empty sequence is not allowed as the first argument of
local:getString()
>
> with a location that tells me the transform call parameter map is where the
error happens.
>
> Is there a way to do this?  I can of course duplicate the function
definition but that seems improper.
>
> Thanks!
>
>
> --
> Graydon Saunders  | graydonish@xxxxxxxxx
> CC&s oferC)ode, C0isses swC! mC&g.
> -- Deor  ("That passed, so may this.")

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.