ERtool

The first component of ERW you will have to deal with is ERtool, which is responsible for analysing ERL files, checking the consistency of the entity-relationship schemata they describe, and produce various outputs depending on the options you specified.

ERtool is a Java™ (version 1.4 or greater) application, and as such comes in the form of a Java archive, a file containing a number of Java classes in compressed form. The Java archive of ERW is, not surprisingly, named erw.jar. When you want to recall ERtool, you must be sure that the archive is installed in the extension directory, or that you provide suitable options to Java, or that you set the $CLASSPATH environment variable, so that it can find the class.

Said that, ERtool is a Java class whose complete path is it.unimi.dsi.erw.ERtool. Thus, you can invoke it with java it.unimi.dsi.erw.ERtool <filename, since it expects to read an ERL file from standard input. The archive erw.jar contains also a Java manifest that allows you to run ERtool just with java -jar erw.jar <filename.

As a commodity, a command named ertool (a script shell that invokes the Java class) is also provided. It takes the same arguments as the Java class.

After searching for the ERL DTD in the current directory, ERtool looks in /usr/share/ERW/dtd and finally at the directory defined by the Java property it.unimi.dsi.erw.dtddir; this property is automatically set by the ertool command using the content of the ERW_DTD_DIR environment variable. Indeed, setting this variable is the easiest way to guarantee that the ERL DTD will be available. You can also set the variable manually, using, for instance, java -jar erw.jar -Dit.unimi.dsi.erw.dtddir=directory <filename.

Warning

A common problem with running ERtool is that it cannot find the ERL Document Type Definition (DTD). Often setting up an SGML/XML system is not so easy, so the simplest thing to do is to put everything in /usr/share/ERW/dtd, or to be sure that the current directory contains all DTD-related files when running ERtool (you can copy them or create symbolic links), or set up correctly ERW_DTD_DIR.

Options

Without options, ERtool will simply read an ERL file from standard input and check it for syntactic and semantic errors. However, there are a number of options that will select a back-end and produce useful output:

--sql

Activates the SQL back-end. The entity-relationship schema is reified, and complete SQL code creating all necessary tables is printed to standard output. This code can be saved or even directly piped into a database client.

--defs

Activates the definition back-end. A number of PHP files will be created in the current directory, one for each entity type, relationship type, and for each instance of fileset or dynamic enumerative type. These files should be moved in a place accessible to the run-time environment.

--defs-utf-8

As above, but instead of using the standard PHP encoding (ISO-8859-1), definition files will be output in UTF-8 encoding. This is essential if you are using the UTF-8 support.

--forms form1 form2

Activates the forms back-end. For each form specified (an ERF file), a corresponding PHP file coding the form will be produced. These files should be moved in a place accessible to the run-time environment.

--forms-utf-8

As above, but instead of using the standard PHP encoding (ISO-8859-1), forms will be output in UTF-8 encoding. This is essential if you are using the UTF-8 support.

--default-forms

Outputs default forms (embedded and non-embedded) for all types in the schema. Compiling those forms and installing the resulting PHP files would not modify ERW behaviour, as they are equivalent to the run-time environment generated default form. However, you can modify them to produce custom forms.

--doc

Activates the documentation back-end. A DocBook 4.1.2 XML file commenting in detail the entity-relationship schema and the reification process will be printed on standard output. You can then easily convert it to your preferred format.

--dot

Activates the DOT language back-end. The output can be formatted using the dot utility from the GraphViz suite of tools. More details can be found in the Section called The DOT graphical back-end.

--i18n type

Activates the internationalisation back-end. The output is a gettext template file that contains all the attributes and leg labels (if type is label), all the labels of static enumerative types (if type is enum) or all the help strings (if type is help). The file can be then used for translations or manipulated with standard gettext commands. See the Chapter called Localisation.