由网友(三岁会撩人)分享简介:我有以下的XML在我的web配置,我想使用的web.config转换来选择要删除的属性,但我想选择的基础上的子元素之一的值去除的元素。我的web.config是这样的:<结构>< Sitecore的><调度><代理类型=Sitecore.Tasks.DatabaseAgent&...![怎么建web.config文件](https://p.xsw88.cn/allimgs/daicuo/20230903/1565.png)
我有以下的XML在我的web配置,我想使用的web.config转换来选择要删除的属性,但我想选择的基础上的子元素之一的值去除的元素。
我的web.config是这样的:
<结构>
< Sitecore的>
<调度>
<代理类型=Sitecore.Tasks.DatabaseAgent>
<参数说明=数据库>核心< /参数>
< /剂>
<代理类型=Sitecore.Tasks.DatabaseAgent>
<参数说明=数据库>主< /参数>
< /剂>
< /调度>
< / Sitecore的>
< /结构>
我已经尝试了以下尝试选择要删除的基于子元素在第二剂元素<参数说明=数据库>主< /参数>
但没有成功。
<结构>
< Sitecore的>
<调度>
<! - 尝试1 - >
<代理类型=Sitecore.Tasks.DatabaseAgent
XDT:转换=删除
XDT:定位器=的XPath(配置/ Sitecore的/计划/代理/参数[文本()='大师'])/>
<! - 尝试2 - >
<代理类型=Sitecore.Tasks.DatabaseAgent
XDT:转换=删除>
<参数说明=数据库
XDT:定位器=的XPath([文本()='大师'])/>
< /剂>
< /调度>
< / Sitecore的>
< /结构>
解决方案
作为回答this 的XDT问题:定位器属性需要使用条件
语法。因此,需要选择是:
<代理类型=Sitecore.Tasks.DatabaseAgent
XDT:转换=删除
XDT:定位器=条件(参数/ @ DESC ='数据库'和参数/文()='大师')/>
![怎么建web.config文件](https://p.xsw88.cn/allimgs/daicuo/20230903/1565.png)
I have the following XML in my web config and I would like to select an attribute for removal using web.config transforms, but I would like to select the element for removal based on the value of one of the child elements.
My web.config is something like this:
<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>
I have tried the following to try to select the second agent element for deletion based on the child element <param desc="database">master</param>
but with no success.
<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>
解决方案
As answered in this question the xdt:Locator attribute needs to use the Condition
syntax. So the required selector is:
<agent type="Sitecore.Tasks.DatabaseAgent"
xdt:Transform="Remove"
xdt:Locator="Condition(param/@desc='database' and param/text()='master')" />
相关推荐
最新文章