Viewing Comparison Results

www.altova.com Print this Topic Previous Page Up One Level Next page

Home >  Running Comparisons >

Viewing Comparison Results

Whenever you run a comparison using the diff command and supply the --output-mode=text option, a text report with comparison results is generated. Likewise, if you supply the option --output-mode=xml, an XML report with comparison results is generated.

 

By default, the report containing comparison results is displayed at the command line, unless you set the option --quiet=true. To save the report to an output file, set the --output-file option, see also Handling the Output.

 

XML report

To understand how differences are reported in XML format, let's assume that the following two XML files must be compared side-by-side:

 

<book id="1">  
  <author>Mark Twain</author>
</book>

<book id="2">
  <author>Franz Kafka</author>
</book>

 

If you compare these two files with the command

 

DiffDogCmdlClient diff file1.xml file2.xml --mode=xml --output-mode=xml --output-file=report.xml

 

then the resulting XML report would look similar to the one below:

 

<?xml version="1.0" encoding="UTF-8"?>
<!-- Differencing export generated by Altova DiffDog Server -->
<diff_result>
  <diff_info comparison_mode="xml">
    <source_left name="c:\file1.xml" uri="file:///c:/file1.xml"/>
    <source_right name="c:\file2.xml" uri="file:///c:/file2.xml"/>
  </diff_info>
  <xml_diff>
    <left_location>
        <parent xpath="/book"/>
        <position>1</position>
    </left_location>
    <right_location>
        <parent xpath="/book"/>
        <position>1</position>
    </right_location>
    <left_content>
        <attribute id="1"/>
    </left_content>
    <right_content>
        <attribute id="2"/>
    </right_content>
  </xml_diff>
  <xml_diff>
    <left_location>
        <parent xpath="/book/author"/>
        <position>1</position>
    </left_location>
    <right_location>
        <parent xpath="/book/author"/>
        <position>1</position>
    </right_location>
    <left_content>
        <element>Mark Twain</element>
    </left_content>
    <right_content>
        <element>Franz Kafka</element>
    </right_content>
  </xml_diff>
</diff_result>

Example XML report

At the very top, the XML report contains a diff_info element. The diff_info element supplies information about files that were compared (including the comparison mode used, and the path of the compared files). This element occurs only once.

 

Next, all the encountered differences (two, in this example) are listed by means of multiple xml_diff elements. In the context of each difference, the left_location (and right_location, correspondingly) inform you where the difference was encountered, as an XPath expression.  The left_content (and right_content, correspondingly) inform you about the exact element or attribute that is changed.


© 2019 Altova GmbH