我的 Web 配置中有以下 XML,我想使用 web.config 转换选择要删除的属性,但我想根据其中一个子元素的值选择要删除的元素。
我的 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>
正如中所回答的这个问题 https://stackoverflow.com/questions/9707108/xdt-transform-locator-that-matches-subnode-content/9707298 the xdt:Locator
属性需要使用Condition
句法。所以所需的选择器是:
<agent type="Sitecore.Tasks.DatabaseAgent"
xdt:Transform="Remove"
xdt:Locator="Condition(param/@desc='database' and param/text()='master')" />
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)