[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] 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
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
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|