This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: attribute problem


> 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]