我的要求是删除与 Relation 的where或or only@guid之一匹配的 Relation 标签。上述逻辑也适用于应该与 Relation 的where或or only 之一匹配的情况。@relationObj<roleCode tc=32><roleCode tc=31><roleCode tc=8>@relationObj@relationObj<roleCode tc=32><roleCode tc=31><roleCode tc=8>
基本上我想搜索@guid并@relationObj查找@relationObj属于<roleCode tc=32>or <roleCode tc=31>or的其他关系标签<roleCode tc=8>。如果此条件为真,请删除此部分。
下面是 XML:
<Relations>
<Relation guid="abcd1234" relationObj="1234">
<roleCode tc="20"/>
</Relation>
<Relation guid="xyz123" relationObj="1111">
<roleCode tc="32"/>
</Relation>
<Relation guid="def123" relationObj="2222">
<roleCode tc="31"/>
</Relation>
<Relation guid="1111" relationObj="2222">
<roleCode tc="98"/>
</Relation>
<Relation guid="jkl123" relationObj="3333">
<roleCode tc="8"/>
</Relation>
<Relation guid="2222" relationObj="1234">
<roleCode tc="100"/>
</Relation>
</Relations>
我尝试创建三个变量以在模板中@relationObj为每个变量提取。<roleCode tc>[32,31 and 8]然后@objectId与@relationObj这三个变量进行比较。<Relation>但这里的问题是,当迭代时遇到另一个标签时,变量会更新为空值。
从上面的 xml 我应该在转换后得到下面的 xml。
<Relations>
<Relation guid="abcd1234" relationObj="1234">
<roleCode tc="20"/>
</Relation>
<Relation guid="xyz123" relationObj="1111">
<roleCode tc="32"/>
</Relation>
<Relation guid="def123" relationObj="2222">
<roleCode tc="31"/>
</Relation>
<Relation guid="jkl123" relationObj="3333">
<roleCode tc="8"/>
</Relation>
<Relation guid="2222" relationObj="1234">
<roleCode tc="100"/>
</Relation>
</Relations>
如果您观察到,<Relation>带有 [guid="1111" relationObj="2222"] 的标签将被删除。因为@guid 和@relationObj 都属于roleCodes 之一 - 32,31 或 8。
您能否让我知道在不更新新变量的情况下将值保存在变量中的最佳方法是什么?或者有什么更好的方法可以实现这一点。谢谢你的时间。