Java API

DITA-OT 2.5 includes a new Java Application Programming Interface to allow developers to embed DITA-OT more easily into other Java programs.

When using the API, programmers don't need to know or care that DITA-OT uses Ant, they can just use Java.

Note: When running DITA-OT via the dita command, an ant shell script handles the classpath setup, but when using the API the classpath should be set up as part of the normal classpath configuration for the Java application.

Example usage

// Create a reusable processor factory with DITA-OT base directory and temporary directory
ProcessorFactory pf = ProcessorFactory.newInstance(ditaDir);

// Create a processor using the factory and configure the processor
Processor p = pf.newProcessor("html5")
.setProperty("nav-toc", "partial");

// Run conversion;

By default, running DITA-OT via the API will write a debug log to the temporary directory. A custom SLF4J logger can also be used to access the log via the Simple Logging Facade for Java.

The processor cleans the temporary directory by default, but this can be disabled to simplify debugging in cases where the processor failed.

Tip: See the DITA-OT Java API documentation in the doc/api/ folder of the DITA-OT distribution package for information on the packages, classes, interfaces and methods provided by the Java API.