2012-04-28 104 views
4

如何选择注释或使用Web.config转换插入注释?Web.Config转换xml注释

无处可以找到关于此的任何信息。

我试图做之一: 1)在Web.config现有注释前插入一块XML(<serviceAuthorization impersonateCallerForAllOperations="true"/>)的

OR

2)将在最后的注释和XML一组兄弟姐妹的:

至于我可以告诉Web.config文件转换不支持XPath轴,我已经尝试了一些他们的尝试和第一注释前插入一个节点:

<serviceAuthorization impersonateCallerForAllOperations="true" xdt:Transform="InsertBefore(/configuration/system.serviceModel/behaviors/serviceBehaviors/behavior[@name='behaviorOne']/serviceMetadata/preceding::comment()[1])"/> 

<serviceAuthorization impersonateCallerForAllOperations="true" xdt:Transform="InsertBefore(/configuration/system.serviceModel/behaviors/serviceBehaviors/behavior[@name='behaviorOne']/child::node()[1]"/> 

我已经尝试了其他几个,但你明白了。预览变换时我只是遇到了一个错误。

我似乎也无法找到关于如何插入评论的任何信息。我错过了什么吗?

回答

2

我相信转换仅限于对元素或属性进行操作。至少,xdt:Transform上的documentation都没有提及可用于添加评论的任何内容。

至于定位,那里似乎是为轴线一些支持,我可以使用以下命令:

<spring > 
<objects xmlns="http://www.springframework.net"> 
    <object name="requestConfig" type="Example.Namespace.RequestConfig, Example" singleton ="true"> 
     <constructor-arg index="0" type="System.Uri" value="https://example.com/production"/> 
     <constructor-arg index="1" value="45000"/> 
    </object> 
</objects> 

<spring > 
<objects xmlns="http://www.springframework.net"> 
    <object > 
    <constructor-arg index="0" type="System.Uri" value="https://example.com/test" xdt:Locator="Condition(../@name='requestConfig' and @index='0')" xdt:Transform="SetAttributes(value)"/> 
    </object> 
</objects> 

以下操作时

正如你所看到的,abov e使用父轴来匹配要变换的元素。