Detailing the markups used to define resources related to data.
Data Sources are usually a reference to a Database, but may also include other forms of data, including CGI, Data Files, and RAM/temporary. Internally, all sources are represented as a DBI handle (Perl's standard DataBase Interface), and Non-Database sources are represented using techniques such as the DBD::RAM module.
Data Sources are defined using the <SOURCE> markup, which requires two properties to be defined; the NAME of the source, which is an identifier used to reference this source, and the TYPE of the source. Additional properties can be defined (and some are required) as additional markups within a <SOURCE> markup.
The currently supported source types include:
Here's some quickie examples of complete Source definitions:
<SOURCE NAME="mysource" TYPE="datafile"> <FILE>data/thedata.dat</FILE> <KEY>Bill</KEY> </SOURCE>
<SOURCE NAME="mysource" TYPE="mysql"> <USER>bingle</USER> </SOURCE>
Data Views, as the name implies, is a view of some data within a source. More specifically, this data, which is stored in a source, consists of a number of named fields, and a number of records, consisting of values for those fields. Most views are simply references to tables within a database, or a similar structure from non-database sources.
Data Views are defined using the <VIEW> markup, which requires at least the view NAME to be defined. A Source is also required, which can be specified either using the SOURCE parameter to the <VIEW> markup, or by defining the view inside a Source definition, effectively implying that parent source for the view.
Views also require a list of fields to be specified, using the <FIELDS> markup within a <VIEW> markup. The field names are comma-delimited.
Here's some quickie examples of complete View definitions:
<VIEW NAME="People" SOURCE="Fred"> <FIELDS>ID,name,address,phone,email</FIELDS> </VIEW>
<SOURCE NAME="fields" TYPE="datafile"> <FILE>db.fields</FILE> <KEY>name</KEY> <VIEW NAME="fields"> <FIELDS>title,name,type,other,help</FIELDS> </VIEW> </SOURCE>
A Record is a collection of fields, used to temporarily store values.
Records are often used to store the results of a query to a View, and as such may consist of the same fields as a view, but there is no enforced correlation. For example, a more complex record may contain select fields from several views, and the data of the one record may be populated by a join across several Views.
The Fields within a record can contain specific properties, which dictate the formatting of the fields in different circumstances, as well as the type of data they can store. The most important setting for each Field is the field type. Once a type is set, further properties can be customised.
Records are defined using the <RECORD> markup, which requires the record NAME to be defined.
Records also require a list of fields to be specified, using the <FIELDS> markup within a <VIEW> markup. The field names are comma-delimited. A special View containing the types and parameters for each field can be specified using the DETAILS option to <FIELDS>.
The syntax to reference a particular field is:
[record.]field[.method]
If a record is not specified, then the default record is assumed. If a method is not specified, then the
default method is assumed (more on methods later).
To include the value of a field anywhere in a document,
preceed the field specification by a $ symbol. ie;
$[record.]field[.method]
If it isn't clear within the flow of the document what the field specifier is, the whole field specifier
can be enclosed in braces ({ and }) to clarify it. ie;
${[record.]field[.method]}
As a general rule, preceeding a Field specification by a $ will substitute the value stored in that field before further processing. As such, the value of a field can be used within the normal document, and within the arguments of the custom EDO markups. Some EDO markups specifically want the name of the field, not its value, and so the field specification is required without the $.
By default, a Field is of type "string", with a formatted size of "30" and a maximum size of "255". Properties of fields can be defined in a View and referenced when creating a Record, or can be altered using the <ALTER> tag, which takes as arguments the FIELD to alter, and the name of the property to alter. All fields have some common properties (including TYPE), but different types of fields can have different properties.
Here's some quickie examples of Record definitions:
<RECORD NAME="People"> <FIELDS DETAILS="fields">ID,name,address,phone,email</FIELDS> </RECORD>
<RECORD NAME="People"> <FIELDS>ID,name,address,phone,email</FIELDS> </RECORD> <ALTER FIELD="People.ID" TYPE="int"> <ALTER FIELD="People.address" TYPE="text"> <ALTER FIELD="People.email" SIZE="60">