plugin-newextensions.dita 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE reference PUBLIC "-//OASIS//DTD DITA Reference//EN" "reference.dtd">
  3. <!-- This file is part of the DITA Open Toolkit project. See the accompanying LICENSE file for applicable license. -->
  4. <reference id="plugin-newextensions" xml:lang="en-US">
  5. <title>Creating a new plug-in extension point</title>
  6. <shortdesc>If your plug-in needs to define its own extension point in an XML file, add the string
  7. "<codeph>_template</codeph>" to the filename before the file suffix. When the plug-in is installed, this file will
  8. be processed like the built-in DITA-OT templates.</shortdesc>
  9. <prolog>
  10. <metadata>
  11. <keywords>
  12. <indexterm><xmlelement>template</xmlelement></indexterm>
  13. <indexterm><xmlelement>dita:extension</xmlelement></indexterm>
  14. <indexterm><xmlelement>pathelement</xmlelement></indexterm>
  15. <indexterm><xmlelement>xsl:import</xmlelement></indexterm>
  16. <indexterm><xmlatt>id</xmlatt>
  17. <indexterm>plug-in</indexterm></indexterm>
  18. <indexterm><xmlatt>behavior</xmlatt></indexterm>
  19. <indexterm><xmlatt>dita:extension</xmlatt></indexterm>
  20. <indexterm>plug-ins
  21. <indexterm>extension points</indexterm></indexterm>
  22. <indexterm>extension points
  23. <indexterm>creating</indexterm></indexterm>
  24. <indexterm>XSLT
  25. <indexterm>extension points</indexterm></indexterm>
  26. <indexterm>preprocessing
  27. <indexterm>XSLT</indexterm></indexterm>
  28. <indexterm>metadata
  29. <indexterm>plug-in</indexterm></indexterm>
  30. <indexterm>catalog</indexterm>
  31. </keywords>
  32. </metadata>
  33. </prolog>
  34. <refbody>
  35. <section>
  36. <p>Template files are used to integrate most DITA-OT extensions. For example, the
  37. <filepath>dita2xhtml_template.xsl</filepath> file contains all of the default rules for converting DITA topics
  38. to XHTML, along with an extension point for plug-in extensions. When the plug-in is installed, the
  39. <filepath>dita2xhtml.xsl</filepath> is recreated, and the extension point is replaced with references to all
  40. appropriate plug-ins.</p>
  41. <p>To mark a new file as a template file, use the <xmlelement>template</xmlelement> element.</p>
  42. <p>The template extension namespace has the URI <codeph>http://dita-ot.sourceforge.net</codeph>. It is used to
  43. identify elements and attributes that have a special meaning in template processing. This documentation uses the
  44. <codeph>dita:</codeph> prefix to refer to elements in the template extension namespace. However, template
  45. files are free to use any prefix, provided that there is a namespace declaration that binds the prefix to the
  46. URI of the template extension namespace. </p>
  47. </section>
  48. <section>
  49. <title><xmlelement>dita:extension</xmlelement> element</title>
  50. <p>The <xmlelement>dita:extension</xmlelement> elements are used to insert generated content during the plug-in
  51. installation process. There are two required attributes:</p>
  52. <ul>
  53. <li>The <xmlatt>id</xmlatt> attribute defines the extension point ID that provides the argument data.</li>
  54. <li>The <xmlatt>behavior</xmlatt> attribute defines which processing action is used.</li>
  55. </ul>
  56. <p>Supported values for the <xmlatt>behavior</xmlatt> attribute:</p>
  57. <parml>
  58. <plentry>
  59. <pt><codeph>org.dita.dost.platform.CheckTranstypeAction</codeph></pt>
  60. <pd>Create Ant condition elements to check if the <codeph>${transtype}</codeph> property value equals a
  61. supported transformation type value.</pd>
  62. </plentry>
  63. <plentry>
  64. <pt><codeph>org.dita.dost.platform.ImportAntLibAction</codeph></pt>
  65. <pd>Create Ant <xmlelement>pathelement</xmlelement> elements for the
  66. <xref keyref="plugin-javalib">library import extension point</xref>. The <xmlatt>id</xmlatt> attribute is
  67. used to define the extension point ID.</pd>
  68. </plentry>
  69. <plentry>
  70. <pt><codeph>org.dita.dost.platform.ImportPluginCatalogAction</codeph></pt>
  71. <pd>Include plug-in metadata catalog content.</pd>
  72. </plentry>
  73. <plentry>
  74. <pt><codeph>org.dita.dost.platform.ImportPluginInfoAction</codeph></pt>
  75. <pd>Create plug-in metadata Ant properties.</pd>
  76. </plentry>
  77. <plentry>
  78. <pt><codeph>org.dita.dost.platform.ImportStringsAction</codeph></pt>
  79. <pd>Include plug-in string file content based on the
  80. <xref keyref="plugin-addgeneratedtext">generated text extension point</xref>. The <xmlatt>id</xmlatt>
  81. attribute is used to define the extension point ID.</pd>
  82. </plentry>
  83. <plentry>
  84. <pt><codeph>org.dita.dost.platform.ImportXSLAction</codeph></pt>
  85. <pd>Create <xmlelement>xsl:import</xmlelement> elements based on the
  86. <xref keyref="plugin-overridestyle">XSLT import extension point</xref>. The <xmlatt>id</xmlatt> attribute is
  87. used to define the extension point ID.</pd>
  88. </plentry>
  89. <plentry>
  90. <pt><codeph>org.dita.dost.platform.InsertAction</codeph></pt>
  91. <pd>Include plug-in conductor content based on the
  92. <xref keyref="plugin-anttarget">Ant import extension point</xref>. The <xmlatt>id</xmlatt> attribute is used
  93. to define the extension point ID.</pd>
  94. </plentry>
  95. <plentry>
  96. <pt><codeph>org.dita.dost.platform.InsertAntActionRelative</codeph></pt>
  97. <pd>Include plug-in conductor content based on the
  98. <xref keyref="plugin-anttarget">relative Ant import extension point</xref>. The <xmlatt>id</xmlatt>
  99. attribute is used to define the extension point ID.</pd>
  100. </plentry>
  101. <plentry>
  102. <pt><codeph>org.dita.dost.platform.InsertCatalogActionRelative</codeph></pt>
  103. <pd>Include plug-in catalog content based on the
  104. <xref keyref="plugin-xmlcatalog">catalog import extension point</xref>. The <xmlatt>id</xmlatt> attribute is
  105. used to define the extension point ID.</pd>
  106. </plentry>
  107. <plentry>
  108. <pt><codeph>org.dita.dost.platform.ListTranstypeAction</codeph></pt>
  109. <pd>Create a pipe-delimited list of supported transformation types.</pd>
  110. </plentry>
  111. </parml>
  112. </section>
  113. <section id="section_vfc_gvw_mg">
  114. <title><xmlatt>dita:extension</xmlatt> attribute</title>
  115. <p>The <xmlatt>dita:extension</xmlatt> attribute is used to process attributes in elements which are not in the
  116. template extension namespace. The value of the attribute is a space-delimited tuple, where the first item is the
  117. name of the attribute to process and the second item is the action ID.</p>
  118. <p>Supported values:</p>
  119. <parml>
  120. <plentry>
  121. <pt><codeph>depends org.dita.dost.platform.InsertDependsAction</codeph></pt>
  122. <pd>The Ant target dependency list is processed to replace all target names that start with an opening brace
  123. <codeph>{</codeph> character and end with a closing brace <codeph>}</codeph>. The value of the extension
  124. point is the ID between the braces.</pd>
  125. </plentry>
  126. </parml>
  127. </section>
  128. <example>
  129. <title>Example</title>
  130. <p>The following plug-in defines <filepath>myBuildFile_template.xml</filepath> as a new template for extensions,
  131. and two new extension points.</p>
  132. <codeblock outputclass="language-xml normalize-space show-line-numbers show-whitespace">&lt;plugin id="com.example.new-extensions">
  133. &lt;extension-point id="com.example.new-extensions.pre"
  134. name="Custom target preprocess"/>
  135. &lt;extension-point id="com.example.new-extensions.content"
  136. name="Custom target content"/>
  137. &lt;template file="myBuildFile_template.xml"/>
  138. &lt;/plugin></codeblock>
  139. <p>When the plug-in is installed, this will be used to recreate <filepath>myBuildFile.xml</filepath>, replacing
  140. Ant file content based on extension point use.</p>
  141. <codeblock outputclass="language-xml normalize-space show-line-numbers show-whitespace">&lt;project xmlns:dita="http://dita-ot.sourceforge.net">
  142. &lt;target name="dita2custom"
  143. dita:depends="dita2custom.init,
  144. {com.example.new-extensions.pre},
  145. dita2xhtml"
  146. dita:extension="depends org.dita.dost.platform.InsertDependsAction">
  147. &lt;dita:extension id="com.example.new-extensions.content"
  148. behavior="org.dita.dost.platform.InsertAction"/>
  149. &lt;/target>
  150. &lt;/project></codeblock>
  151. </example>
  152. </refbody>
  153. </reference>