| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- <!DOCTYPE html
- SYSTEM "about:legacy-compat">
- <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 2019"><meta name="DC.rights.owner" content="(C) Copyright 2019"><meta name="DC.type" content="concept"><meta name="description" content="DITA Open Toolkit includes a Java Application Programming Interface to allow developers to embed the toolkit more easily into other Java programs."><meta name="DC.subject" content="Java, API, command, dita, classpath"><meta name="keywords" content="Java, API, command, dita, classpath"><meta name="DC.relation" scheme="URI" content="../topics/building-output.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>Using the Java API</title></head><body id="API"><header role="banner"><div class="header">
- <p>DITA Open Toolkit</p>
- <hr>
- </div></header><nav role="toc"><ul><li><a href="../index.html">DITA Open Toolkit 3.3</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><ul><li><a href="../topics/build-using-dita-command.html">Using the dita command</a></li><li><a href="../topics/publishing-with-ant.html">Using Ant</a></li><li class="active"><a href="../reference/java-api.html">Using the Java API</a></li><li><a href="../topics/output-formats.html">Output formats</a></li></ul></li><li><a href="../parameters/index.html">Setting parameters</a></li><li><a href="../topics/customizing.html">Customizing DITA-OT</a></li><li><a href="../topics/troubleshooting-overview.html">Troubleshooting</a></li><li><a href="../reference/index.html">Reference</a></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">
- <h1 class="title topictitle1" id="ariaid-title1">Using the Java API</h1>
-
-
- <div class="body conbody"><p class="shortdesc">DITA Open Toolkit includes a Java Application Programming Interface to allow developers to embed the
- toolkit more easily into other Java programs.</p>
- <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>
- <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
- classpath setup, but when using the API the classpath should be set up as part of the normal classpath
- configuration for the Java application.</div>
- <div class="example"><h2 class="title sectiontitle">Example usage</h2>
-
- <pre class="pre codeblock language-java normalize-space show-line-numbers show-whitespace"><code>// 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();</code></pre>
- </div>
- <section class="section">
-
- <p class="p">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.</p>
- <p class="p">The processor cleans the temporary directory by default, but this can be disabled to simplify debugging in
- cases where the processor failed.</p>
- <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
- of the DITA-OT distribution package for information on the packages, classes, interfaces and methods provided by
- the Java API.</div>
- </section>
- <section class="section"><h2 class="title sectiontitle">Downloading DITA-OT from Maven Central</h2>
-
-
- <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
- 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.</p>
- <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>
- <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
- 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
- to ensure that your build installs the other files and directories required for the toolkit along with the
- dependencies for your project.</div>
- </section>
- </div>
- <nav role="navigation" class="related-links"><div class="familylinks"><div class="parentlink"><strong>Parent topic:</strong> <a class="link" href="../topics/building-output.html" title="You can use the dita command-line tool, Ant, or the Java API to transform DITA content to the various output formats that DITA Open Toolkit supports.">Building output</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>
|