|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: XSLT - update attribute with new value
Hi,
> Now I have one final question. I want to add an attribute/value to the
> xml tree only if that attribute does not exist anywhere in
> the document
> source tree.
>
> Is there a way to do that in XSLT?
<xsl:template match="the-node-to-add-the-attribute-to">
<xsl:copy>
<xsl:if test="not(//@the-attribute)">
<xsl:attribute name="the-attribute">the value</xsl:attribute>
</xsl:if>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
Cheers,
Jarno
|
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








