This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: To pass parameters to function
- To: "nmartella" <nmartella at tiscalinet dot it>
- Subject: Re: [xsl] To pass parameters to function
- From: Jeni Tennison <mail at jenitennison dot com>
- Date: Thu, 15 Feb 2001 12:57:20 +0000
- CC: xsl-list at lists dot mulberrytech dot com
- Organization: Jeni Tennison Consulting Ltd
- References: <3A87B3F2000C30A8@mail.tiscalinet.it> (added bypostmaster@mail.tiscalinet.it)
- Reply-To: xsl-list at lists dot mulberrytech dot com
Hi Nicola,
> <xsl:variable name="sVal" select='XXXXX'/>
> <xsl:value-of select="xsl:alignLeft($sVal,10)"/>
Here, you're setting the value of the variable $sVal to the node set
holding all the XXXXX children of the current node. I think you
wanted to pass the string 'XXXXX', in which case you need a couple of
extra quotes in there:
<xsl:variable name="sVal" select="'XXXXX'" />
A couple of things, though: you shouldn't really be using the XSLT
namespace for your own functions - make up one of your own - and you
can probably achieve what you want to achieve with foo:alignLeft() in
plain XSLT, e.g.:
<xsl:variable name="sVal" select="'XXXXX'" />
<xsl:value-of select="substring(
concat($sVal,
substring(' ',
string-length($sVal) + 1)),
1, 10)" />
Or, if you prefer, define a template that does the same thing:
<xsl:variable name="large-node-set" select="document('')//node()" />
<xsl:template name="alignLeft">
<xsl:param name="string" />
<xsl:param name="pad" />
<xsl:variable name="padding">
<!-- using the Piez Method for repeating a number of times -->
<xsl:for-each select="$large-node-set[position() <= $pad]">
<xsl:text> </xsl:text>
</xsl:for-each>
</xsl:variable>
<xsl:value-of select="substring(
concat($string,
substring($padding,
string-length($string) + 1)),
1, $pad)" />
</xsl:template>
and then call it with:
<xsl:call-template name="alignLeft">
<xsl:with-param name="string" select="$sVal" />
<xsl:with-param name="pad" select="10" />
</xsl:call-template>
Of course this is all based on my guess about what alignLeft does.
I hope that helps anyway,
Jeni
---
Jeni Tennison
http://www.jenitennison.com/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list