Subject: Re: [xsl] xsl:param syntax please From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx> Date: Thu, 19 Apr 2001 08:44:59 +0100 |
Hi Jax, > 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 Is it always the value of the name element that you want to change? If so, then you can pass in the new value through a parameter. Define the parameter at the top level of the stylesheet: <xsl:param name="new-name" /> And then perform a recursive copy using a variant of the identity template: <xsl:template match="node()"> <xsl:copy> <xsl:copy-of select="@*" /> <xsl:apply-templates select="node()" /> </xsl:copy> </xsl:template> And have a template that overrides this to deal specially with the name element, creating a copy but placing the new value within it instead: <xsl:template match="name"> <xsl:copy><xsl:value-of select="$new-name" /></xsl:copy> </xsl:template> Note that this isn't really *changing* the value of the name element, it's just creating a new node tree in which the value of the name element is different from what it was in the source XML. How you pass the value of the parameter into the stylesheet depends on the processor you're using and how you're accessing it. I'm afraid I don't know enough about accessing Xalan (or perhaps any TRAX processor) through JSP to help you with how to do that, but someone else here may be able to, or you could try reading the documentation that comes with the processor. I hope that helps, Jeni --- Jeni Tennison http://www.jenitennison.com/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] xsl:param syntax please, Java XML | Thread | [xsl] msxsl command line transforma, bill french |
[xsl] Transform min and max values , Michael Strasser | Date | Re: [xsl] Sorting and Grouping revi, David Carlisle |
Month |