-1

我需要合并两个节点MANHATTAN:

因为我们的系统规则如下:

CREATE A + MODIFY A” 仍然是“ CREATE A with the combined 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 做这件事需要几个小时。

4

1 回答 1

0

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.

于 2012-07-11T09:42:05.793 回答