- I need to replace all ? in file1.xml with element value present in File2.xml.
- And also need to remove extra element node present in File1.xml whose value is not present in File2.xml. (i.e. In my sample input need to remove totalDueWithoutTax element from file1.xml as it is not present in File2.xml.
- There may be the cases where we have multiple elements in File2 but only one corresponsing element in File1. Like in my below example we have two salesInfo element in File2 but in File1 we have only one. In that case as a expected output we need both salesInfo element of File2.
- This is just sample input. In real scenario input xmls can be different means we can get different format of xmls everytime.
Please suggest me how to do that in java. It would be better if we can achieve this using xslt.
**File 1 -- input xml**
<order>
<orderId>?</orderId>
<sales>
<salesInfo>
<salesChannel>?</salesChannel>
<senderSystemId>?</senderSystemId>
<applicationId>?</applicationId>
<totalDueWithoutTax>?</totalDueWithoutTax>
</salesInfo>
<salesid>?</salesid>
</sales>
</order>
**File 2 -- input xml**
<order>
<orderId>4567</orderId>
<sales>
<salesInfo>
<salesChannel>abc</salesChannel>
<senderSystemId>def</senderSystemId>
<applicationId>123</applicationId>
<esignatureCaptureMode>INLINE</esignatureCaptureMode>
</salesInfo>
<salesInfo>
<salesChannel>xyz</salesChannel>
<senderSystemId>uvw</senderSystemId>
<applicationId>234</applicationId>
<esignatureCaptureMode>outline</esignatureCaptureMode>
</salesInfo>
<salesid>789</salesid>
</sales>
</order>
**Expected output:**
<order>
<orderId>4567</orderId>
<sales>
<salesInfo>
<salesChannel>abc</salesChannel>
<senderSystemId>def</senderSystemId>
<applicationId>123</applicationId>
</salesInfo>
<salesInfo>
<salesChannel>xyz</salesChannel>
<senderSystemId>uvw</senderSystemId>
<applicationId>234</applicationId>
</salesInfo>
<salesid>789</salesid>
</sales>
</order>
orderroot element in the first document,rootroot element) in the second, and you know anorderroot element in the first document is matched against thatrootroot element in the second document?