I have two xml files, say file1.xml which is as follows:
<?xml version="1.0"?>
<root >
<text id='a'>This is to be replaced</text>
<note>This should not be touched</note>
<text id='b'>This is intact</text>
</root>
file2.xml is as follows
<?xml version="1.0"?>
<root >
<text id='a'>Replacement Text</text>
<note>This is a personal note</note>
</root>
I expect an output xml file of the form :
output.xml
<?xml version="1.0"?>
<root>
<text id='a'>Replacement Text</text>
<note>This should not be touched</note>
<text id='b'>This is intact</text>
</root>
Please help me with a xsl to get the desired output. This is not a homework and I am trying to understand xslt.
This transformation:
when applied on this XML document (the provided file1.xml):
and having the provided file2.xml residing in
c:\temp\delete\file2.xml:produces the wanted, correct result:
Explanation:
Use and overriding of the identity rule.
Use of the standard XSLT function
document().