plugin-messages.dita 4.0 KB

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