This transformation:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="node()|@*" name="identity">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="system.web/compilation[1]/@debug">
<xsl:attribute name="debug">false</xsl:attribute>
</xsl:template>
</xsl:stylesheet>
when applied on this XML document:
<configuration>
<system.web>
<compilation debug="true" defaultLanguage="C#">
<!-- this is a comment -->
</compilation>
<compilation debug="true" defaultLanguage="C#">
<!-- this is another comment -->
</compilation>
</system.web>
</configuration>
produces the wanted, correct result: modifies the debug
attribute of the first compilation
child of any system.web
element (but we know that there is only one system.web
element in a config file.
<configuration>
<system.web>
<compilation debug="false" defaultLanguage="C#">
<!-- this is a comment -->
</compilation>
<compilation debug="true" defaultLanguage="C#">
<!-- this is another comment -->
</compilation>
</system.web>
</configuration>
As we see, only the first debug
atribute is modifird to false
, as required.