1 | <?xml version="1.0" encoding="UTF-8"?>
|
---|
2 | <!DOCTYPE reference PUBLIC "-//OASIS//DTD DITA Reference//EN"
|
---|
3 | "reference.dtd">
|
---|
4 | <reference id="plugin-javalib" xml:lang="en-us">
|
---|
5 | <title>Adding Java libraries to the classpath</title>
|
---|
6 | <shortdesc>If your Ant or XSLT extensions require additional Java
|
---|
7 | libraries in the classpath, you can add them to the global DITA-OT
|
---|
8 | classpath with the following feature.</shortdesc>
|
---|
9 | <refbody>
|
---|
10 | <section> <dl><dlentry>
|
---|
11 | <dt><codeph>dita.conductor.lib.import</codeph></dt>
|
---|
12 | <dd>Add Java libraries to DITA-OT classpath.</dd>
|
---|
13 | </dlentry></dl> </section>
|
---|
14 | <example><title>Example</title><p>The following plug-in adds the compiled
|
---|
15 | Java code from <filepath>myJavaLibrary.jar</filepath> into the global
|
---|
16 | DITA-OT classpath. XSLT or Ant code can then make use of the added
|
---|
17 | code.</p><codeblock><plugin id="com.example.addjar">
|
---|
18 | <feature extension="dita.conductor.lib.import" file="myJavaLibrary.jar"/>
|
---|
19 | </plugin></codeblock><p>Now assume that in this case myJavaLibrary.jar
|
---|
20 | performs some validation step in the middle of processing, and you
|
---|
21 | always want it to run immediately before the conref step. In that
|
---|
22 | case you need to make use of several features in this plug-in</p><ul>
|
---|
23 | <li>The JAR file must be added to the classpath.</li>
|
---|
24 | <li>An Ant target must be created that uses this class, and the Ant
|
---|
25 | wrapper integrated into the code.</li>
|
---|
26 | <li>The Ant target must be added to the dependency chain for conref.</li>
|
---|
27 | </ul><p>In this extended example, the files might look something like
|
---|
28 | this.</p><codeblock>plugin.xml:
|
---|
29 | <?xml version="1.0" encoding="UTF-8"?>
|
---|
30 | <plugin id="com.example.samplejava">
|
---|
31 | <!-- Add the JAR file to the DITA-OT CLASSPATH -->
|
---|
32 | <b><feature extension="dita.conductor.lib.import" file="com.example.sampleValidation.jar"/></b>
|
---|
33 | <!-- Integrate the Ant code -->
|
---|
34 | <feature extension="dita.conductor.target.relative" file="antWrapper.xml"/>
|
---|
35 | <!-- Define the Ant target that is called, and the location (before conref) -->
|
---|
36 | <feature extension="depend.preprocess.conref.pre" value="validateWithJava"/>
|
---|
37 | </plugin>
|
---|
38 |
|
---|
39 | antWrapper.xml imports the new Ant code:
|
---|
40 | <?xml version="1.0" encoding="UTF-8"?>
|
---|
41 | <dummy>
|
---|
42 | <import file="calljava-antcode.xml"/>
|
---|
43 | </dummy>
|
---|
44 |
|
---|
45 | calljava-antcode.xml:
|
---|
46 | <?xml version="1.0" encoding="UTF-8"?>
|
---|
47 | <project default="validateWithJava">
|
---|
48 | <target name="validateWithJava">
|
---|
49 | <java classname="com.example.sampleValidation">
|
---|
50 | <!-- The class was added to dost.class.path (the DITA-OT classpath) -->
|
---|
51 | <classpath refid="dost.class.path"/>
|
---|
52 | </java>
|
---|
53 | </target>
|
---|
54 | </project></codeblock></example>
|
---|
55 | </refbody>
|
---|
56 | </reference>
|
---|