This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: attribute problem
- To: <xsl-list at lists dot mulberrytech dot com>
- Subject: RE: [xsl] attribute problem
- From: "Michael Kay" <mhkay at iclway dot co dot uk>
- Date: Tue, 11 Sep 2001 17:41:02 +0100
- Reply-To: xsl-list at lists dot mulberrytech dot com
> I am writing a xsl stylesheet for adding attribute to the
> element but facing
> problems .I need to take the attribute(name value) as wel as
> element name as
> a parameter from the user.Can anybody tell me how should I
> achieve this?
Declare global parameters in your stylesheet:
<xsl:param name="elname"/>
<xsl:param name="attname"/>
Then write something like
<xsl:template match="*">
<xsl:if test="name() = $elname">
<xsl:copy>
<xsl:attribute name="{$attname}">new value</xsl:attribute>
<xsl:apply-templates/>
</xsl:copy>
</xsl:if>
</xsl:template>
Mike Kay
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list