Subject: Re: [xsl] Removing an XML Attribute From: Tony Graham <Tony.Graham@xxxxxxxxxxxxxxxxxxxxxx> Date: Thu, 05 Jul 2007 00:11:40 +0100 |
On Wed, Jul 04 2007 19:10:22 +0100, Shaun.McDonald@xxxxxxxxxxx wrote: > I came up with something that appears to work, only I'm not sure if > there is a caveat to doing it this way. > > Since I'm transforming almost 100 files, I want to make sure nothing > bites me in the rear. > > Using XSLT 2.0, Saxon 8.8 > > <xsl:template match="*"> > <xsl:copy> > <xsl:choose> > <xsl:when test="not(@change)"> > <xsl:copy-of select="@* "/> > </xsl:when> > <xsl:otherwise/> > </xsl:choose> > <xsl:apply-templates/> > </xsl:copy> > </xsl:template> > > I'm still spot-checking the files, but so far it seems to have removed > the @change attribute only, which is my desired output. That would appear to be because @change is the only attribute on that particular element. Your template copies all attributes if @change is not present, and copies no attributes if it is present. (If you have just one test, you can use xsl:if instead of xsl:choose, and when you do use xsl:choose, the xsl:otherwise is optional.) Try just: <xsl:copy-of select="@*[not(self::change)]"/> Regards, Tony Graham. ====================================================================== Tony.Graham@xxxxxxxxxxxxxxxxxxxxxx http://www.menteithconsulting.com Menteith Consulting Ltd Registered in Ireland - No. 428599 Registered Office: 13 Kelly's Bay Beach, Skerries, Co. Dublin, Ireland ======================================================================
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Removing an XML Attribute, McDonald, Shaun | Thread | Re: [xsl] Removing an XML Attribute, Wendell Piez |
Re: [xsl] Testing implicit XHTML hi, David Carlisle | Date | Re: [xsl] Testing implicit XHTML hi, bryan rasmussen |
Month |