我的web配置中有以下XML,我想使用web.config转换选择要删除的属性,但我想根据其中一个子元素的值选择要删除的元素。 / p>
我的web.config是这样的:
<configuration>
<sitecore>
<scheduling>
<agent type="Sitecore.Tasks.DatabaseAgent">
<param desc="database">core</param>
</agent>
<agent type="Sitecore.Tasks.DatabaseAgent">
<param desc="database">master</param>
</agent>
</scheduling>
</sitecore>
</configuration>
我尝试过以下尝试根据子元素<param desc="database">master</param>
选择要删除的第二个代理元素,但没有成功。
<configuration>
<sitecore>
<scheduling>
<!-- Attempt 1 -->
<agent type="Sitecore.Tasks.DatabaseAgent"
xdt:Transform="Remove"
xdt:Locator="XPath(configuration/sitecore/scheduling/agent/param[text()='master'])"/>
<!-- Attempt 2 -->
<agent type="Sitecore.Tasks.DatabaseAgent"
xdt:Transform="Remove">
<param desc="database"
xdt:Locator="XPath([text()='master'])"/>
</agent>
</scheduling>
</sitecore>
</configuration>
答案 0 :(得分:6)
正如this question中所述,xdt:Locator
属性需要使用Condition
语法。所以所需的选择器是:
<agent type="Sitecore.Tasks.DatabaseAgent"
xdt:Transform="Remove"
xdt:Locator="Condition(param/@desc='database' and param/text()='master')" />
答案 1 :(得分:2)
只需使用Sitecores自己的配置修补程序。这将删除您的设置:
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<scheduling>
<agent patch:instead="*[@type='Sitecore.Tasks.DatabaseAgent' and param='master']">
</agent>
</scheduling>
</sitecore>
</configuration>
有关详细信息,请查看此处:
http://intothecore.cassidy.dk/2009/05/working-with-webconfig-include-files-in.html http://www.thescrewballdivision.com/playing-with-sitecore-include-files
答案 2 :(得分:-1)
只需将/..
添加到最后,应该这样做..
e.g。
XPath(configuration/sitecore/scheduling/agent/param[text()='master']/..)