implement-saxon-customizations.dita 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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<indexterm><xmlelement>service</xmlelement></indexterm></indexterm>
  13. <indexterm>Ant<indexterm><xmlelement>jar</xmlelement></indexterm></indexterm>
  14. <indexterm>Ant<indexterm><xmlelement>pipeline</xmlelement></indexterm></indexterm>
  15. <indexterm>Ant<indexterm><xmlelement>xslt</xmlelement></indexterm></indexterm>
  16. <indexterm>Saxon<index-see-also>Ant</index-see-also></indexterm>
  17. <indexterm>Ant<index-see-also>Saxon</index-see-also></indexterm>
  18. <indexterm>I18N<indexterm>plug-in</indexterm></indexterm>
  19. <indexterm>plug-ins<indexterm start="plugins-saxon">Saxon</indexterm></indexterm>
  20. <indexterm>XSLT<indexterm>Saxon</indexterm></indexterm>
  21. <indexterm>preprocessing<indexterm>extension points, Saxon</indexterm></indexterm>
  22. <indexterm>Java<indexterm>ServiceLoader</indexterm></indexterm>
  23. </keywords>
  24. </metadata>
  25. </prolog>
  26. <body>
  27. <p>Plug-ins can provide the following Saxon extensions:
  28. <ul>
  29. <li>Extension functions</li>
  30. <li>Collation URI resolvers</li>
  31. </ul></p>
  32. <p>Extensions are declared in plug-in-provided JAR files using the Java ServiceLoader feature that looks for
  33. service-declaring files in JAR files and loads classes. This requires adding one or more files in the
  34. <filepath>META-INF/services</filepath> directory in plug-in-provided JAR files.</p>
  35. <p>You can create the file manually or generate it dynamically using <xmlelement>service</xmlelement> elements in
  36. Ant <xmlelement>jar</xmlelement> tasks. See the topics for the different extension types for details.</p>
  37. <p>These extensions use the DITA Open Toolkit Ant <xmlelement>pipeline</xmlelement> element to wrap
  38. <xmlelement>xslt</xmlelement> elements. You can do this in plug-ins as shown in this excerpt from the DITA
  39. Community I18N plugin’s <filepath>build.xml</filepath>
  40. file:<codeblock outputclass="language-xml">&lt;target name="org.dita-community.i18n-saxon-extension-test">
  41. &lt;pipeline message="Test the DITA Community i18n Saxon extension functions"
  42. taskname="i18n-extension-function-test">
  43. &lt;xslt
  44. in="${dita.plugin.org.dita-community.i18n.dir}/test/xsl/data/test-data.xml"
  45. style="${dita.plugin.org.dita-community.i18n.dir}/test/xsl/test-extension-functions.xsl"
  46. out="${basedir}/out/extension-function-test-results.xml"
  47. >
  48. &lt;/xslt>
  49. &lt;/pipeline>
  50. &lt;/target></codeblock></p>
  51. <p>Normal XSLT extensions to built-in transformation types will automatically have the extensions available to
  52. them.</p>
  53. <p>The dynamic Saxon configuration is implemented in the class <codeph>org.dita.dost.module.XsltModule</codeph>,
  54. which backs the <xmlelement>pipeline</xmlelement>/<xmlelement>xslt</xmlelement> element.</p>
  55. <p> </p>
  56. </body>
  57. </topic>