[prev in list] [next in list] [prev in thread] [next in thread]
List: xsl-list
Subject: Aw:=?UTF-8?B?wqBSZQ==?=: [xsl] passing a function as a parameter to transform()
From: "Martin Honnen martin.honnen () gmx ! de" <xsl-list-service () lists ! mulberrytech ! com>
Date: 2021-05-14 12:40:12
Message-ID: 20210514083946.ca62beb2 () lists ! mulberrytech ! com
[Download RAW message or body]
<html>
<head>
<meta name="viewport" content="width=device-width">
<meta http-equiv="Content-Type" content="text/vnd.ui.insecure+html;charset=utf-8">
</head>
<body style="overflow-wrap:break-word; word-break: break-word;"><div \
class="mail_android_message" style="line-height: 1; padding: 0.5em">Use \
$local:function<br/><br/>--<br/>Diese Nachricht wurde von meinem Android Mobiltelefon \
mit GMX Mail gesendet.</div><div class="mail_android_quote" style="line-height: 1; \
padding: 0.3em"><html><body>Am 14.05.21, 14:15 schrieb "Graydon \
graydon@marost.ca" \
<xsl-list-service@lists.mulberrytech.com>:</body></html><blockquote \
class="gmail_quote" style="margin: 0.8ex 0pt 0pt 0.8ex; border-left: 1px solid \
rgb(204, 204, 204); padding-left: 1ex;">
On Thu, May 13, 2021 at 09:20:49PM -0000, Michael Kay mike@saxonica.com scripsit:
<br> > To pass the function itself, rather than the result of a function call, \
use local:getString#2. <br>
<br> Thank you!
<br>
<br> That moves the error into the stylesheet called by transform():
<br>
<br> Engine name: Saxon-EE 10.3 (External)
<br> Severity: error
<br> Description: Cannot find a 1-argument function named Q{data:,dpc}tiny()
<br>
<br> The tiny test example has an "outer" stylesheet:
<br>
<br> <?xml version="1.0" encoding="UTF-8"?>
<br> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
<br> xmlns:xs="http://www.w3.org/2001/XMLSchema"
<br> xmlns:math="http://www.w3.org/2005/xpath-functions/math"
<br> xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl"
<br> xmlns:local="data:,dpc"
<br> exclude-result-prefixes="xs math xd local"
<br> version="3.0">
<br> <xd:doc scope="stylesheet">
<br> <xd:desc>
<br> <xd:p><xd:b>Created on:</xd:b> May 13, 2021</xd:p>
<br> <xd:p><xd:b>Author:</xd:b> graydon</xd:p>
<br> <xd:p>pass a function to a transform() call</xd:p>
<br> </xd:desc>
<br> </xd:doc>
<br> <xd:doc>
<br> <xd:desc>minimalist function</xd:desc>
<br> <xd:param name="in">whatever string we're called with</xd:param>
<br> </xd:doc>
<br> <xsl:function name="local:tiny" as="text()">
<br> <xsl:param name="in" as="xs:string" />
<br> <xsl:value-of select="$in" />
<br> </xsl:function>
<br>
<br> <!-- test content -->
<br> <xsl:variable name="consume" as="document-node()">
<br> <xsl:document>
<br> <stuff>
<br> <goes>
<br> <here>Around the words</here>
<br> </goes>
<br> </stuff>
<br> </xsl:document>
<br> </xsl:variable>
<br>
<br> <xd:doc>
<br> <xd:desc>do the thing</xd:desc>
<br> </xd:doc>
<br> <xsl:template name="xsl:initial-template">
<br> <xsl:variable name="testResult">
<br> <xsl:sequence select="
<br> transform(map {
<br> 'stylesheet-location': 'functionTest.xsl',
<br> 'source-node': $consume,
<br> 'stylesheet-params': map {
<br> QName('local', 'tiny'): local:tiny#1
<br> }
<br> })?output" />
<br> </xsl:variable>
<br> <xsl:sequence select="$testResult" />
<br> </xsl:template>
<br> </xsl:stylesheet>
<br>
<br> calling
<br>
<br> <?xml version="1.0" encoding="UTF-8"?>
<br> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
<br> xmlns:xs="http://www.w3.org/2001/XMLSchema"
<br> xmlns:math="http://www.w3.org/2005/xpath-functions/math"
<br> xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl"
<br> xmlns:local="data:,dpc"
<br> exclude-result-prefixes="xs math xd local"
<br> version="3.0">
<br> <xd:doc scope="stylesheet">
<br> <xd:desc>
<br> <xd:p><xd:b>Created on:</xd:b> May 13, 2021</xd:p>
<br> <xd:p><xd:b>Author:</xd:b> graydon</xd:p>
<br> <xd:p></xd:p>
<br> </xd:desc>
<br> </xd:doc>
<br> <xsl:param name="local:tiny" as="function(xs:string) as text()" />
<br>
<br> <xsl:mode on-no-match="shallow-copy"/>
<br>
<br> <xd:doc>
<br> <xd:desc>this is the test case</xd:desc>
<br> </xd:doc>
<br> <xsl:template match="goes">
<br> <xsl:copy>
<br> <xsl:sequence select="local:tiny('away')" />
<br> </xsl:copy>
<br> </xsl:template>
<br> </xsl:stylesheet>
<br>
<br> presumably I have not set the parameter up correctly to be recognized as
<br> a function in the stylesheet being called by transform(), but I'm
<br> finding myself at a loss as to how not.
<br>
<br> What am I doing wrong, here?
<br>
<br> Thanks!
<br>
<br> --
<br> Graydon Saunders | graydonish@gmail.com
<br> Þæs oferéode, ðisses swá mæg.
<br> -- Deor ("That passed, so may this.")
<br>
<br>
<br>
</blockquote></div></body>
</html>
<div><!-- begin bl.html.trailer -->
<div style="border-top:1px solid black; background-color: #dddddd;
color: #888888; font-size: smaller; padding: 5px; text-align: center;
font-family: arial,verdana,arial,sans-serif; margin-top:1em; clear:
both; margin: auto">
<a href="http://www.mulberrytech.com/xsl/xsl-list">
XSL-List info and archive</a>
<div style="text-align:center;">
<a style="color: blue;"
href="http://lists.mulberrytech.com/unsub/xsl-list/651070"
> EasyUnsubscribe</a>
(<a style="color: blue;"
href="mailto:xsl-list-unsub@lists.mulberrytech.com?subject=remove"
> by email</a>)
</div>
</div>
<!-- end bl.html.trailer --></div>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic