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 |
|---|---|---|
|
|
|
Elements and attributes used to represent change between the inputs. |
|
|
|
The namespace of an element, used to represent an attribute, which was not in a namespace in one or both input files. |
|
|
|
The namespace of an element, used to represent an attribute in the XML namespace (corresponding to the URI: |
Elements and Attributes
This is a list of the elements used by this format.
|
Element name |
Value |
Purpose |
|---|---|---|
|
|
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. |
|
|
CDATA representing the value of an attribute. |
To record an attribute value that appeared in one or more of the input documents. |
|
|
One or more |
This element contains the variants of this segment of text. |
|
|
PCDATA, i.e. text. |
To record a text item that appeared in one or more of the input documents. |
|
|
One or more |
This element contains the variants of text and inline formatting elements. |
|
|
Elements and PCDATA, i.e. text. |
To record text or inline formatting elements. |
|
|
One or more |
Contains the variants of |
|
|
One or more |
Contains unique |
|
|
One or more deltaxml:token elements. |
Contains |
|
|
PCDATA, i.e. text |
To represent a tokenized attribute value. |
|
|
One or more deltaxml:movedText elements. |
This element contains the variants of this segment of text after after element moves are identified |
|
|
PCDATA, i.e. text |
To record a text item that appeared in one or more of the input documents due to element moves |
|
|
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. |
|
|
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 |
|---|---|---|
|
|
For a delta of two documents, one of the following values: For a delta of three documents, one of the following values: |
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, |
|
|
For a text/word delta of a |
.This attribute defines the text/word equality of a |
|
|
For a delta of a move elements, one of the following values: |
Define equality of moved elements. |
On the root element, the following attributes must appear.
|
Attribute name |
Value |
Purpose |
|---|---|---|
|
|
This must be |
This indicates the version of the delta format. |
|
|
This must have one of the values: |
This indicates if the delta document contains just the changes ( |
|
|
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 |
|---|---|---|
|
|
Must be |
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 |
|---|---|---|
|
|
An alphabetically sorted list of one or more comma-separated document identifiers, e.g. |
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. |
|
|
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 |
|
|
As above |
Indicates that the content of this element was included in an element marked |
|
|
As above |
Indicates that the content of this element was included in an element marked |
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:
<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 |
|---|---|
|
|
|
And the Delta for this will be as follows:
|
Delta |
Comments |
|---|---|
|
|
Element Element Element |
Examples of Text in Delta
|
Document A |
Document B |
|---|---|
|
|
|
And the Delta for this will be as follows:
|
Delta |
Comments |
|---|---|
|
|
The text in The text in |
Examples of Attributes in Delta
|
Document A |
Document B |
|---|---|
|
|
|
And the Delta for this will be as follows:
|
Delta |
Comments |
|---|---|
|
|
The attribute The attribute Element |
Examples for Three Documents
Examples of Elements in Delta
|
Document A |
Document B |
Document C |
|---|---|---|
|
|
|
|
And the Delta for this will be as follows:
|
Delta |
Comments |
|---|---|
|
|
Element Element |
Examples of Text in Delta
|
Document A |
Document B |
Document C |
|---|---|---|
|
|
|
|
And the Delta for this will be as follows:
|
Delta |
Comments |
|---|---|
|
<example deltaxml:deltaV2="A!=B!=C">
|
The text in The text in The text in |
Examples of Attributes in Delta
|
Document A |
Document B |
Document C |
|---|---|---|
|
|
|
|
And the Delta for this will be as follows:
|
Delta |
Comments |
|---|---|
|
|
The attribute The attribute Element |
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 |
|---|---|---|
|
|
|
|
And the Delta for this will be as follows:
|
Delta |
Comments |
|---|---|
|
|
|
See also: Overlapping Hierarchies in DeltaV2