如何合并具有“同一个父亲"的两个节点并且有一个精确的“方法";序列(使用 XSLT)? [英] how to merge two nodes having "the same father" and having a precise "method" sequence (using XSLT)?
问题描述
我需要合并两个节点MANHATTAN:
I need to merge the two nodes MANHATTAN:
因为我们的系统规则如下:
because our system rule is the following:
"CREATE A + MODIFY A" 仍然是 "CREATE A 与合并的属性"
"CREATE A + MODIFY A" is still a "CREATE A with the merged attributes"
输入文件:
<?xml version="1.0" encoding="UTF-8"?>
<world>
<COUNTRY id="USA" >
<STATE id="NEW JERSEY">
<CITY id="NEW YORK" method="modify">
<DISTRICT id="MANHATTAN" method="create">
<attributes>
<population>99 </population>
<income> 10000</income>
</attributes>
</DISTRICT>
<DISTRICT id="MANHATTAN" method="modify">
<attributes>
<temperature>78</temperature>
<income>15000</income>
<information>suburb of newyork</information>
</attributes>
</DISTRICT>
</CITY>
</STATE>
预期输出:
<?xml version="1.0" encoding="UTF-8"?>
<world>
<COUNTRY id="USA" >
<STATE id="NEW JERSEY">
<CITY id="NEW YORK" method="modify">
<DISTRICT id="MANHATTAN" method="create">
<attributes>
<population>99 </population>
<temperature>78</temperature>
<income>15000</income>
<information>suburb of newyork</information>
</attributes>
</DISTRICT>
</CITY>
</STATE>
</COUNTRY>
</world>
请帮忙,我刚刚开始使用 XSLT,在 Perl 或 Python 中完成需要几个小时.
Please help, I have just began XSLT and doing it in Perl or Python will takes hours.
推荐答案
Adapt solution from similar problem at 如何合并具有相同父亲"、相同方法和相同 id=0 的两个节点(使用 XSLT)?
Adapt solution from similar problem at how to merge two nodes having "the same father", the same method and the same id=0 (using XSLT)?
阅读解决方案以了解分组的工作原理,然后相应地改变分组键.
Read the solution to see how grouping works, and then vary the grouping keys accordingly.
这篇关于如何合并具有“同一个父亲"的两个节点并且有一个精确的“方法";序列(使用 XSLT)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!