www.gusucode.com > rptgen 案例源码程序 matlab代码 > rptgen/mlxml_testplan.m

    %% Comparing XML Files
% This example shows you how to use MATLAB(R) Report Generator(TM) to
% perform an XML comparison of two XML text files, and view the differences
% in the resulting report.

% Copyright 2008-2012 The MathWorks, Inc.

%% Introduction
% This example compares two XML text files that describe a catalytic
% converter test. The XML files record information about the environment
% when the test was performed, such as time and temperature, as well as the
% results of the tests that were performed. You can use XML comparison to
% explore the changes between files.

%% Raw Test Files
% The test files are stored as XML. To view their contents, run the
% following commands:
type('xmldemo_test_run1.xml')
 
type('xmldemo_test_run2.xml')

%% Compare The XML Files
% Use the Comparison Tool to compare the two XML files.
visdiff('xmldemo_test_run1.xml', 'xmldemo_test_run2.xml')

%% Understand The Results
% The Comparison Tool shows only differences between the two XML files as a
% hierarchy, via two tree controls. The report does not display sections of
% the XML files which are identical. For example, both
% xmldemo_test_run1.xml and xmldemo_test_run2.xml contain an element called
% "testname" that contains the same text, "Catalysts", in both files. This
% item is not included in the comparison report because it is identical in
% both files.
% 
% Click the "Expand All" button on the Comparison Tool to expand the report
% trees and view every difference found by the analysis.
%
% Colors indicate if items are modified (pink items) or unmatched (green
% items, found only on one side).

%% View Environment Changes
% The values of environmental data (temperature, humidity and pressure) are
% different in each file, and you can view these elements, and the changed
% text content, in the report. Click the "environment" item in one tree to
% automatically select it in the other.
% 
% Click temperature, humidity and pressure in turn, and view the different
% values on each side in the Parameter Values pane at the bottom of the
% report.
%
% Note that these environment elements have changed order. Click the
% "weather" element in the comparison report. The report highlights the
% weather element on both sides. In this case, the "weather" text content
% is the same in both files, but its location has changed within the
% environment node.  The highlighting shows you that in
% xmldemo_test_run1.xml the "weather" element is located at the end of the
% "environment" element. In xmldemo_test_run2.xml it has moved to the
% beginning of the "environment" element.

%% View Header Changes
% Under the "header" element, you can see the that the contents of some
% child elements have changed. 
% 
% Click the "time" element to view the item selected on both sides of the
% report, and view the different parameter values in the lower pane.
%
% Observe the "date" element is green, showing it is "Unmatched". The
% Chawathe algorithm cannot match the "date" elements because the text
% content is different and there are no attributes to compare. The other
% elements in the file have attributes which cause them to have a higher
% "score" according to the Chawathe matching rules, so they match (e.g. the
% "zone" attribute of the "time" element in the XML file:

% <time zone="GMT">14:02:34</time>


%% View Vehicle Changes
% In xmldemo_test_run1.xml, the "ECUVersion" parameter is part of the
% "engine" grouping, which is part of the "vehicle" element. In
% xmldemo_test_run2.xml, the "ECUVersion" parameter has moved out of
% "engine" and into "vehicle". Click "ECUVersion" to see the different
% position on each side.
% 
% Under the "results" element there is an element "lambda". In
% xmldemo_test_run1.xml this has the value "pass". In xmldemo_test_run2.xml
% this has the value "fail", and is followed by an additional node "rerun"
% containing another element "lambda" with value "pass". Since "rerun"
% exists only in xmldemo_test_run2.xml it is shown as unmatched. 
% The Chawathe algorithm regards the two instances of lambda with value
% "pass" as being the best match, and so the element lambda in
% xmldemo_test_run1.xml is shown as having moved to within "rerun" in
% xmldemo_test_run2.xml. 

%% Further Information
%
% <matlab:helpview(fullfile(docroot,'toolbox','rptgen','rptgen.map'),'comparexmlfiles') XML Comparison documentation>

%%
displayEndOfDemoMessage(mfilename)