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.
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 and temporary directory ProcessorFactory pf = ProcessorFactory.newInstance(ditaDir); 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.