Delta Output Format Overview

Delta Output Format Overview

DeltaV2 is second-generation comparison output format. It represents the differences between two or more XML documents within a single well-formed XML document, using specialised attributes to mark the origin and equality status of every node.

When the format is applied to two documents, these input documents are denoted A and B, and with three documents the inputs are denoted A, B and C.

Namespaces and Prefixes

Three namespaces are used in the DeltaV2 format to represent change. They are summarized in the following table.

usual prefix

namespace URI

Purpose

deltaxml

http://www.deltaxml.com/ns/well-formed-delta-v1

Elements and attributes used to represent change between the inputs.

dxa

http://www.deltaxml.com/ns/non-namespaced-attribute

The namespace of an element, used to represent an attribute, which was not in a namespace in one or both input files.

dxx

http://www.deltaxml.com/ns/xml-namespaced-attribute

The namespace of an element, used to represent an attribute in the XML namespace (corresponding to the URI: http://www.w3.org/XML/1998/namespace and always bound to the prefix xml:).  Such attributes include: xml:space, xml:id, xml:base and xml:lang.

Elements and Attributes

This is a list of the elements used by this format.

Element name

Value

Purpose

deltaxml:attributes

One of more elements, each of which has a local-name and namespace corresponding to an attribute belonging to the parent element.

Details any differences between the attributes associated with the parent element.

deltaxml:attributeValue

CDATA representing the value of an attribute.

To record an attribute value that appeared in one or more of the input documents.

deltaxml:textGroup

One or more deltaxml:text elements.

This element contains the variants of this segment of text.

deltaxml:text

PCDATA, i.e. text.

To record a text item that appeared in one or more of the input documents.

deltaxml:contentGroup

One or more deltaxml:content or deltaxml:text elements.

This element contains the variants of text and inline formatting elements.

deltaxml:content

Elements and PCDATA, i.e. text.

To record text or inline formatting elements.

deltaxml:attributeValueWords

One or more deltaxml:textGroup elements.

Contains the variants of deltaxml:textGroup elements.

deltaxml:attributeTokenSet

One or more deltaxml:token elements.

Contains unique deltaxml:token elements.

deltaxml:attributeTokenList

One or more deltaxml:token elements.

Contains deltaxml:token preserving order of attribute values.

deltaxml:token

PCDATA, i.e. text

To represent a tokenized attribute value.

deltaxml:movedTextGroup

One or more deltaxml:movedText elements.

This element contains the variants of this segment of text after after element moves are identified

deltaxml:movedText

PCDATA, i.e. text

To record a text item that appeared in one or more of the input documents due to element moves

deltaxml:movedAttributes

One of more elements, each of which has a local-name and namespace corresponding to an attribute belonging to the parent element.

Details any differences between the attributes associated with the parent element after element moves are identified.

deltaxml:movedAttributeValue

CDATA representing the value of an attribute

To record an attribute value that appeared in two documents after element moves are identified.

This is a list of the attributes used by DeltaV2.

Attribute name

Value

Purpose

deltaxml:deltaV2

For a delta of two documents, one of the following values: A, B, A=B, A!=B.

For a delta of three documents, one of the following values: A, B, C, A=B, A!=B, B=C, B!=C, A=C, A!=C, A=B=C, A!=B!=C, A=B!=C, A=C!=B, A!=B=C.

Details the documents in which this data item appeared. If it appeared in more than one document, this attribute also indicates whether the data items were the same or different. For example, deltaxml:deltaV2="A=B" means that the element appears in documents A and B and is the same in both.

deltaxml:wordDelta

For a text/word delta of a deltaxml:contentGroup, one of the following values: A, B, A=B, A!=B.

.This attribute defines the text/word equality of a deltaxml:contentGroup.

deltaxml:moveDeltaV2

For a delta of a move elements, one of the following values: A, B, A=B, A!=B.

Define equality of moved elements.

On the root element, the following attributes must appear.

Attribute name

Value

Purpose

deltaxml:version

This must be 2.0.

This indicates the version of the delta format.

deltaxml:content-type

This must have one of the values: full-context, changes-only or merge-concurrent.

This indicates if the delta document contains just the changes (changes-only) or if the data that is unchanged in all the documents is also present (full-context).

deltaxml:original-position

Shows the comma-separated element position for the A and B documents: E.g. 'A=2, B=1'

Optional output for child elements of an 'Orderless Container' element.  Shows the position of each child element for the same element as found in the A document and in the B document.

On each deltaxml:attributes element, the following attribute/value must be present.

Attribute name

Value

Purpose

deltaxml:ordered

Must be false.

Indicates that the child elements, used to represent attributes, can appear in any order.

Version 2.1-specific Attributes

In Version 2.1, new attributes are added to support the representation of changes in element structure with respect to content. In certain document comparison scenarios, (e.g. when processing formatting elements), this can improve granularity. A fuller description and samples can be found in the Overlapping Hierarchies in DeltaV2 document.

The following table summarises the function and contents of each of these new attributes.

Attribute name

Content

Purpose

deltaxml:deltaTag

An alphabetically sorted list of one or more comma-separated document identifiers, e.g. A, B, A,B.

Indicates that the element tag was present in the document(s) identified, and all of its content is as included in this element in the delta file.

deltaxml:deltaTagStart

As above

Indicates that the element tag was present in the document(s) identified, but in that document the element contained not only the content here but more content. The additional content follows in zero or more elements marked deltaxml:deltaTagMiddle and ending with an element marked deltaxml:deltaTagEnd.

deltaxml:deltaTagMiddle

As above

Indicates that the content of this element was included in an element marked deltaxml:deltaTagStart which precedes this element. There is additional content, which follows in an element marked deltaxml:deltaTagMiddle or deltaxml:deltaTagEnd.

deltaxml:deltaTagEnd

As above

Indicates that the content of this element was included in an element marked deltaxml:deltaTagStart which precedes this element and this element contains the last part of the content for this element.

Description

There is no DTD or Schema for a Delta, but the Delta will have the same look and feel as the original documents. There is a set of rules which apply to the Delta format. In general terms, the Delta generated from a set of documents will be a union of these documents. All the data that appears in any of the documents will also appear in the Delta.

Elements, attributes and text that are identified by DeltaXML as common to two or more of the documents are shared in the Delta. A subtree that appears unchanged in one or more documents will appear in the Delta almost exactly as it appeared in the original document(s).

Schematron Rules

The definitive version of these rules is contained in a Schematron rule document: deltaV2-schematron.xml. - Note: this document does not yet support the new Version 2.1 attributes.

The same rules file is normally used for both the 2-input and 3-input deltas.  Only one of the rules, the one which specifies the DeltaV2 allowable characters, needs to be changed should a schema be required to differentiate between the 2-way and 3-way deltas.  Should a specific 2-way delta be required, the rule is:

XML
<report test="matches(@deltaxml:deltaV2, '[^AB!=]')">Delta value contains invalid characters</report>

If an application needs to be coded to handle both 2-way and 3-way delta results and be required to differentiate between them, it can do so by looking at the characters contained in the deltaxml:deltaV2 attribute on the root node of a delta file. The root node will always have a delta attribute and it will always reflect the number of inputs. 

Full Context Delta

In an analogous manner to the original Delta format, a Delta can either show just the changes or can include all the data from the original documents. When only the changes are shown, the content of any unchanged element is not reproduced in the delta. This will be for any element with a deltaxml:deltaV2 attribute equal to A=B or, for three documents, A=B=C.

Compatibility with Original Delta Format

The original delta format handled two documents only. The values of the deltaxml:deltaV2 attribute correspond with the deltaxml:delta attribute as follows: add becomes B, delete becomes A, unchanged becomes A=B and WFmodify becomes A!=B. The value WFmodifyUnordered is also A!=B but the deltaxml:ordered="false" attribute remains on the element so that knowledge of the unordered content remains in the delta document.

Attribute changes are now handled within markup to make processing easier. There is no longer a representation of an exchange between two elements or an element and text item.

Examples for Two Documents

Examples of Elements in Delta

Document A

Document B

<example>
  <person>
    <firstName/>

    <tel/>
  </person>
</example>

<example>
  <person>
    <firstName/>
    <lastName/>

  </person>
</example>

And the Delta for this will be as follows:

Delta

Comments

<example deltaxml:deltaV2="A!=B">
 <person deltaxml:deltaV2="A!=B">
  <firstName deltaxml:deltaV2="A=B"/>
  <lastName deltaxml:deltaV2="B" />
  <tel deltaxml:deltaV2="A" />
 </person>
</example>

Element <firstName> appears in both documents, A and B, and is the same in both.

Element <lastName> appears in document B only.

Element <T> appears in document A only.

Examples of Text in Delta 

Document A

Document B

<example>
  <person>
    <firstName>J</firstName>
    <lastName>Smith</lastName>
  </person>
</example>

<example>
  <person>
    <firstName>John</firstName>
    <lastName>Smith</lastName>
  </person>
</example>

And the Delta for this will be as follows:

Delta

Comments

<example deltaxml:deltaV2="A!=B">
 <person deltaxml:deltaV2="A!=B">
  <firstName deltaxml:deltaV2="A!=B">
    <deltaxml:textGroup deltaxml:deltaV2="A!=B">
      <deltaxml:text deltaxml:deltaV2="A">J</deltaxml:text>
      <deltaxml:text deltaxml:deltaV2="B">John</deltaxml:text>
    </deltaxml:textGroup>
   </firstName>
   <lastName deltaxml:deltaV2="A=B">Smith</lastName>
 </person>
</example>

The text in <firstName> is J in A and  John in document B.

The text in <lastName> is the same in both documents.

Examples of Attributes in Delta 

Document A

Document B

<example>
  <person gender="M" age="36">
    <firstName>J</firstName>
  </person>
</example>

<example>
  <person gender="M" age="37">
    <firstName>J</firstName>
  </person>
</example>

And the Delta for this will be as follows:

Delta

Comments

<example deltaxml:deltaV2="A!=B">
 <person deltaxml:deltaV2="A!=B" gender="M">
  <deltaxml:attributes deltaxml:deltaV2="A!=B">
   <dxa:age deltaxml:deltaV2="A!=B">
    <deltaxml:attributeValue deltaxml:deltaV2="A">36</deltaxml:attributeValue>
    <deltaxml:attributeValue deltaxml:deltaV2="B">37</deltaxml:attributeValue>
   </dxa:age>
  </deltaxml:attributes>
  <firstName deltaxml:deltaV2="A=B">J</firstName>
 </person>
</example>

The attribute gender is unchanged and so appears as a regular attribute.

The attribute age has a value of 36 in document A and 37 in B.

Element <firstName> appears now as the second child of <person>.

Examples for Three Documents

Examples of Elements in Delta

Document A

Document B

Document C

<example>
  <person>
    <firstName/>
    <lastName/>
    <tel/>
  </person>
</example>

<example>
  <person>
    <firstName/>
    <lastName/>

  </person>
</example>

<example>
  <person>
    <firstName/>

  </person>
</example>

And the Delta for this will be as follows:

Delta

Comments

<example deltaxml:deltaV2="A!=B!=C">
 <person deltaxml:deltaV2="A!=B!=C">
  <firstName deltaxml:deltaV2="A=B=C"/>
  <lastName deltaxml:deltaV2="A=B" />
  <tel deltaxml:delta="A" />
 </person>
</example>

Element <lastName> appears in two documents, A and B, and is the same in both.

Element <tel> appears in only one document, A.

Examples of Text in Delta

Document A

Document B

Document C

<example>
  <person>
    <firstName>J</firstName>
    <lastName>Smith</lastName>
  </person>
</example>

<example>
  <person>
    <firstName>John</firstName>
    <lastName>Smith</lastName>
  </person>
</example>

<example>
  <person>
    <firstName>J</firstName>
    <lastName>Smith</lastName>
  </person>
</example> 

And the Delta for this will be as follows:

Delta

Comments

<example deltaxml:deltaV2="A!=B!=C">
 <person deltaxml:deltaV2="A!=B!=C">
  <firstName deltaxml:deltaV2="A=C!=B">
    <deltaxml:textGroup deltaxml:deltaV2="A=C!=B">
      <deltaxml:text deltaxml:deltaV2="A=C">J</deltaxml:text>
      <deltaxml:text deltaxml:deltaV2="B">John</deltaxml:text>
    </textGroup>
   </firstName>
   <lastName deltaxml:deltaV2="A=B=C">Smith</lastName>
 </person>
</example>

The text in <firstName> is J in both A and C.

The text in <firstName> is John in document B.

The text in <lastName> is the same in all documents.

Examples of Attributes in Delta

Document A

Document B

Document C

<example>
  <person gender="M" age="36">
    <firstName>J</firstName>
  </person>
</example>

<example>
  <person gender="M" age="37">
    <firstName>J</firstName>
  </person>
</example>

<example>
  <person gender="M">
    <firstName>J</firstName>
  </person>
</example>

And the Delta for this will be as follows:

Delta

Comments

<example deltaxml:deltaV2="A!=B!=C">
 <person deltaxml:deltaV2="A!=B!=C" gender="M">
  <deltaxml:attributes deltaxml:deltaV2="A!=B!=C">
   <dxa:age deltaxml:deltaV2="A!=B">
    <deltaxml:attributeValue deltaxml:deltaV2="A">36</deltaxml:attributeValue>
    <deltaxml:attributeValue deltaxml:deltaV2="B">37</deltaxml:attributeValue>
   </dxa:age>
  </deltaxml:attributes>
  <firstName deltaxml:deltaV2="A=B=C">J</firstName>
 </person>
</example>

The attribute gender is unchanged and so appears as a regular attribute.

The attribute age has a value of 36 in document A and 37 in B.

Element <firstName> appears now as the second child of <person>.

DeltaV2 Version 2.1 Samples

A set of samples specific to Version 2.1 is provided in the document Overlapping Hierarchies in DeltaV2 .

The included samples illustrate how the new attributes introduced to DeltaV2 can be used in practice by supporting DeltaXML products.

Examples of Format Change Using deltaxml:contentGroup

Document A

Document B

Document C

<example>
  <p>This text has no formatting</p>
</example>

<example>
  <p>This <b>text has some</b> formatting</p>
</example>

<example>
  <p>This <i>text has some</i> formatting</p>
</example>

And the Delta for this will be as follows:

Delta

Comments

<example deltaxml:deltaV2="A!=B!=C">
  <p deltaxml:deltaV2="A!=B!=C">This
    <deltaxml:contentGroup deltaxml:deltaV2="A!=B!=C" deltaxml:wordDelta="A!=B=C">
      <deltaxml:text deltaxml:deltaV2="A">text has no</deltaxml:text>
      <deltaxml:text deltaxml:deltaV2="B=C">text has some</deltaxml:text>
      <deltaxml:content deltaxml:deltaV2="A">text has no</deltaxml:content>
      <deltaxml:content deltaxml:deltaV2="B"><b>text has some</b></deltaxml:content>
      <deltaxml:content deltaxml:deltaV2="C"><i>text has some</i></deltaxml:content>
    </deltaxml:contentGroup>
    formatting.
  </p>
</example>


See also: Overlapping Hierarchies in DeltaV2