From version 13.1
edited by Marius Dumitru Florea
on 2019/12/11 15:55
To version 14.1
edited by Marius Dumitru Florea
on 2019/12/11 16:23
Change comment: There is no comment for this version

Summary

Details

ExtensionCode.ExtensionClass[0]
Description
... ... @@ -138,9 +138,9 @@
138 138  public interface XMLDiff
139 139  {
140 140   /**
141 - * Computes the difference between two XML nodes and their descendants. When a text node, attribute, comment or any
142 - * value node type in general is modified we compute the difference at character level. Otherwise the difference is
143 - * expressed at node level, as if two lists of nodes are compared.Levenshtein distance
141 + * Computes the difference between two XML nodes and their descendants. When a value node type (e.g. text,
142 + * attribute, comment) is modified we compute the difference on the text value using the splitter indicated by the
143 + * configuration. Otherwise the difference is expressed at node level, as if two lists of nodes are compared.
144 144   * <p>
145 145   * The result is a mapping between nodes from the left side and the patches that need to be applied to these nodes
146 146   * in order for the left tree to become the right tree. If the root nodes of the left and right trees don't match
... ... @@ -162,7 +162,8 @@
162 162  if leftNode and rightNode are "similar"
163 163   if leftNode has value (true for text, comment or attribute nodes)
164 164   if leftNode's value is different than rightNode's value
165 - compute the changes at character level (lists of characters)
165 + compute the changes using the splitter indicated in the configuration
166 + (character splitter is used for text nodes by default, but there is also a word splitter available)
166 166   else
167 167   if leftNode has attributes (true for elements)
168 168   compute the difference between attributes (added, removed, modified)
... ... @@ -179,6 +179,8 @@
179 179  very similar = similar and the percent of text changes (Levenshtein distance / max length) is less than 60%
180 180  {{/code}}
181 181  
183 +The similarity threshold (0.6 by default) can be changed from the configuration.
184 +
182 182  == Displaying the Changes ==
183 183  
184 184  To compute and display the changes you can use the ##XMLDiffManager## component.
... ... @@ -199,6 +199,8 @@
199 199  }
200 200  {{/code}}
201 201  
205 +You can control from the configuration which ##XMLDiffFilter##s are applied on the XML documents before and after computing the changes. You can also implement your own filters, e.g. to remove irrelevant changes, or to ignore parts of the XML documents while computing the changes. The default configuration applies a filter to mark context (unmodified) nodes after the changes are computed.
206 +
202 202  === HTML Visual Diff ===
203 203  
204 204  The ##XMLDiffManager## has an implementation dedicated to computing a visual diff on HTML. Best is to use the provided script service:
... ... @@ -215,3 +215,12 @@
215 215   #end
216 216  </div>
217 217  {{/code}}
223 +
224 +You can configure the diff by passing a third argument:
225 +
226 +{{code language="none"}}
227 +#set ($config = $services.diff.html.defaultConfiguration)
228 +#set ($htmlDiff = $services.diff.html.unified($previousHTML, $nextHTML, $config))
229 +{{/code}}
230 +
231 +The default configuration applies a filter that embeds images into the HTML before computing the changes, in order to compare the image data and not the image location.

Get Connected