using-dita-properties-file.dita 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE task PUBLIC "-//OASIS//DTD DITA General Task//EN" "generalTask.dtd">
  3. <!-- This file is part of the DITA Open Toolkit project. See the accompanying LICENSE file for applicable license. -->
  4. <task id="using-dita-properties-file">
  5. <title>Setting build parameters with <filepath>.properties</filepath> files</title>
  6. <titlealts>
  7. <navtitle>Using a properties file</navtitle>
  8. </titlealts>
  9. <shortdesc>Usually, DITA builds require setting a number of parameters that do not change frequently. You can
  10. reference a set of build parameters defined in a <filepath>.properties</filepath> file when building output with the
  11. <cmdname>dita</cmdname> command. If needed, you can override any parameter by specifying it explicitly as an
  12. argument to the <cmdname>dita</cmdname> command.</shortdesc>
  13. <prolog>
  14. <metadata>
  15. <keywords>
  16. <indexterm>draft<indexterm><xmlelement>draft</xmlelement></indexterm></indexterm>
  17. <indexterm><xmlelement>required-cleanup</xmlelement></indexterm>
  18. <indexterm><cmdname>dita</cmdname> command<indexterm>.properties file</indexterm></indexterm>
  19. <indexterm>DITA maps<indexterm>properties file</indexterm></indexterm>
  20. <indexterm>.properties file</indexterm>
  21. </keywords>
  22. </metadata>
  23. </prolog>
  24. <taskbody>
  25. <section>
  26. <title>About <filepath>.properties</filepath> files</title>
  27. <p>A <filepath>.properties</filepath> file is a text file that enumerates one or more name-value pairs, one per
  28. line, in the format <codeph>name = value</codeph>. The <filepath>.properties</filepath> filename extension is
  29. customarily used, but is not required.</p>
  30. <ul compact="yes">
  31. <li>Lines beginning with the <codeph>#</codeph> character are comments.</li>
  32. <li>Properties specified as arguments of the <cmdname>dita</cmdname> command override those set in
  33. <filepath>.properties</filepath> files. <note type="restriction">For this reason,
  34. <parmname>args.input</parmname> and <parmname>transtype</parmname> can’t be set in the
  35. <filepath>.properties</filepath> file.</note></li>
  36. <li>If you specify the same property more than once, the last instance is used.</li>
  37. <li>Properties not used by the selected transformation type are ignored.</li>
  38. <li>Properties can reference other property values defined elsewhere in the <filepath>.properties</filepath>
  39. file or passed by the <cmdname>dita</cmdname> command. Use the Ant
  40. <codeph>${<varname>property.name</varname>}</codeph> syntax.</li>
  41. <li>You can set properties not only for the default DITA-OT transformation types, but also for custom plugins.
  42. </li>
  43. </ul>
  44. </section>
  45. <steps>
  46. <step>
  47. <cmd>Create your <filepath>.properties</filepath> file.</cmd>
  48. <info>
  49. <note conref="../resources/conref-task.dita#ID/template-properties"/>
  50. </info>
  51. <stepxmp>
  52. <p>For example:</p>
  53. <p><codeblock outputclass="language-properties normalize-space show-line-numbers show-whitespace"><coderef href="../samples/properties/sequence-html5.properties"/></codeblock>
  54. </p>
  55. </stepxmp>
  56. </step>
  57. <step>
  58. <cmd>Reference your <filepath>.properties</filepath> file with the <cmdname>dita</cmdname> command when building
  59. your output.</cmd>
  60. <stepxmp>
  61. <codeblock><cmdname>dita</cmdname> <parmname>--input</parmname>=<varname>my.ditamap</varname> <parmname>--format</parmname>=<option>html5</option> <parmname>--propertyfile</parmname>=<varname>my.properties</varname></codeblock>
  62. </stepxmp>
  63. <info/>
  64. </step>
  65. <step>
  66. <cmd>If needed, pass additional arguments to the <cmdname>dita</cmdname> command to override specific build
  67. parameters. </cmd>
  68. <stepxmp>
  69. <p>For example, to build output once with <xmlelement>draft</xmlelement> and
  70. <xmlelement>required-cleanup</xmlelement> content:</p>
  71. <codeblock><cmdname>dita</cmdname> <parmname>--input</parmname>=<varname>my.ditamap</varname> <parmname>--format</parmname>=<option>html5</option> <parmname>--propertyfile</parmname>=<varname>my.properties</varname> \
  72. <parmname>--args.draft</parmname>=<option>yes</option></codeblock>
  73. </stepxmp>
  74. <info>
  75. <note conref="../resources/conref-task.dita#ID/pass-input-dir"/>
  76. </info>
  77. </step>
  78. </steps>
  79. </taskbody>
  80. </task>