Altova Mailing List Archives>Archive Index >comp.text.xml Archive Home >Recent entries >Thread Prev - Re: Template that adds a given attribute and value [Thread Next] Re: Template that adds a given attribute and valueTo: NULL Date: 6/8/2008 9:25:00 AM
On 07-06-2008 15:05:54, Martin Honnen wrote:
> You have already posted much of the solution:
> <xsl:template name="add-attribute">
> <xsl:param name="el"/>
> <xsl:param name="att-name"/>
> <xsl:param name="att-value"/>
> <xsl:for-each select="$el">
> <xsl:copy>
> <xsl:copy-of select="@*"/>
> <xsl:attribute name="{$att-name}">
> <xsl:value-of select="$att-value"/>
> </xsl:attribute>
> <xsl:copy-of select="node()"/>
> </xsl:copy>
> </xsl:for-each>
> </xsl:template>
>
> Call as
>
> <xsl:call-template name="add-attribute">
> <xsl:with-param name="el" select="foo"/>
> <xsl:with-param name="att-name" select="'bar'"/>
> <xsl:with-param name="att-value" select="'baz'"/>
> </xsl:call-template>
Perfect! Thanks, Martin.
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
