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

Re: To pass parameters to function

Subject: Re: To pass parameters to function
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Thu, 15 Feb 2001 12:57:20 +0000
pass select to a function
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() &lt;= $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


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.