How to create an input plugin

The first thing to do when creating an input plugin is to decide if you can best achieve your objectives using XSLT or Java. Generally, if your input document is an XML document then you should use XSLT, otherwise you will need to use Java.

Creating an XSLT Plugin

Creating an XSLT plugin is a matter of creating an XSLT stylesheet and registering a copy of the XSLTInputPlugin that will use your stylesheet.

An XSLT plugin has two defining properties. One is the URL of the XSLT file to be used, the other is a property that defines what type of document can be processed by this plugin.

Register the Plugin

Plugins are registered with Forrest2 using the Spring Framework. This means that you need to add an entry to the forrestContext.xml file, such as:

]]>

This input plugin will take an XML source document and process it with the indicated stylesheet. The result is expected to be an document using the internal Forrest2 format.

Creating an Java Plugin

Create a new java project to house your plugin

Create a class file that will be the controller for the plugin.

This should extend the abstact class
org.apache.forrest.core.plugin.AbstractInputPlugin

You must implement the following method:

	public IDocument process(IDocument doc)

The process method should create an instance of an org.apache.forrest.core.document.InternalDocument by performing whatever process is required to generate an internal Forrest document from the source docuemnt.

Register the Plugin

Plugins are registered with Forrest2 using the Spring Framework. This means that you need to add an entry to the forrestContext.xml file, such as:

]]>

The Forrest controller will read all the files that it finds in the classpath that match this naming convention.

      XHTML 2 Simple Sample Page       Hellow World  ";

	public IDocument process(IDocument doc) {
		return new InternalDocument(CONTENT);
	}

	@Override
	public String getInputType() {
		return "http://forrest.apache.org/helloWorld.dtd";
	}
}

Once registered with the InputPluginFactory we can provide an instance of the
org.apache.forrest.test.document.HelloWorldPluginTest class and Forrest will
then use this plugin to produce a new InternalDocument with a simple Hello 
World message.

==============================
How to create an Output Plugin
==============================
]]>