| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
- <!-- This file is part of the DITA Open Toolkit project. See the accompanying LICENSE file for applicable license. -->
- <task id="plugin-javalib" xml:lang="en-US">
- <title>Adding a Java library to the DITA-OT <parmname>classpath</parmname> parameter</title>
- <shortdesc>You can use the <codeph>dita.conductor.lib.import</codeph> extension point to add an additional Java
- library to the DITA-OT <parmname>classpath</parmname> parameter.</shortdesc>
- <taskbody>
- <steps>
- <step>
- <cmd>If necessary, compile the Java code into a JAR file.</cmd>
- </step>
- <step>
- <cmd>Create a <filepath>plugin.xml</filepath> file that contains the following code:</cmd>
- <info><codeblock><plugin id="<varname>plugin-id</varname>">
- <feature extension="dita.conductor.lib.import" file="<varname>file</varname>"/>
- </plugin></codeblock>where:<ul>
- <li><varname>plugin-id</varname> is the plug-in identifier, for example, com.example.addjar.</li>
- <li><varname>file</varname> is the name of the JAR file, for example,
- <filepath>myJavaLibrary.jar</filepath>. </li>
- </ul></info>
- </step>
- <step>
- <cmd>Install the plug-in.</cmd>
- </step>
- </steps>
- <result>The Ant or XSLT code now can make use of the Java code.</result>
- <example>
- <p>In the following extended example, the <filepath>myJavaLibrary.jar</filepath> file performs a validation step
- during processing, and you want it to run immediately before the <codeph>conref </codeph>step. To accomplish
- this, you will need to use several features:</p>
- <ul>
- <li>The JAR file must be added to the classpath.</li>
- <li>The Ant target must be added to the dependency chain for conref.</li>
- <li>An Ant target must be created that uses this class, and the Ant wrapper integrated into the code.</li>
- </ul>
- <p>The files might look like the following:</p>
- <fig>
- <title><filepath>plugin.xml</filepath> file</title>
- <codeblock><?xml version="1.0" encoding="UTF-8"?>
- <plugin id="com.example.samplejava">
- <!-- Add the JAR file to the DITA-OT CLASSPATH -->
- <b><feature extension="dita.conductor.lib.import" file="com.example.sampleValidation.jar"/></b>
- <!-- Integrate the Ant code -->
- <feature extension="dita.conductor.target.relative" file="antWrapper.xml"/>
- <!-- Define the Ant target that is called, and the location (before conref) -->
- <feature extension="depend.preprocess.conref.pre" value="validateWithJava"/>
- </plugin></codeblock>
- </fig>
- <fig>
- <title><filepath>antWrapper.xml</filepath> file</title>
- <codeblock><?xml version="1.0" encoding="UTF-8"?>
- <dummy>
- <import file="calljava-antcode.xml"/>
- </dummy></codeblock>
- </fig>
- <fig>
- <title><filepath>calljava-antcode.xml</filepath> file</title>
- <codeblock><?xml version="1.0" encoding="UTF-8"?>
- <project default="validateWithJava">
- <target name="validateWithJava">
- <java classname="com.example.sampleValidation">
- <!-- The class was added to dost.class.path (the DITA-OT classpath) -->
- <classpath refid="dost.class.path"/>
- </java>
- </target>
- </project></codeblock>
- </fig>
- </example>
- </taskbody>
- </task>
|