mhe*_*384 8 xpath web-config-transform
我有一个看起来像这样的变换
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<a>
<b>
<c>
<d>
<e name="UpdateLanguageProfile">
<f xdt:Transform="Replace" xdt:Locator="Condition(/..@name='UpdateLanguageProfile')">
stuff here
</f>
</e>
</d>
</c>
</b>
</a>
Run Code Online (Sandbox Code Playgroud)
所以我希望xdt:Locator仅在父节点具有指定值的属性时才选择f节点.
xdt:Locator被转换为以下xpath表达式:
/a/b/c/d/e/f[/..@name='UpdateLanguageProfile']
Run Code Online (Sandbox Code Playgroud)
这是无效的.
所以问题是,我可以在条件中放入什么,即XPath方括号,以便根据父节点中的属性选择f节点.
mhe*_*384 17
答案是xdt:Locator和xdt:Transform不需要在同一个节点上.它们碰巧在我见过的每个例子中都在同一个节点上.
你可以这样做:
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<a>
<b>
<c>
<d>
<e name="UpdateLanguageProfile" xdt:Locator="Match(name)">
<f xdt:Transform="Replace">
stuff here
</f>
</e>
</d>
</c>
</b>
</a>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2861 次 |
| 最近记录: |