plugin-messages.dita 4.8 KB

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