RE: [xsl] attribute problem

Subject: RE: [xsl] attribute problem
From: "Michael Kay" <mhkay@xxxxxxxxxxxx>
Date: Tue, 11 Sep 2001 17:41:02 +0100
> 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


Current Thread