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


Jeni,
         Is there a way to change the value of an xml element through 
jsplike if i have

a.xml
-----
<details>
<name>jax</name>
</details>

what i want to do is that i want to change the value of the name element 
from "jax" to "jeni" what is the correct way to do this is it possible 
throught xslt cause have the idea of using parameters so that we can pass 
the value as a parameter and use a style sheet which generates another xml 
with the same structure and with the values passed as parameters is ths the 
right way we can do it or what is the right way to do it....... i appriciate 
ur help

Thanx
JAX


From: Jeni Tennison <mail@jenitennison.com>
Reply-To: xsl-list@lists.mulberrytech.com
To: "Java XML" <jaxlive@hotmail.com>
CC: XSL-List@lists.mulberrytech.com
Subject: Re: [xsl] xsl:param syntax please
Date: Wed, 18 Apr 2001 18:51:00 +0100

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


_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.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]