implement-saxon-customizations.dita 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE topic PUBLIC "-//OASIS//DTD DITA Topic//EN" "topic.dtd">
  3. <!-- This file is part of the DITA Open Toolkit project. See the accompanying LICENSE file for applicable license. -->
  4. <topic id="implement-saxon-customizations">
  5. <title>Adding Saxon customizations</title>
  6. <shortdesc>Plug-ins can contribute XSLT extension functions and collation URI resolvers. These customizations are
  7. automatically configured to work with Saxon when transformations are run using the DITA-OT
  8. <xmlelement>pipeline</xmlelement> task with custom XSLT.</shortdesc>
  9. <prolog>
  10. <metadata>
  11. <keywords>
  12. <indexterm>Saxon
  13. <indexterm><xmlelement>service</xmlelement></indexterm></indexterm>
  14. <indexterm>Ant
  15. <indexterm><xmlelement>jar</xmlelement></indexterm></indexterm>
  16. <indexterm>Ant
  17. <indexterm><xmlelement>pipeline</xmlelement></indexterm></indexterm>
  18. <indexterm>Ant
  19. <indexterm><xmlelement>xslt</xmlelement></indexterm></indexterm>
  20. <indexterm>Saxon
  21. <index-see-also>Ant</index-see-also></indexterm>
  22. <indexterm>Ant
  23. <index-see-also>Saxon</index-see-also></indexterm>
  24. <indexterm>I18N
  25. <indexterm>plug-in</indexterm></indexterm>
  26. <indexterm>plug-ins
  27. <indexterm>Saxon</indexterm></indexterm>
  28. <indexterm>XSLT
  29. <indexterm>Saxon</indexterm></indexterm>
  30. <indexterm>preprocessing
  31. <indexterm>extension points, Saxon</indexterm></indexterm>
  32. <indexterm>Java
  33. <indexterm>ServiceLoader</indexterm></indexterm>
  34. </keywords>
  35. </metadata>
  36. </prolog>
  37. <body>
  38. <p>Plug-ins can provide the following Saxon extensions:
  39. <ul>
  40. <li>Extension functions</li>
  41. <li>Collation URI resolvers</li>
  42. </ul></p>
  43. <p>Extensions are declared in plug-in-provided JAR files using the Java ServiceLoader feature that looks for
  44. service-declaring files in JAR files and loads classes. This requires adding one or more files in the
  45. <filepath>META-INF/services</filepath> directory in plug-in-provided JAR files.</p>
  46. <p>You can create the file manually or generate it dynamically using <xmlelement>service</xmlelement> elements in
  47. Ant <xmlelement>jar</xmlelement> tasks. See the topics for the different extension types for details.</p>
  48. <p>These extensions use the DITA Open Toolkit Ant <xmlelement>pipeline</xmlelement> element to wrap
  49. <xmlelement>xslt</xmlelement> elements. You can do this in plug-ins as shown in this excerpt from the DITA
  50. Community I18N plugin’s <filepath>build.xml</filepath>
  51. file:<codeblock outputclass="language-xml">&lt;target name="org.dita-community.i18n-saxon-extension-test">
  52. &lt;pipeline message="Test the DITA Community i18n Saxon extension functions"
  53. taskname="i18n-extension-function-test">
  54. &lt;xslt
  55. in="${dita.plugin.org.dita-community.i18n.dir}/test/xsl/data/test-data.xml"
  56. style="${dita.plugin.org.dita-community.i18n.dir}/test/xsl/test-extension-functions.xsl"
  57. out="${basedir}/out/extension-function-test-results.xml"
  58. >
  59. &lt;/xslt>
  60. &lt;/pipeline>
  61. &lt;/target></codeblock></p>
  62. <p>Normal XSLT extensions to built-in transformation types will automatically have the extensions available to
  63. them.</p>
  64. <p>The dynamic Saxon configuration is implemented in the class <codeph>org.dita.dost.module.XsltModule</codeph>,
  65. which backs the <xmlelement>pipeline</xmlelement>/<xmlelement>xslt</xmlelement> element.</p>
  66. <p> </p>
  67. </body>
  68. </topic>