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

Re: xsl:param syntax please

Subject: Re: xsl:param syntax please
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Wed, 18 Apr 2001 18:51:00 +0100
xsl foreach syntax
Hi,

> <xsl:for-each select="parameter">
>         <xsl:param name="'concat('preParameterValue',position())" 
select="'abcdef'"/>>
> <name><xsl:value-of select="name"/></name>
> <value><xsl:value-of 
> select="$concat('preParameterValue',position())"/></value>
>         </xsl:for-each>
>
> i want to create a parameter in the above way i am able to creat it
> but i dontknow how to get the value of that parameter is there any
> other way to do that

I think that you're hoping that the above would name parameters
dynamically - $preParameterValue1, $preParameterValue2 and so on.  I'm
afraid that you can't do that in XSLT.

I'm a bit confused, though, by the way that you're using xsl:param -
xsl:param should only be used as the first child of xsl:template (for
passing parameters into a template) or of xsl:stylesheet (for passing
parameters into a stylesheet).  I think that in the above you're
trying to use xsl:param as a synonym for xsl:variable, so you're
trying to store the string 'abcdef' as a variable, and then retrieving
it.

The good news is that the above could be achieved with:

  <!-- iterate over the parameter elements -->
  <xsl:for-each select="parameter">
     <!-- create a name element, with a value equal to the value of
          the name subelement of the parameter element -->
     <name><xsl:value-of select="name" /></name>
     <!-- create a value element, with a value equal to the string
         'abcdef' -->
     <value>abcdef</value>
  </xsl:for-each>

Or, if you want to use a variable, you could use:
  
  <!-- iterate over the parameter elements -->
  <xsl:for-each select="parameter">
     <!-- set the $preParameterValue variable to the string 'abcdef'
          -->
     <xsl:variable name="preParameterValue" select="'abcdef'" />
     <!-- create a name element, with a value equal to the value of
          the name subelement of the parameter element -->
     <name><xsl:value-of select="name" /></name>
     <!-- create a value element, with a value equal to the value of
          the $preParameterValue variable -->
     <value><xsl:value-of select="$preParameterValue" /></value>
  </xsl:for-each>

If you need to have a set of variables holding a number of values, but
don't know how many variables you're going to need, then you should
use the equivalent of an array in XSLT - you should create a result
tree fragment, which you can then turn into a node set in order to get
its content.

However, it's really not clear what you're trying to achieve with the
above code snippet; it's likely that there's another way of doing
whatever you're trying to do, and if you give us more information then
we'll be glad to help you with it.

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.