Check
Supported Input Types
|
Input Type |
Java Class |
|---|---|
|
DITA map |
|
|
Docx |
|
|
XML |
|
Running a Check
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
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
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.
-
Create a
plugin.xmlfile which contains a<feature>using thedita.specialization.catalog.relativeextension and a relative path pointing to your catalog file.
<plugin id="com.example.catalog">
<feature extension="dita.specialization.catalog.relative"
file="catalog-dita.xml"/>
</plugin>
-
Zip up this file along with your catalog files.
-
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:
<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:
dita-ot-3.7.4-patched-1/bin/dita install /path/to/your/new.zip
Progress Reporting
checker.addConversionCheckerProgressListener(new ConversionCheckerProgressListener() {
@Override
public void progressUpdate(ConversionCheckerProgressEvent event) {
System.out.println("Stage: " + event.getStage() + " (" + event.getPercentComplete() + "%)");
}
});