java-api.dita 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE concept PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
  3. <!-- This file is part of the DITA Open Toolkit project. See the accompanying LICENSE file for applicable license. -->
  4. <concept id="API">
  5. <title>Java API</title>
  6. <shortdesc>DITA-OT includes a Java Application Programming Interface to allow developers to embed DITA-OT more easily
  7. into other Java programs.</shortdesc>
  8. <prolog>
  9. <metadata>
  10. <keywords>
  11. <indexterm>Java API</indexterm>
  12. <indexterm>API:Java</indexterm>
  13. </keywords>
  14. </metadata>
  15. </prolog>
  16. <conbody>
  17. <p>When using the API, programmers don't need to know or care that DITA-OT uses Ant, they can just use Java. </p>
  18. <note>When running DITA-OT via the <cmdname>dita</cmdname> command, an <codeph>ant</codeph> shell script handles the
  19. classpath setup, but when using the API the classpath should be set up as part of the normal classpath
  20. configuration for the Java application.</note>
  21. <example>
  22. <title>Example usage</title>
  23. <codeblock outputclass="language-java">// Create a reusable processor factory with DITA-OT base directory and temporary directory
  24. ProcessorFactory pf = ProcessorFactory.newInstance(ditaDir);
  25. pf.setBaseTempDir(tempDir);
  26. // Create a processor using the factory and configure the processor
  27. Processor p = pf.newProcessor("html5")
  28. .setInput(mapFile)
  29. .setOutputDir(outDir)
  30. .setProperty("nav-toc", "partial");
  31. // Run conversion
  32. p.run();</codeblock>
  33. </example>
  34. <section>
  35. <p>By default, running DITA-OT via the API will write a debug log to the temporary directory. A custom SLF4J
  36. logger can also be used to access the log via the Simple Logging Facade for Java.</p>
  37. <p>The processor cleans the temporary directory by default, but this can be disabled to simplify debugging in
  38. cases where the processor failed.</p>
  39. <note type="tip">See the <cite>DITA-OT Java API documentation</cite> in the <filepath>doc/api/</filepath> folder
  40. of the DITA-OT distribution package for information on the packages, classes, interfaces and methods provided by
  41. the Java API.</note>
  42. </section>
  43. <section>
  44. <title>Downloading DITA-OT from Maven Central</title>
  45. <p>As of version 2.5, the DITA Open Toolkit base library (<filepath>dost.jar</filepath>) is available via the
  46. Maven 2 Central Repository. You can use this mechanism to download the main JAR file and include it in the build
  47. for other Java projects.</p>
  48. <p>To locate the latest version, <xref href="https://search.maven.org/#search%7Cga%7C1%7Cg%3A%22org.dita-ot%22"
  49. format="html" scope="external">search for the <codeph>org.dita-ot</codeph> group ID</xref>.</p>
  50. <note type="important">The <filepath>dost.jar</filepath> file provides only the DITA Open Toolkit base library. It
  51. does <b>not</b> contain the full DITA-OT distribution and cannot be used to run DITA-OT by itself. You will need
  52. to ensure that your build installs the other files and directories required for the toolkit along with the
  53. dependencies for your project.</note>
  54. </section>
  55. </conbody>
  56. </concept>