[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: Thu, 19 Apr 2001 08:44:59 +0100
xsl param syntax
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

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.