antditadita-ot

Pass Command Line arguments to Apache Ant build file from DITAOT custom plugin


I am trying to build a very basic custom html5 plugin for dita-ot. Below is my current setup. Here is my plugin.xml file.

plugin.xml

<plugin id="html5-test" version="3.6.1">        
    <transtype name="html5-test" desc="testing html5 transformation with current setup." >
        <param name="args.artlbl" desc="Specifies whether to generate a label for each image;" type="enum">
            <val>yes</val>
            <val default="true">no</val>
          </param>
    </transtype>
    

    <feature extension="ant.import" file="build.xml" />
</plugin>

Here is build.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:if="ant:if" xmlns:unless="ant:unless" name="dita2html5-test" default="get-parameters">
<target name="get-parameters">
    <echoproperties/>
    <!-- here I want to access CLI arguments for further use. --!>
    <echo message="print value:${args.artlbl}"/>
</target>

the console only shows text and no value. I was expecting to see "no" there as it is default value. Ultimate goal is to get CLI arguments inside transtype tag and then pass them to build.xml. After that add this to properties and then use inside ant xslt task.


Solution

  • So finally I figured it out.

    dita -f html5 -i /test.dita -Done=abc
    

    will pass "one" as a parameter to the build.xml file. In build.xml file you will access the argument by following. No changes needed in plugin.xml file.

    <?xml version="1.0" encoding="UTF-8"?>
    <project xmlns:if="ant:if" xmlns:unless="ant:unless" name="dita2html5-test" default="get-parameters">
    <target name="get-parameters">
        <echo>Embed another1:${one}</echo>
        <echo message="print value:${args.artlbl}"/>
    </target>