|
Home >Online Product Documentation >Table of Contents >Overview OverviewStylus Studio's Diff tool lets you easily compare two or more versions of the same document in the XML Diff Viewer (as shown in Figure 126), or the contents of two folders (as shown in Figure 130). Customizable color-coding lets you quickly determine how one document differs from another - green, for example, identifies objects (such as elements and attributes) that are present in the target document, but which do not exist in the source document. When you hover the pointer over symbols displayed in the side bars of the source and target document windows, Stylus Studio displays a tool tip that indicates the specific nature of the change. This section covers the following topics: Sources and TargetsWhen you use Stylus Studio to diff documents (or folders), you select a source and a target. Stylus Studio considers the source document or folder to be the baseline, or current standard; the target document or folder is assumed to be some other version (it might be older or newer, for example) of the source. The Stylus Studio Diff tool illustrates how this other version, the target, differs from the source (or sources) you have selected. The Diff Configuration FileYou can save the information associated with a given XML diff session in a diff configuration file. Diff configuration files make it easy to perform a diff on the same set of XML documents over time. Examples of the information saved with the diff configuration file include the URLs of the source and target documents, and any settings made on the XML Diff menu or tool bar. Diff configuration files are created with a .dff extension. Changes made to the source and target documents are detected by Stylus Studio the next time you open the diff configuration file, allowing you to diff the files at that time. (Whether or not the diff is run automatically when you open the diff configuration file depends on Autorun Diff settings on the Engine page of the Options dialog box. See When Does the Diff Run? for more information.) What Diffs Are Calculated?This section describes how Stylus Studio diffs XML documents and folders. Documents - The Stylus Studio Diff engine compares source and target documents in their entirety. If you want, you can use the Engine page of the Options dialog box to exclude certain items from the diff calculation. These items include:
l Comments
l Text
l Entities
l Attributes
l Processing instructions
You can also specify whether or not you want Stylus Studio to:
l Use URIs to compare namespaces
l Expand entity references
l Ignore text formatting characters (new lines, carriage returns, and tabs)
See Modifying Default Diff Settings to learn how to set these and other diff options. Folders - Options for diffing XML documents do not affect how Stylus Studio diffs folders. When diffing folders, Stylus Studio compares one folder's contents with another. See Diffing Foldersfor more information on this topic. Tuning the Diffing AlgorithmThe purpose of any diffing tool is to identify the list of logical operations required to change the source document into the target document. Examples of logical operations include additions, revisions, and deletions. Even diffs between simple XML documents can yield a long list, sometimes with redundant operations. Ideally, the list of operations should be reduced to make it as economical as possible; that is, the list should be able to answer the question, What are the fewest number of changes required to turn the source into the target? Calculating such a list can be time-consuming and resource intensive, and these costs might not be worth the benefits to a given user. For this reason, Stylus Studio provides settings that let you tune the diffing algorithm used by the XML Diff engine. Tuning settings are displayed in the Performance group box on the Engine page of the Options dialog box. You can
l Select a tuning that optimizes the algorithm to provide the most economical set of changes possible (Optimize change description). As described earlier, this calculation, though it yields the best results, can be costly in terms of time and processing resources.
l Select a tuning that optimizes the algorithm to provide the set of changes in the shortest time possible (Optimize calculation time).
l Let Stylus Studio decide (Autodetect). By default, Stylus Studio tries to provide the most economical set of changes possible, but if it determines that processing resources are limited or that the calculation will take too much time, it reverts to the algorithm tuning that is optimized for speed.
Handling Large DocumentsThe Optimize for large documents with few changes setting helps speed the diffing of large (greater than 1MB) documents. This setting can be used in conjunction with any of the algorithm tuning settings and is on by default. When Does the Diff Run?Stylus Studio runs the diff automatically, as soon as you specify the target document or folder. Whether or not subsequent changes cause Stylus Studio to automatically recalculate the diff is determined by the Autorun Diff settings on the Engine page of the Options dialog box. Changes that can make a diff recalculation necessary include adding new source and target documents, changing the underlying source and target documents themselves, or to changes to certain Engine settings. Options That Affect When the Diff RunsThese settings, on the Engine page of the Options dialog box, determine when and whether Stylus Studio automatically recalculates the diff.
l On changes - Certain types of changes to the diff configuration file require Stylus Studio to recalculate the diff. These changes include:
n Adding a new source document
n Changing the target document
n Changing the Use URI to compare namespaces setting
n Changing the Expand entity references setting
If the On changes setting is on, Stylus Studio automatically runs the diff when any of these changes occurs.
l If files modified - If you make and save changes to a source or target document, Stylus Studio automatically runs the diff if this setting is on.
See Modifying Default Diff Settingsto learn more about setting these and other Diff options. Running the Diff ManuallyYou can run the diff manually by clicking the Calculate diff button ( ). Stylus Studio activates this button when it detects the need to recalculate the diff, and the On changes or If files modified settings are off. These settings, as described in When Does the Diff Run?, cause Stylus Studio to run the diff automatically. You can also run the diff from the command line. See Running the Diff Tool from the Command Line. Symbols and Background ColorsStylus Studio uses symbols and background colors to alert you to differences in diffed documents and folders. The following table summarizes the symbols and default background colors, and the types of changes they represent. You can change the background colors on the Presentation page of the Options dialog box. Combined SymbolsAs described in Table 14, Default Colors Used for Diffing Files and Folders,, Stylus Studio displays a turquoise block ( ) when a node that you have collapsed contains changes. Sometimes, the node itself has changes. In this case, Stylus Studio combines two symbols - one indicating the change of a child within the collapsed node, and one to the node itself. Consider the following illustration: Here, the city node displays a combined symbol - the turquoise box indicates that a change exists within the collapsed node; the minus sign indicates that the city node is not present in the source document. Expanding the city node makes the scope and nature of the changes explicit:
Additional Symbols for Diffing Multiple SourcesStylus Studio uses other symbols in the target document window when you diff multiple source documents. See Symbols Used in the Target Document Window. |