Contents | Parent Topic | Previous Topic | Next Topic
Home | Catalog

# 1.8. Creating a New Format Driver

## 1.8.1. Overview

The steps are:

1. Pick an existing driver to copy.
2. Copy it.
3. Make the necessary changes.
4. Update the `sdf.ini` file in the bin directory.

Simple, really! :-)

Good drivers to start from are `totxt.pl`, `tohtml.pl` and `tomif.pl`. The drivers can be found in the perllib/sdf directory of the SDF distribution.

## 1.8.2. Required Skills

The following skills are required to write a format driver:

1. Good knowledge of the target format.
2. Perl programming.

It also helps if one has a look at SDFAPI before beginning.

## 1.8.3. Driver Architecture Overview

An SDF driver interacts with the core SDF system as follows:

1. The `sdf.ini` file configures SDF so that the relevant driver is loaded and called, when necessary.
2. Each driver is implemented by a single subroutine which is responsible for initialising itself, processing the input, finalising things and returning the output.
3. The input should be processed by:
   1. calling the SdfNextPara routine within a while loop
   2. for each paragraph, calling the SdfNextSection routine within a while loop.

## 1.8.4. Some General Comments

If you are considering writing a driver, it might be a good idea to let people on the SDF mailing lists know. If you're lucky, someone else might have started a driver for the same output format or be willing to assist you develop a new one. Likewise, if you're having problems, send email to sdf-bugs@mincom.com. Chances are, an SDF guru will try to help.

As a rule, it is a good idea to use configuration files to define the mappings from SDF entities to target entities. In this way, people can override the default mappings without changing your driver.

Depending on your skills, the amount of changes you need to make, and your knowledge of SDF, the driver can take anything from 10 minutes to 10 weeks. Good luck. :-)