Grammar-specific Comparison
DeltaNova's XML comparison engine can exploit grammar information — from DTDs, XML Schemas (XSD), or RELAX NG grammars — to produce more accurate and semantically meaningful comparison results. When grammar information is available, the comparator uses it to determine element content models, whitespace significance, and attribute types, enabling more precise difference detection.
Grammar-aware Processing
When a DTD or XML Schema is loaded, the comparison engine uses grammar information to:
-
Determine which whitespace nodes are significant (mixed content) and which are ignorable (element-only content).
-
Identify attribute types, including ID and IDREF attributes used for key-based matching
-
Handle default attribute values defined in the grammar, ensuring they are not incorrectly flagged as additions or deletions.
-
Preserve ignorable whitespace nodes explicitly, preventing them from being affected by normalisation filters.
Without grammar information, whitespace patterns are analysed heuristically using the built-in whitespace-detection.xsl stylesheet to identify elements with mixed content.
DTD-aware Comparison
When a DTD is available, the comparator can resolve entity references and handle default attribute values as defined in the document type declaration. To use DTD information, ensure the XML inputs include a valid DOCTYPE declaration pointing to an accessible DTD, or configure a catalog resolver to map public or system identifiers to local copies.
See Using a Catalog Resolver for information on configuring catalog-based entity resolution.
Schema-aware Comparison
XML Schema (XSD) provides richer type information than DTDs. When an XSD is available, the comparator can:
-
Use
xs:IDandxs:IDREFtype information for key-based element matching -
Apply content model constraints to improve alignment accuracy for complex types
-
Handle
xsi:typesubstitutions correctly in polymorphic document structures
To associate a schema with a comparison, use the schemaLocation or noNamespaceSchemaLocation attributes on the root element, or configure the schema explicitly via the comparison pipeline.
Enhanced Whitespace Handling with Grammar Information
The enhanced whitespace handling feature extends standard grammar-based whitespace processing with additional preservation modes. When enabled:
-
A
grammarattribute is added to the root element of each input, indicating whether DTD or schema information was used -
Ignorable whitespace nodes are wrapped in
preserve:ignorableelements to prevent normalisation -
A
mixed-contentattribute is added to elements where text nodes are permitted by the grammar
See Enabling Enhanced Whitespace Handling and Lexical Preservation Concepts for configuration details.
RELAX NG and Other Grammars
For documents validated using RELAX NG or other schema languages, grammar-specific processing can be approximated by providing custom input filters that annotate elements with content model information before comparison takes place. See Specifying a Comparison Pipeline for details on adding custom filter steps.
DITA, DocBook, and HTML Support
DeltaNova's comparison engine supports the following grammar-specific document types:
-
DITA Compare — optimised for DITA topics and maps, giving more accurate comparisons of DITA content.
-
DocBook Compare — tailored for DocBook documents, improving comparison accuracy across books, chapters, and sections.
-
HTML Compare — tailored for HTML documents, handling HTML's structure automatically without needing a DOCTYPE or schema.
Each of these builds on the same grammar-aware comparison engine, pre-configured for its target format.