我正在尝试编写XSLT来修改配置文件。我尝试过使用replace函数,但这仅在2.0中受支持,我也尝试过使用translate,但与“false”相关的“true”trn被截断为“fals”。我不能仅仅更换整个模块部分,因为我们的客户处于分布式环境中,我不知道他们是否在该部分添加了其他内容。
我从以下几点开始:
<modules runAllManagedModulesForAllRequests="true">
<remove name="FormsAuthentication" />
</modules>
期望输出:
<modules runAllManagedModulesForAllRequests="false">
<remove name="FormsAuthentication" />
</modules>
这就是我认为会起作用的东西。
<xsl:template match="/configuration/system.webServer/modules">
<xsl:choose>
<xsl:when test="@name=runAllManagedModulesForAllRequests">
<xsl:copy>
<xsl:copy-of select="<modules runAllManagedModulesForAllRequests="false">"/>
</xsl:copy>
</xsl:when>
<xsl:otherwise>
<xsl:copy>
<xsl:copy-of select="@*"/>
</xsl:copy>
</xsl:otherwise>
</xsl:choose>
</xsl:template>