Friday, October 30, 2009

How to create a DITA OT plugin

When you use DITA OT to publish your DITA content, you might need to customize DITA OT XSL transformation. To make your DITA OT changes portable, you can create a DITA OT plugin.

To create a plugin, you need to first create one or more new or overridden templates xslt files, second create a plugin.xml file to point to your xslt files, and then install this plug-in to your DITA OT.

To create templates

  1. Create a folder in dita-ot/demo to store your plug-in, such as my-plugin.
  2. Create a folder to store your xslt files in dita-ot/demo/my-plugin, such as xsl.
  3. Create a new xslt file to contain the template. It's better that one xslt file only include one function.

To create plugin.xml

  1. Copy a plugin.xml file from any existing plugins into dita-ot/demo/my-plugin.
  2. If there are more than one <feature> elements, delete the rest and only keep one <feature>.
  3. Change the value in the remaining element to point to your new xslt files, separated by commas: &lt; feature extension="dita.xsl.xml" value="xsl/yourxslt1.xsl,xsl.yourxslt2.xsl" type="file" / >

To install your plugin

  1. In your dita-ot folder, run startcmd.bat.
  2. In the cmd.exe window, type: ant -f integrator.xml.

The plugin that you have created can be easily packed and installed once you upgrade your DITA OT, or pass to others.

3 comments:

denisb said...

Lisha, I'm very grateful to you for posting this topic. I've been trying to create a simple plug-in by following the OT documentation, with no luck.

The OT doc has lots of concept and reference information, but not much in the way of procedures or examples. Your simple procedure showed me the step I was missing: running the integration.

As a long-time DocBook user, I'm spoiled by its great documentation and community support. Learning DITA would be a lot easier if there were more users like you sharing their knowledge.

Thanks very much,
Denis

Anonymous said...

I was missing the final part of setting up the plugin. Thanks for putting up your steps, it was helpful!

Hibou57 said...

The “final part” mentionned above, actually is mentionned too in the DITA-OT documentation. See UserGuid ‑> Developer Reference ‑> Installing DITA‑OT plug‑ins.

There's also another tutorial on the topic of overriding default transformations and styles:
http://www.scriptorium.com/whitepapers/hackingot/index.html

Have a nice time :)
With thanks to Lisha Li