This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: xsl:param syntax please


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]