Comparing text versions

Build 1501 on 14/Nov/2017  This topic last edited on: 13/Jul/2016, at 12:31

Since GN4 version 2.4 you can compare the text versions of an article.

Enabling new functionality

The configuration to show the differences is stored in a new file:

..\Config\Global\GN4_Tark4_Common\feed_XamlDisplayDifference.xml

(add in ..\Config\Editorial_InstallConfig.xml)

(to import the file: srv4 config -in .\Config\Global\GN4_Tark4_Common\feed_XamlDisplayDifference.xml)

How to display the text versions compare dialog box?

Click the new icon, available since 2.4 on the Audit/Version palette (when an article text is selected).

The new icon is:

ico_compareversions

The following screenshot shows where the icon appears on the versions/audit palette.

Click to toggle graphic size

The icon is enabled only when you select an article element that has the version (asterisk in the Ver column). If the icon is not enabled when you select a row with an asterisk, make sure that it is not an article version: the compare works only for text versions.

Moreover, you can display the differences by running a script ShowDifferences() (Article.vb, available only when there is a current text editing)

Description of the text versions compare dialog box

 

2016125122723_Diff2

1The two vertical arrows allow you to browse through the difference parts. If they appear disabled, that's becaouse there are no differences.

To work correctly, the configuration need a right tags placement (see the "configuration" part)

2 The two combos allow you to select what to compare:

- when called by the ShowDifferences script, the dialog shows by default the current version and the previous version.

- when called from the version/audit panel, the dialog shows the difference of the current version and the selected version.

You can select another version to compare at any time, and the difference preview will be updated.

(3) The Revert button, to revert the current version to the selected version (in the right combo). If you click it, the software copis the the selected previous version to the version selected in the left combo, and closes the dialog box.

Understanding the differences

Read the differences is simple: the left combo is the reference version (a) compared to the other one (b) (right combo)

If (a) has the text that does not appear in (b), the text is painted in green;

If some text of (a) was deleted in (b), the text is struck in red;

Comparison summary

With default configuration there is a summary part before the text.

2016125122742_Diff3

 

Difference by url:

The difference dialog use a new REST call,

.../do.ashx?Cmd=Diff&Name=XamlDisplayDifference&Id=7304v2016-01-22T13%3a43%3a53.803Z&Id2=7304

Diff calls has 3 parameters

Name: (optional) the configuration name that contain the stylesheet to apply to the Difference result.

Id2: (required) idversion value: the object to compare (left combo, witching the dialog) (into the example is specified an id without the version date: the user want use the current version)

Id: (required) idversion value: the compared object (right combo, witching the dialog)

the diff command can be applied to two different text object.

 

The default configuration (XamlDisplayDifference, used by client dialog) return a Xaml codification to show into difference dialog, is planned a version for web.

If there is specified no configuration file the raw difference data is structured with this sintax:

<gn4:diff xmlns:gn4="urn:schemas-teradp-com:gn4tera" xmlns:t="http://www.teradp.com/schemas/GN3/t.xsd" nAdd="0" nRemove="1" nReplace="1">
  <t:p>
    <change kind="equal">aa</change>
    <change kind="remove"> </change>
    <change kind="add">aaa</change>
    <change kind="equal">aa</change>
  </t:p>
  <t:p>
    <change kind="equal">bbbbbbbb</change>
  </t:p>
  <t:p>
    <change kind="equal">ccccccccc</change>
  </t:p>
  <t:p>
    <change kind="equal"></change>
    <change kind="remove">dddddddd</change>
  </t:p>
  <t:p>
    <change kind="remove">eeeee</change>
  </t:p>
  <t:p>
    <change kind="remove"></change>
    <change kind="equal"></change>
  </t:p>
</gn4:diff>

Configuration:

watching the RAW difference XML is easy apply a stylesheet to show customized text difference.

There is a rule to follow using the client Difference Dialog: the arrows that point out the difference parts to recongnize the differences search an empty hyperlink tag before every difference.

Into the configuration add this empty hyperlink (sample from default configuration).

  <xsl:for-each select="*">
    <xsl:choose>
      <xsl:when test="@kind and @kind='add'">
        <a href=""/>
        <font color="green">
          <xsl:value-of select="."/>
        </font>
      </xsl:when>
      <xsl:when test="./@kind and ./@kind='remove'">
        <a href=""/>
        <strike>
          <font color="red">
            <xsl:value-of select="."/>
          </font>
        </strike>               
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="."/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:for-each>