5

Visual Studio (web.config 변환)에서 루트 요소에 두 가지 특성을 추가하는 수행 할 변환이 있습니다. 하나의 속성이 작동합니다 (여러 개는 아님). 그리고 자식 요소에 여러 속성을 설정할 수 있습니다. 속성 이름을 지정하거나 지정하지 않고 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" /> 

이 부분은 ransformation는 분명히 작동하거나하지 않습니다이

업데이트 을 (느린 치타를 사용하여) 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> 

루트 요소에 속성이 두 개 이상 있으면 오류가 발생합니다.

답변

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가 하나의 속성으로 작동하지만 두 개가 아닌 것은 흥미 롭습니다. 루트 요소에서 ... –

6

당신이이()의 setAttribute로 설정하는 속성 목록을 전달하여 동시에 여러 속성을 설정하는 다음과 같이 변환 시도?

자세한 내용은 here 양식을 참조하십시오.

Secifically : = "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> 
관련 문제