Java API Sample

 Table of Contents


This sample is a basic demonstration of how to use DITA Merge's Java API to run some DITA Merge operations with hard-coded file paths.


The sample is implemented in the main method of a single Java class,, and the approach taken is as follows:

  1. Create File objects for sample inputs.
  2. Instantiate the DitaConcurrentMerge object using the constructor;
  3. Set the ancestor file with setAncestor;
  4. Add the demo input versions with addVersion;
  5. Call extractAll to get hold of the DeltaV2 representation of the merge.

Additionally use is made of the ThreeWayDitaMerge class and one of its merge methods which allows merge operations to be performed using a single method call. This class also allows the approach show above but we only demonstrate the simpler method calls in the sample code.


To run this sample, you will require Apache Ant and a JDK. From a command prompt in the sample directory, you can invoke the sample with:


The following targets are supplied in build.xml:

runDefault. This depends on the compile target, and runs the main method of
compileCompiles into a Java .class file in the class directory, which can be invoked either through the java command or from the ant run target above.
cleanThis deletes everything in the .class directory.
#content .code