Menu

#30 XML ID dereferencing difference engine

open
nobody
None
5
2014-12-14
2010-01-07
No

We have several cases where the XML ID / IDREF is used to save space for re-used elements. In such cases, the XML IDs are generated local to the XML document and do not have to be equal across documents even though their content is equivalent. For such cases, I subclasses the difference engine to not compare values of attributes with type IDREF directly, but compare the referenced elements instead.

However, to determine the schema type of an attribute, it is necessary to obtain the Document via a validating parser. Thus, my implementation takes the schema and control XML source on construction, which is not elegant and makes the engine applicable only for XMLs of the given schema. Probably this feature could be better implemented in XMLUnit.

Also, I added a wrapper for ComparisonController, because the standard Diff takes a DifferenceEngine on construction which cannot be changed afterwards and vice versa. So there does not seem to be a good way to use a subclass of DifferenceEngine with a standard Diff instance, but maybe I overlooked sth. here.

Sources are attached.

Discussion

  • Bastian Blankenburg

    Considering the last point, after having looked through the code, I think it would be good if the assert* methods would use a configurable factory to instantiate the Diff, and the Diff should use a factory to instantiate the difference engine. That way, a custom difference engine might be used in conjunction with all assert* methods, not just the ones taking the Diff as parameter.

     
  • Stefan Bodewig

    Stefan Bodewig - 2014-12-14
     

Log in to post a comment.