Re:  Re:  Re: [xsl] passing a function as a parameter to transform()

Subject: Re:  Re:  Re: [xsl] passing a function as a parameter to transform()
From: "Graydon graydon@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 14 May 2021 13:48:20 -0000
On Fri, May 14, 2021 at 01:30:39PM -0000, Martin Honnen martin.honnen@xxxxxx scripsit:
>  The parameter passing needs to use the URI of the namespace

and not the namespace prefix.  (Argh.)

That works!  Thank you!

Apologies for the cabbage-nature.

For anyone who might be curious, the working version is:

<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()" visibility="public">
    <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('data:,dpc', 'tiny'): local:tiny#1
            }
          })?output" />
    </xsl:variable>
    <xsl:sequence select="$testResult" />
  </xsl:template>
</xsl:stylesheet>

<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 as="function(xs:string) as text()" name="local:tiny" />

  <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>


-- 
Graydon Saunders  | graydonish@xxxxxxxxx
^fs oferiode, pisses swa mfg.
-- Deor  ("That passed, so may this.")

Current Thread