Should an XML Payload be represented as XML or text?

If our payload is XML, and our carrier is XML, does it make sense to embed the payload as XML rather than text? At first sight this seems to be an attractive proposition, and an example is shown below. For clarity we have put the diff3x elements into their own namespace, using a d: prefix.

Table 8. XML data example

A.xmlO.xmlB.xml
<author>
<personname>
 <first>Nigel</first>
 <last>Whitaker</last>
</personname>
<address>
 <st>Geraldine Rd</st>
 <city>Malvern</city>
 <country>UK</country>
    
</address>
</author>
<author>
<personname>
 <first>Nigel</first>
 <last>Whitaker</last>
</personname>
<address>
 <st>Geraldine Rd</st>
 <city>Malvern</city>
 <country>UK</country>
 <post>WR14 3SZ</post> 
</address>
</author>
<author>
<personname>
 <first>Nigel</first>
 <last>Whitaker</last>
</personname>
<address>
 <st>Geraldine Rd</st>
 <city>Malvern</city>
 <country>UK</country>
 <post>PQ9 5XY</post> 
</address>
</author>

This could be embedded in the XML diff3x carrier as shown below.

<d:diff3x a="A.xml" b="B.xml" o="O.xml">
<author>
<personname>
  <first>Nigel</first>
  <last>Whitaker</last>
</personname>
<address>
 <st>Geraldine Rd</st>
 <city>Malvern</city>
 <country>UK</country>
 <d:choice3>
  <d:a/>
  <d:o>
   <post>WR14 3SZ</post>
  </d:o>
  <d:b>
   <post>PQ9 5XY</post>
  </d:b>
 </d:choice3>
</address>
</author>
</d:diff3x>

This looks good and useful, but it has limitations. The main one is that it would not be possible to show changes to attributes in situ, even if we resorted to XML processing instructions. Other approaches to this include representing attribute change by introducing an XML element immediately following the end of the start tag.

Also, it would not be possible to show changes to element tags, e.g. if a <bold> was changed to <italic>.

These limitations could be overcome by making the diff3x more complex but there is no good reason to do this because it takes away the primary purpose of the diff3x carrier, which is to represent changes to a text file. As an XML payload can be considered to be a text file we should treat it as such to be consistent with the handling of JSON or any other payload.