|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Adding attributes
"Ivan Rubin Ayma" <Iayma@xxxxxxxxxxxx> 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








