plugin-newextensions.dita 8.5 KB

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