plugin-messages.dita 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
  3. <!-- This file is part of the DITA Open Toolkit project. See the accompanying LICENSE file for applicable license. -->
  4. <task id="plugin-messages" xml:lang="en-US">
  5. <title>Adding new diagnostic messages</title>
  6. <shortdesc>Use the <codeph>dita.xsl.messages</codeph> extension point to add plug-in-specific messages to the
  7. diagnostic messages that are generated by DITA-OT. These messages then can be used by any XSLT override.</shortdesc>
  8. <prolog>
  9. <metadata>
  10. <keywords>
  11. <indexterm><xmlatt>type</xmlatt></indexterm>
  12. <indexterm><xmlatt>id</xmlatt><indexterm>diagnostic messages</indexterm></indexterm>
  13. <indexterm>plug-ins<indexterm>troubleshooting</indexterm></indexterm>
  14. <indexterm>troubleshooting<indexterm>plug-ins</indexterm></indexterm>
  15. <indexterm>XSLT<indexterm>errors</indexterm></indexterm>
  16. <indexterm>preprocessing<indexterm>XSLT</indexterm></indexterm>
  17. </keywords>
  18. </metadata>
  19. </prolog>
  20. <taskbody>
  21. <steps>
  22. <step id="step_create-message-xml">
  23. <cmd>Create an XML file that contains the messages that you want to add. Be sure to use the following format for
  24. the XML file:</cmd>
  25. <info><codeblock outputclass="language-xml normalize-space show-line-numbers show-whitespace">&lt;messages>
  26. <i>&lt;!-- See resources/messages.xml for the details. --></i>
  27. &lt;message id="<varname>Prefix</varname><varname>Number</varname><varname>Letter</varname>" type="<varname>error-severity</varname>">
  28. &lt;reason>Message text&lt;/reason>
  29. &lt;response>How to resolve&lt;/response>
  30. &lt;/message>
  31. &lt;/messages></codeblock>where:
  32. <ul>
  33. <li><varname>Prefix</varname> is a sequence of four capital letters.<note>By convention, the toolkit
  34. messages use <codeph>DOTX</codeph> but any sequence can be used by plug-in developers.</note></li>
  35. <li><varname>Number</varname> is a three-digit integer.</li>
  36. <li><varname>Letter</varname> is one of the following upper-case letters: I, W, E, F. It should match the
  37. value that is specified for the <xmlatt>type</xmlatt> attribute.<note>As the <xmlatt>id</xmlatt> attribute
  38. is used as a whole and not decomposed by recent versions of the toolkit, you could use any sequence as
  39. the message identifier. Nevertheless, to facilitate reuse of the plug-in and make it more readable by
  40. other users, we recommend following these guidelines.</note></li>
  41. <li><varname>error-severity</varname> specifies the severity of the error. It must be one of the following
  42. values:
  43. <dl conkeyref="messages-push/severity-levels">
  44. <dlentry>
  45. <dt/>
  46. <dd/>
  47. </dlentry>
  48. </dl><note>The <codeph>FATAL</codeph> value throws a fatal error message in XSLT and an exception in
  49. Java.</note>
  50. <note type="tip">If the <xmlatt>id</xmlatt> attribute of your message is equal to the <xmlatt>id</xmlatt>
  51. of a default DITA-OT message, your message will override the default one.</note></li>
  52. </ul></info>
  53. </step>
  54. <step>
  55. <cmd>Create a <filepath>plugin.xml</filepath> file that contains the following content:</cmd>
  56. <info>
  57. <codeblock outputclass="language-xml normalize-space show-line-numbers show-whitespace">&lt;plugin id="<varname>plugin-id</varname>">
  58. &lt;feature extension="dita.xsl.messages" file="<varname>file</varname>"/>
  59. &lt;/plugin></codeblock>
  60. <p>where:</p>
  61. <ul>
  62. <li><varname>plugin-id</varname> is the plug-in identifier, for example,
  63. <codeph>com.example.newmsg</codeph>.</li>
  64. <li><varname>file</varname> is the name of the new XML file containing the messages created in step
  65. <xref keyref="plugin-messages/step_create-message-xml"/>, for example,
  66. <filepath>myMessages.xml</filepath>. </li>
  67. </ul>
  68. </info>
  69. </step>
  70. <step>
  71. <cmd>Install the plug-in.</cmd>
  72. </step>
  73. </steps>
  74. <postreq>
  75. <p>Add the following call in XSLT modules to generate a message when a specific condition occurs:</p>
  76. <codeblock outputclass="language-xml normalize-space show-line-numbers show-whitespace">&lt;xsl:call-template name="output-message">
  77. &lt;xsl:with-param name="id"><varname>prefix</varname><varname>number</varname><varname>letter</varname>&lt;/xsl:with-param>
  78. &lt;xsl:with-param name="msg">Message text and parameters.&lt;/xsl:with-param>
  79. &lt;/xsl:call-template></codeblock>
  80. <p>Use the <codeph>ctx</codeph> parameter if calling from a function.</p>
  81. </postreq>
  82. </taskbody>
  83. </task>