I want to know if it's possible to take the values for the same resources (same attribute value) from another file, maintaining in the first file all the structure and comments.
Maybe I'll explain it better with an example.
Input file 1 (the one that needs the values):
<?xml version="1.0" encoding="UTF-8"?>
<root>
<element name="1">File1-value1</frag>
<element name="2">File1-value2</frag>
<element name="3">File1-value3</frag>
</root>
Input file 2 (the one to take the values from):
<?xml version="1.0" encoding="UTF-8"?>
<root>
<element name="3">File2-value3</frag>
<element name="7">File2-value3</frag>
<element name="1">File2-value1</frag>
<element name="2">File2-value2</frag>
</root>
Desired output:
<?xml version="1.0" encoding="UTF-8"?>
<root>
<element name="1">File2-value1</frag>
<element name="2">File2-value2</frag>
<element name="3">File2-value3</frag>
</root>
The point is to have all the contents of file 2 in file 1 for matching attributes (there will be extra elements with attribute values not present in file 1 that I don't want) but preserving order, tab structure, spaces and comments of file 1.
It may seem a very dumb process but there are a lot of big files. I have been reading a lot about XSLT but I could not found any solution as I'm completely novice with it.
Thank you very much for any possible answers.