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

Re:  Re:  Re: passing a function as a parameter to tr

Subject: Re:  Re:  Re: 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
Re:  Re:  Re:  passing a  function as a parameter to tr
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

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.