Check

Check

Supported Input Types

Input Type

Java Class

DITA map

DITAMapInput

Docx

DocxInput

XML

XMLInput

Running a Check

Java
File fileA = new File(dir, "document.docx");
File fileB = new File(dir, "document.xml");

DocxInput inputA = new DocxInput(fileA);
XMLInput inputB  = new XMLInput(fileB);

ConversionChecker checker = new ConversionChecker();
ConversionCheckerResult result = checker.checkConversion(inputA, inputB);

Reading the Result

Java
if (result.isContentEqual()) {
    System.out.println("Conversion was successful.");
} else {
    File changeReport = result.getChangeReport();
    System.out.println("Changes detected. Report: " + changeReport);
}

isContentEqual

Returns true if the content of the two inputs is equal; false if differences were found.

getChangeReport

Returns a File object pointing to the HTML change report.

Setting Result Location

Java
checker.setResultLocation(new File("/output/directory"));
checker.setResultPrefix("mycheck-2024-01-15");

How to Use Custom DITA

Our DitaMapInput class relies on using DITA-OT to consolidate DITA documents into a single file to allow it to be checked against a document in a different format.

If you’re using DitaMapInput and have DITA files using a customised catalog, you need to do the following setup to get it to work.

  1. Create a plugin.xml file which contains a <feature> using the dita.specialization.catalog.relative extension and a relative path pointing to your catalog file.

XML
<plugin id="com.example.catalog">
  <feature extension="dita.specialization.catalog.relative"
           file="catalog-dita.xml"/>
</plugin> 
  1. Zip up this file along with your catalog files.

  2. Run the following command to install it:

dita-ot-3.7.4-patched-1/bin/dita install /path/to/your/new.zip

We recommend you run this using the copy of DITA-OT we have bundled with Check: dita-ot-3.7.4-patched-1/bin/dita. Alternatively, if you wish to use a different copy of DITA-OT see Configuration Properties for more information.

View DITA-OT’s documentation for more details - Extending an XML catalog file.

Custom DITA Catalog

If your DITA files use a customised catalog, create a plugin.xml:

XML
<plugin id="com.example.catalog">
  <feature extension="dita.specialization.catalog.relative"
           file="catalog-dita.xml"/>
</plugin>

Zip the plugin with your catalog files and install it:

Bash
dita-ot-3.7.4-patched-1/bin/dita install /path/to/your/new.zip

Progress Reporting

Java
checker.addConversionCheckerProgressListener(new ConversionCheckerProgressListener() {
    @Override
    public void progressUpdate(ConversionCheckerProgressEvent event) {
        System.out.println("Stage: " + event.getStage() + " (" + event.getPercentComplete() + "%)");
    }
});