The Form Definition Files.



next up previous
Next: About this document Up: WDB Poster (ADASS'94) Previous: Flow of Control

The Form Definition Files.

One of the goals of WDB was to provide an easy - yet flexible - way to make database information available. In the simple case no coding should be necessary. However if special behavior is needed it should be possible to add it - without changing the core system. Also if some special behavior has been defined for one field in a form it should be easy to reuse this in other forms.
As examples of such special behavior can be mentioned :

( Some of these conversions can be implemented using database views, however this usually makes it either impossible or very inefficient to search on the corresponding field. )
The way this is obtained in WDB is by using Form Definition Files (fdfs). When a new query form has to be added to the system all that is needed is to create a new fdf file specifying what fields should be in the form and how they should be presented to the user.
ßForm attributes

An fdf is composed of a set of form attributes, and a set of field attributes for each field in the form. Examples of form attributes include :

ßField attributes

Field attributes describe how to find the field in the database and how to present it to the user. Examples of field attributes include :

    { }columnx

    FIELD
    Field identifier. Used internally to uniquely identify a field.
    label
    Label/title in forms etc.
    column
    Database column definition. Defaults to the value of FIELD. values can include Sybase computed fields, and table-names.
    type
    Database type of field [ int | char | datetime | ...].
    length
    Length of field including formatting etc.

A whole lot of other attributes can be added to the fdf if needed. For example a 'url' attribute can be added if the field should have a hypertext link. - Or converters could be added to specify how data from the database should be converted to what is to be presented to the user (the 'from_db' attribute), - or how the text entered by the user should be converted to what actually should be searched for in the database (the 'to_db' attribute).
The conversions are expressed using the very powerful Perl language. In fact WDB was coded entirely in Perl, with a few extensions to enable access to Sybase.

ßExample of a Form Definition Files.

The following fdf file demonstrates several of the features of WDB.

NAME       = preprints
TITLE      = ESO Preprints Database
DATABASE   = library
TABLE      = preprint
ORDER      = authors
DOCURL     = /eso/preprint.html
RECTOP     = $val{'title'}
COMMENTS_TO= malbrech@eso.org
PERL       = require "eso_util.pl";	# Include extra perl functions 
#------------------------------------
FIELD      = date
label      = Received
type       = int
length     = 10
from_db    = &cvdatein( $val{'date'}, "DD MMM YY" );
to_db      = &cvdateout( $val );
default    = '>01-Jan-'.`date +%y` 
no_tab

FIELD      = authors
label      = Authors
type       = char
length     = 255
tablen     = 20
from_db    = &textohtml($val{'authors'})

FIELD      = title
label      = Title
type       = char
length     = 255
from_db    = "<em>".&textohtml($val{'title'})."</em>"
url        = "$WDB/eso/$form{'NAME'}/query/".&cgi_encode($val{'title'})
no_full
key

FIELD      = reference
label      = Reference
from_db    = "$val{'institute'}, <em>$val{'numb'}</em>"
computed
no_tab
no_query

FIELD      = institute
column     = inst
label      = Institute
type       = char
length     = 255
no_tab
no_full

FIELD      = numb
type       = char
hidden



next up previous
Next: About this document Up: WDB Poster (ADASS'94) Previous: Flow of Control



Bo Frese Rasmussen
Fri Nov 25 16:28:57 MET 1994