Set multiple attributes on root element using web.config transform

In visual studio (web.config conversions), I have a transform that I want to perform by adding two attributes to the root element. One attrbute works (but not several). And I can set some attributes for the child. I tried SetAttributes with and without attribute names, no luck.

Ideas ??

Example

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

desired effect

    <element attrOne="One" attrTwo="Two">
      <children>
       <child name="One" attrOne="One" attrTwo="Two" />
      </children>
    </element>

The "element" section is indeed a custom section of the web.config file ... for example:

<configuration>

... <element configSource="App_Data\element.config" />

this conversion is for use in the element.config file (using a slow cheetah)

Update This, apparently, does not work either:

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

But it does:

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

As soon as there is more than 1 attribute in the root element, it fails

+5
2

, , , SetAttribute()?

. .

Secifically: Transform = "SetAttributes ( - )"

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

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

All Articles