私は2つのxmlファイルを持っています。要素の最後の出現の下にある xml ファイル データを別のファイルにコピーしたいと考えています。以下は私が持っているxmlです:
---------- xml-1---------------
<?xml version="1.0"?>
<parent>
....
<form id="1" name="world"/>
<source id="1" name="abc1"/>
<source id="2" name="abc2"/>
<source id="3" name="abc3"/>
<file id="1" name="xyz"/>
....
</parent>
----------- xml-2--------------
<?xml version="1.0"?>
<root>
<source id="4" data="anything"/>
<source id="5" data="anything"/>
<source id="6" data="anything"/>
<source id="7" data="anything"/>
</root>
------------------The desired output I want-----------------
<?xml version="1.0"?>
<parent>
....
<source id="1" name="abc1"/>
<source id="2" name="abc2"/>
<source id="3" name="abc3"/>
<source id="4" data="anything"/>
<source id="5" data="anything"/>
<source id="6" data="anything"/>
<source id="7" data="anything"/>
<file id="1" name="xyz"
....
</parent>
============== xslt I am using =============
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="node()|@*" name="identity">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="source">
<xsl:choose>
<xsl:when test="'id=3'">
<xsl:call-template name="identity"/>
<xsl:copy-of select="document('file:///D:/Softwares/JEE eclipse/JEEworkspace/Migration/TestMigrationWithoutDeletingProject/xml2.xml')/*/*"/>
</xsl:when>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
id 属性に基づいて見つけようとしていますが、xml-1 データのすべてのソース要素の後に xml-2 データをコピーしています。これについて私を助けてください。