5

ビジュアルスタジオ(web.config変換)では、ルート要素に2つの属性を追加する変換があります。 1つのアトリビュートが機能します(複数のアトリビュートは動作しません)。 子要素に複数の属性を設定できます。 私は属性の名前を指定して、指定せずにSetAttributesを試しましたが、運はありません。web.config変換を使用してルートelemementに複数の属性を設定する

アイデア??

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

this t

<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> 
ransformationを更新は、これは明らかにどちらか動作しません

(スローチーターを使用して)element.configファイルで使用されることを意味しています

ルート要素に2つ以上の属性があるとすぐに失敗します。

答えて

0

012の文書要素ファイルは<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> 
+0

、申し訳ありません、それは自己web.configファイルではないと言うことを意味しますが、このショーそのカスタムセクション。しかし、SetAttributesは1つの属性では動作しますが、2つでは動作しません...ルート要素では面白いです –

6

は、あなたが)(SetAttributeのに設定する属性のリストを渡すことで、同時に複数の属性を設定し、このように変換しようとしたことがありますか?

hereフォームを参照してください。 Secifically

=「をsetAttributes(1つ以上の属性名のカンマ区切りのリスト)」を変換

<element xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform" xdt:Transform="SetAttributes(attrOne,attrTwo)" attrOne="One" attrTwo="Two"> 
    <children> 
    <child name="One" xdt:Transform="SetAttributes(attrOne,attrTwo)" attrOne="One" attrTwo="Two" /> 
    </children> 
</element>