Function natural_xml_diff::diff
source · Expand description
Given XML document A and XML document B produce a diff document.
This document describes how to get from A to B.
The diff document adds a new namespace prefix diff for the http://paligo.net/nxd
namespace URI.
Elements
New elements that are inserted are marked by the diff:insert attribute with
an empty value:
<section><p diff:insert="">This is a new paragraph.</p></section>
Elements that are deleted are marked by the diff:delete attribute with
an empty value:
<section><p diff:delete="">This is a paragraph that is deleted.</p></section>
Text
Text updates are marked with diff:text-insert and diff:text-delete elements:
<section><p>This is a paragraph with <diff:text-insert>new text</diff:text-insert> and <diff:text-delete>deleted text</diff:text-delete>.</p></section>
Attributes
Attributes changes are represented by a new diff:attributes elements inserted as the first child of the
element in which the attributes changed. Each attribute update
is represented by a child element that is marked with the diff:attr-update, diff:attr-insert or diff:attr-delete
attributes (with empty values):
Update attribute a to the new value A!:
<section a="A" b="B"><diff:attributes><a diff:attr-update>A!</a></diff:attributes><p>Txt</p></section>
Insert a new attribute c with value C:
<section a="A" b="B"><diff:attributes><c diff:attr-insert="">C</c></diff:attributes><p>Txt</p></section>
Delete attribute b:
<section a="A" b="B"><diff:attributes><b diff:attr-delete=""/></diff:attributes><p>Txt</p></section>