9

Visual Studio (web.config 変換) では、ルート要素に 2 つの属性を追加する、実行したい変換があります。1 つの属性が機能します (ただし、複数の属性は機能しません)。また、子要素に複数の属性を設定できます。属性の名前を指定して、または指定せずに 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 ファイルで使用することを意図しています (遅いチーターを使用)。

更新 これも明らかに機能しません:

<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>

ルート要素に複数の属性があるとすぐに失敗します

4

2 に答える 2

0

web.configファイルのドキュメント要素は<configuration>. あなたの例で<element>は、おそらくの子です<configuration>。試す:

<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
    <element xdt:Transform="SetAttributes" attrOne="One" attrTwo="Two">
        <children>
            <child xdt:Transform="SetAttributes" name="One"
                   attrOne="One" attrTwo="Two" />
        </children>
    </element>
</configuration>
于 2012-07-31T08:29:40.937 に答える