java-api.html 5.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <!DOCTYPE html
  2. SYSTEM "about:legacy-compat">
  3. <html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><meta charset="UTF-8"><meta name="copyright" content="(C) Copyright 2018"><meta name="DC.rights.owner" content="(C) Copyright 2018"><meta name="DC.Type" content="concept"><meta name="description" content="DITA-OT includes a Java Application Programming Interface to allow developers to embed DITA-OT more easily into other Java programs."><meta name="DC.subject" content="Java API, API:Java"><meta name="keywords" content="Java API, API:Java"><meta name="DC.Relation" scheme="URI" content="../reference/index.html"><meta name="DC.Relation" scheme="URI" content="../api/index.html"><meta name="DC.Format" content="HTML5"><meta name="DC.Identifier" content="API"><link rel="stylesheet" type="text/css" href="../css/commonltr.css"><link rel="stylesheet" type="text/css" href="../css/dita-ot-doc.css"><title>Java API</title></head><body id="API"><header role="banner"><div class="header">
  4. <p>DITA Open Toolkit</p>
  5. <hr>
  6. </div></header><nav role="toc"><ul><li><a href="../index.html">DITA Open Toolkit 3.0</a></li><li><a href="../release-notes/index.html">Release Notes</a></li><li><a href="../topics/installing-client.html">Installing DITA-OT</a></li><li><a href="../topics/alternative-input-formats.html">Authoring formats</a></li><li><a href="../topics/building-output.html">Building output</a></li><li><a href="../parameters/index.html">Setting parameters</a></li><li><a href="../topics/extending-the-ot.html">Customizing DITA-OT</a></li><li><a href="../topics/troubleshooting-overview.html">Troubleshooting</a></li><li><a href="../reference/index.html">Reference</a><ul><li><a href="../reference/architecture.html">DITA-OT architecture</a></li><li><a href="../reference/DITA_spec-support.html">DITA specification support</a></li><li class="active"><a href="../reference/java-api.html">Java API</a></li><li><a href="../reference/license.html">License</a></li></ul></li><li><a href="../topics/dita-and-dita-ot-resources.html">Resources</a></li></ul></nav><main role="main"><article role="article" aria-labelledby="ariaid-title1">
  7. <h1 class="title topictitle1" id="ariaid-title1">Java API</h1>
  8. <div class="body conbody"><p class="shortdesc">DITA-OT includes a Java Application Programming Interface to allow developers to embed DITA-OT more easily
  9. into other Java programs.</p>
  10. <p class="p">When using the API, programmers don't need to know or care that DITA-OT uses Ant, they can just use Java. </p>
  11. <div class="note note note_note"><span class="note__title">Note:</span> When running DITA-OT via the <span class="keyword cmdname">dita</span> command, an <code class="ph codeph">ant</code> shell script handles the
  12. classpath setup, but when using the API the classpath should be set up as part of the normal classpath
  13. configuration for the Java application.</div>
  14. <div class="example"><h2 class="title sectiontitle">Example usage</h2>
  15. <pre class="pre codeblock language-java"><code>// Create a reusable processor factory with DITA-OT base directory and temporary directory
  16. ProcessorFactory pf = ProcessorFactory.newInstance(ditaDir);
  17. pf.setBaseTempDir(tempDir);
  18. // Create a processor using the factory and configure the processor
  19. Processor p = pf.newProcessor("html5")
  20. .setInput(mapFile)
  21. .setOutputDir(outDir)
  22. .setProperty("nav-toc", "partial");
  23. // Run conversion
  24. p.run();</code></pre>
  25. </div>
  26. <section class="section">
  27. <p class="p">By default, running DITA-OT via the API will write a debug log to the temporary directory. A custom SLF4J
  28. logger can also be used to access the log via the Simple Logging Facade for Java.</p>
  29. <p class="p">The processor cleans the temporary directory by default, but this can be disabled to simplify debugging in
  30. cases where the processor failed.</p>
  31. <div class="note tip note_tip"><span class="note__title">Tip:</span> See the <cite class="cite">DITA-OT Java API documentation</cite> in the <span class="ph filepath">doc/api/</span> folder
  32. of the DITA-OT distribution package for information on the packages, classes, interfaces and methods provided by
  33. the Java API.</div>
  34. </section>
  35. <section class="section"><h2 class="title sectiontitle">Downloading DITA-OT from Maven Central</h2>
  36. <p class="p">As of version 2.5, the DITA Open Toolkit base library (<span class="ph filepath">dost.jar</span>) is available via the
  37. Maven 2 Central Repository. You can use this mechanism to download the main JAR file and include it in the build
  38. for other Java projects.</p>
  39. <p class="p">To locate the latest version, <a class="xref" href="https://search.maven.org/#search%7Cga%7C1%7Cg%3A%22org.dita-ot%22" target="_blank">search for the <code class="ph codeph">org.dita-ot</code> group ID</a>.</p>
  40. <div class="note important note_important"><span class="note__title">Important:</span> The <span class="ph filepath">dost.jar</span> file provides only the DITA Open Toolkit base library. It
  41. does <strong class="ph b">not</strong> contain the full DITA-OT distribution and cannot be used to run DITA-OT by itself. You will need
  42. to ensure that your build installs the other files and directories required for the toolkit along with the
  43. dependencies for your project.</div>
  44. </section>
  45. </div>
  46. <nav role="navigation" class="related-links"><div class="familylinks"><div class="parentlink"><strong>Parent topic:</strong> <a class="link" href="../reference/index.html" title="The Reference topics provide more advanced information about the DITA-OT architecture, API and specification support, and licensing.">Reference</a></div></div><div class="linklist relinfo"><strong>Related information</strong><br><ul class="linklist"><li class="linklist"><a class="link" href="../api/index.html">DITA-OT Java API documentation</a></li></ul></div></nav></article></main></body></html>