using-dita-properties-file.dita 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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
  17. <indexterm><xmlelement>draft</xmlelement></indexterm></indexterm>
  18. <indexterm><xmlelement>required-cleanup</xmlelement></indexterm>
  19. <indexterm><cmdname>dita</cmdname> command
  20. <indexterm>.properties file</indexterm></indexterm>
  21. <indexterm>DITA maps
  22. <indexterm>properties file</indexterm></indexterm>
  23. <indexterm>.properties file</indexterm>
  24. </keywords>
  25. </metadata>
  26. </prolog>
  27. <taskbody>
  28. <section>
  29. <title>About <filepath>.properties</filepath> files</title>
  30. <p>A <filepath>.properties</filepath> file is a text file that enumerates one or more name-value pairs, one per
  31. line, in the format <codeph>name = value</codeph>. The <filepath>.properties</filepath> filename extension is
  32. customarily used, but is not required.</p>
  33. <ul compact="yes">
  34. <li>Lines beginning with the <codeph>#</codeph> character are comments.</li>
  35. <li>Properties specified as arguments of the <cmdname>dita</cmdname> command override those set in
  36. <filepath>.properties</filepath> files. <note type="restriction">For this reason,
  37. <parmname>args.input</parmname> and <parmname>transtype</parmname> can’t be set in the
  38. <filepath>.properties</filepath> file.</note></li>
  39. <li>If you specify the same property more than once, the last instance is used.</li>
  40. <li>Properties not used by the selected transformation type are ignored.</li>
  41. <li>Properties can reference other property values defined elsewhere in the <filepath>.properties</filepath>
  42. file or passed by the <cmdname>dita</cmdname> command. Use the Ant
  43. <codeph>${<varname>property.name</varname>}</codeph> syntax.</li>
  44. <li>You can set properties not only for the default DITA-OT transformation types, but also for custom plugins.
  45. </li>
  46. </ul>
  47. </section>
  48. <steps>
  49. <step>
  50. <cmd>Create your <filepath>.properties</filepath> file.</cmd>
  51. <info>
  52. <note conkeyref="conref-task/template-properties"/>
  53. </info>
  54. <stepxmp>
  55. <p>For example:</p>
  56. <p><codeblock outputclass="language-properties normalize-space show-line-numbers show-whitespace"><coderef href="../samples/properties/sequence-html5.properties"/></codeblock>
  57. </p>
  58. </stepxmp>
  59. </step>
  60. <step>
  61. <cmd>Reference your <filepath>.properties</filepath> file with the <cmdname>dita</cmdname> command when building
  62. your output.</cmd>
  63. <stepxmp>
  64. <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>
  65. </stepxmp>
  66. <info/>
  67. </step>
  68. <step>
  69. <cmd>If needed, pass additional arguments to the <cmdname>dita</cmdname> command to override specific build
  70. parameters. </cmd>
  71. <stepxmp>
  72. <p>For example, to build output once with <xmlelement>draft</xmlelement> and
  73. <xmlelement>required-cleanup</xmlelement> content:</p>
  74. <codeblock><cmdname>dita</cmdname> <parmname>--input</parmname>=<varname>my.ditamap</varname> <parmname>--format</parmname>=<option>html5</option> <parmname>--propertyfile</parmname>=<varname>my.properties</varname> \
  75. <parmname>--args.draft</parmname>=<option>yes</option></codeblock>
  76. </stepxmp>
  77. <info>
  78. <note conkeyref="conref-task/pass-input-dir"/>
  79. </info>
  80. </step>
  81. </steps>
  82. </taskbody>
  83. </task>