DITA-OT includes a 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.
antshell 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.
// Create a reusable processor factory with DITA-OT base directory ProcessorFactory pf = ProcessorFactory.newInstance(ditaDir); // and set the temporary directory pf.setBaseTempDir(tempDir); // Create a processor using the factory and configure the processor Processor p = pf.newProcessor("html5") .setInput(mapFile) .setOutputDir(outDir) .setProperty("nav-toc", "partial"); // Run conversion p.run();
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.
Downloading DITA-OT from Maven Central
As of version 2.5, the DITA Open Toolkit base library (dost.jar) is available via the Maven 2 Central Repository. You can use this mechanism to download the main JAR file and include it in the build for other Java projects.
To locate the latest version, search for the
org.dita-ot group ID.