Pollo can be tailored towards editing a certain type of XML file through
the following mechanisms:
These together are combined in a so-called "View Type"
Right after a file is opened, Pollo shows the View Types Dialog. This dialog contains some predefined view types. A view type defines some properties of the new view to be opened: what schema to use, what display specification to use, and what plugins to use. You can also create a temporary view type by manually selecting the schema and display specification to use.The predefined viewtypes are specified in the file
conf/pollo_conf.xml. The basic definition of a view type looks as follows:
<description>Foo Bar files</description>
name should contain a unique name for this view
type. This name is for internal use, it is not shown to the user. The
description contains the name of the view type as
shown to the user. The elements
action-plugins are optional, the other ones are required.
schemas-element contains the definition of the schema to use. Here's an example:
The schema defintion consists of a factory class name and zero or more
init parameters. The following implementations are available:
org.outerj.pollo.xmleditor.schema.BasicSchemaFactory: use this for schemas in Pollo's own schema format. It takes an init parameter
sourcespecifiying the path to the schema file.
org.outerj.pollo.xmleditor.schema.MsvSchemaFactory: use this for schemas in one of the formats supported by MSV (XML Schemas, Relax NG, TREX, Relax core, Relax ns, DTD). The init parameters are:
source: file name for the schema.
type: for DTD's, set this to 'dtd'. Other schema types will be autodetected by MSV and do not require this parameter. If the schema filename has the extension .dtd, it will also be autodetected.
org.outerj.pollo.xmleditor.schema.GenericSchemaFactory: use this if you don't have a schema. All element and attributes lists will then be blank. This one takes no init parameters.
It is possible to implement a completely new schema type by implementing the interfaces ISchema and ISchemaFactory.
It is possible to define more than one schema. These schema's will then
be chained together. This is functionality that's currently not exploited
in Pollo, and remains unverified. In the future, this will allow to combine
e.g. XSLT and HTML to edit XSL files containing HTML tags.
display-specificationselement contains the display specifications to use. Here's an example:
As you can see in the example, two display-specifications are specified.
These are chained together: if the first one doesn't know about an element,
then the next one is queried about it. Since Pollo can't handle the case that
the display specification returns a null, you should always end with a 'GenericDisplaySpecFactory'.
The GenericDisplaySpecFactory can either work in a fixed-color mode, in
which case it always returns the same color to use for elements, or it can
assign values from an internal color table (in which case the same color is
always used for the same element, it is not completely random). For this last
one, supply an init parameter called 'use-random-colors' with the value 'true'.
To use a fixed color, either specify no parameter to use the default color,
or use the parameter 'fixed-color' with as value e.g. '123,233,17' (= the
red, green and blue values).
If you're interested in creating such beasts, take a look at the Cocoon
or Ant examples included in Pollo. The short story is: create both a plugin
(implement IAttributeEditorPlugin or IActionPlugin) and a factory for them
(implement IAttributeEditorPluginFactory or IActionPluginFactory). Multiple
action or attribute editor plugins can be chained. For attribute editor plugins,
this means that if the first one returns null, the next one is asked for an
attribute editor, and so on. For action plugins, all off the action plugins
in the chain will be able to add actions to the plugin menu. Note that API's
of these plugins could change in the future. But then again, everything can
change in the future.