Subject: Aw: Re: [xsl] passing a function as a parameter to transform() From: "Martin Honnen martin.honnen@xxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Fri, 14 May 2021 12:39:47 -0000 |
Use $local:function -- Diese Nachricht wurde von meinem Android Mobiltelefon mit GMX Mail gesendet.Am 14.05.21, 14:15 schrieb "Graydon graydon@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>: 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.") XSL-List info and archiveEasyUnsubscribe (by email)
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: Re: [xsl] passing a function a, Graydon graydon@xxxx | Thread | Re: Re: [xsl] passing a function a, Graydon graydon@xxxx |
Re: Re: [xsl] passing a function a, Graydon graydon@xxxx | Date | Re: [xsl] passing a function as a p, Michael Kay mike@xxx |
Month |