I'm trying to follow the solution provided in this post to merge two XMLs, my issue is that with the namespace I'm not able to make it work, if I remove the namespace then it works fine. To handle the namespace, I've followed the solution provided in this post but still no luck.
input1.xml
<?xml version="1.0" encoding="utf-8"?>
<Template xsi:schemaLocation="Invoice_Summary_Template" Name="Invoice_Summary_Template" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="Invoice_Summary_Template">
<Batches>
<Collection>
<Item>
<Batch>
<Report Name="Invoice_Summary">
<Invoices>
<Invoice_Collection>
<Invoice Id="1">
<content>
<misc>aaa</misc>
<misc>bbb</misc>
</content>
</Invoice>
</Invoice_Collection>
</Invoices>
</Report>
</Batch>
</Item>
</Collection>
</Batches>
</Template>
input2.xml
<?xml version="1.0" encoding="utf-8"?>
<Template xsi:schemaLocation="Invoice_Summary_Template" Name="Invoice_Summary_Template" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="Invoice_Summary_Template">
<Batches>
<Collection>
<Item>
<Batch>
<Report Name="Invoice_Summary">
<Invoices>
<Invoice_Collection>
<Invoice Id="2">
<content>
<misc>ccc</misc>
</content>
</Invoice>
</Invoice_Collection>
</Invoices>
</Report>
</Batch>
</Item>
</Collection>
</Batches>
</Template>
collection.xml
<?xml version="1.0" encoding="UTF-8"?>
<collection>
<doc href="C:/test/input1.xml"/>
<doc href="C:/test/input2.xml"/>
</collection>
Output:
<?xml version="1.0" encoding="utf-8"?>
<Template xsi:schemaLocation="Invoice_Summary_Template" Name="Invoice_Summary_Template" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="Invoice_Summary_Template">
<Batches>
<Collection>
<Item>
<Batch>
<Report Name="Invoice_Summary">
<Invoices>
<Invoice_Collection>
<Invoice Id="1">
<content>
<misc>aaa</misc>
<misc>bbb</misc>
</content>
</Invoice>
</Invoice_Collection>
</Invoices>
</Report>
</Batch>
</Item>
<Item>
<Batch>
<Report Name="Invoice_Summary">
<Invoices>
<Invoice_Collection>
<Invoice Id="2">
<content>
<misc>ccc</misc>
</content>
</Invoice>
</Invoice_Collection>
</Invoices>
</Report>
</Batch>
</Item>
</Collection>
</Batches>
</Template>
XSLT 2.0
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xpath-default-namespace="Invoice_Summary_Template"
exclude-result-prefixes="#all">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="collection">
<Template xsi:schemaLocation="Invoice_Summary_Template" Name="Invoice_Summary_Template" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="Invoice_Summary_Template">
<Batches>
<Collection>
<xsl:copy-of select="document(doc/@href)/*/Batches/Collection/Item"/>
</Collection>
</Batches>
</Template>
</xsl:template>
</xsl:stylesheet>
What changes do I need to make to accomplish this?