我有一个Xml, 结构如下
<xml>
<object context="3-cumulative" >
<metadata>
<ref cite="4.2" relevance="first.2"/>
</metadata>
<body>
<para>
<text>
applicable on and after December 14,2007.
</text>
</para>
</body>
</object>
<object context="1-cumulative" >
<metadata>
<ref cite="4.2" relevance="first.1"/>
</metadata>
<body>
<para>
<text>
applicable on and after December 14,2006.
</text>
</para>
</body>
</object>
<object context="1-cumulative" >
<metadata>
<related-content-ref cite="5 annuity" relevance="first.1"/>
</metadata>
<body>
<para>
<text>
applicable on and after December 14, 2008
</text>
</para>
</body>
</object>
<mainbody>
<num cite="4.2">4.2</num>
<num cite="2" type="para">2</num>
<heading>Stock exchanges</heading>
<prov-body>
<text>
Notwithstanding the provisions of a convention ... as defined in the
<italic>Income Tax Act</italic>.
</text>
<prov>
<num cite="1 annuity"/>
<num cite="5 annuity"/>
<num cite="3 annuity"/>
<heading>“annuity”</heading>
<text>
<term>“annuity”</term>does not include any pension payment ...
</text>
<text>
any pension payment ...
</text>
</prov>
</prov-body>
</mainbody>
</xml>
我需要,如果在“mainbody” num/@cite and objects/@context/@context is 1-cummmmmm/@cite and@context is 1-cumulation and@context/text is 1-cumulative then para/ text from 对象的文本节点应在第一个文本节点结尾处复制,并且应该按对象/metatadata/ref/@relegations排序,或者如果在“mambody” num/@cite and contite and context/@context is 3-crecum and@context of the spextword in the firstext ext node with its Text elmet/metatadata/ref/@relegentation
产出应当是:
<xml>
<mainbody>
<num cite="4.2">4.2</num>
<num cite="2" type="para">2</num>
<heading>Stock exchanges</heading>
<prov-body>
<text>
Notwithstanding the provisions of a convention ... as defined in the
<italic>Income Tax Act</italic>.
**applicable on and after December 14, 2006**
</text>
<text> **applicable on and after December 14, 2007** </text>
<prov>
<num cite="1 annuity"/>
<num cite="5 annuity"/>
<num cite="3 annuity"/>
<heading>“annuity”</heading>
<text>
<term>“annuity”</term>does not include any pension payment ...
**applicable on and after December 14, 2008**
</text>
<text>
any pension payment ...
</text>
</prov>
</prov-body>
</mainbody>
</xml>