This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: Adding attributes
"Ivan Rubin Ayma" <Iayma@mcsla.com.ar> writes:
> Suppose I had an XML:
>
> <myelement type="10">
> <somedata/>
> </myelement>
>
> and with the transformation I need to get:
>
> <myelement type="10" color="blind">
> <somedata/>
> </myelement>
I'm supposing you mean something like this:
<xsl:template match="myelement[@type='10']">
<myelement type="10" color="blind">
<xsl:apply-templates />
</myelement
</xsl:template>
In this example, the template only matches myelement's that have a
type equal to 10. OTOH, this would match 'myelement' and update
the element itself if and only if type = '10'
<xsl:template match="myelement">
<myelement type="{@type}">
<xsl:if test="@type='10'">
<xsl:attribute name="color">
blind
</xsl:attribute>
</xsl:if>
<xsl:apply-templates/>
</myelement>
</xsl:template>
Elizabeth
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list