在 Visual Studio(web.config 转换)中,我有一个要执行的转换,它在根元素上添加两个属性。一种属性有效(但不是多种属性)。我可以在一个子元素上设置多个属性。我试过 SetAttributes 有和没有指定属性的名称,没有运气。
想法??
例子
<element xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform" xdt:Transform="SetAttributes" attrOne="One" attrTwo="Two">
<children>
<child name="One" xdt:Transform="SetAttributes" attrOne="One" attrTwo="Two" />
</children>
</element>
想要的效果
<element attrOne="One" attrTwo="Two">
<children>
<child name="One" attrOne="One" attrTwo="Two" />
</children>
</element>
“元素”部分实际上是 web.config 文件的自定义部分......就像这样:
<configuration>
... <element configSource="App_Data\element.config" />
此转换旨在用于 element.config 文件(使用慢 cheetah)
更新 这显然也不起作用:
<element xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform" xdt:Transform="Replace" attrOne="One" attrTwo="Two">
<children>
<child name="One" attrOne="One" attrTwo="Two" />
</children>
</element>
但这确实:
<element xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform" xdt:Transform="Replace" attrOne="One">
<children>
<child name="One" attrOne="One" attrTwo="Two" />
</children>
</element>
只要根元素上有超过 1 个属性,它就会失败