Subject: RE: [xsl] XSLT - update attribute with new value From: <Jarno.Elovirta@xxxxxxxxx> Date: Mon, 8 Nov 2004 17:43:23 +0200 |
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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] XSLT - update attribute w, Michael Kay | Thread | [xsl] XSLT - update attribute with , Ann Marie Rubin |
Re: [xsl] Need a programmic way to , David Carlisle | Date | RE: [xsl] Need a programmic way to , Andrew Welch |
Month |