plugin-newextensions.dita 7.4 KB

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