Data items
 Home 

Introduction

Data items in MemoWiki are simple plain-text tagged files which contain named elements which may have content (their value). For example, here is a data item file (red.mtr) that describes the colour Red:

 [itemtype] rgb
 [name] Red
 [r] 1
 [g] 0
 [b] 0

In that file, the first line describes the type of the item (and hence which tags may be found in the file), in this case rgb (Red-Green-Blue format). The second line gives a name for the colour, and the remaining three give the red, green, and blue values for the colour.

The data item file can be linked from a MemoWiki page using the usual notation: [red] (which displays as red and refers to the file red.mtr), in which case clicking on the link will let you view and edit the item, as usual. More powerfully, the data item may be loaded, using a link of the form [red||mtr] – MemoWiki will then load the elements from the data item, and these can then be used individually on the page using entity notation as used in HTML » and XML ». For example, the markup:

 Red has the RGB values: &red:r; &red:g; &red:b;

displays as:

 Red has the RGB values: 1 0 0

This lets you keep important data as a single copy, easily edited, which can then be referred to and used from more than one page or topic.

The format of an entity is:

 &itemname:elementname;

where itemname is the name of the data item, and elementname is the name from a tag in the data item file. Entities may be used anywhere in Wiki page text, and also in the content or options part on MemoWiki links.

By default, the itemname is the full name of the data item. For convenience, a short name can be assigned to the data when the data item is loaded using (for example) name=r as an option on the link. &r:r; could then be used to refer to the r element from that data item.

The elementname in an entity may be indexed by one or more numbers; if it is in a group it must be qualified by the group name (which may also be indexed), as described below. For example, after using name=lm on loading the data item below, &lm:runway.2:length; would display 550 m  (note that the units are included in the substitution).

Indexes are canonicalized (trailing .1s are removed), so &lm:radio.1; and &lm:radio; refer to the same element.

MemoTrove format

The format of data items is called MemoTrove format. It designed to be easy to read and simple to edit, yet is strictly defined so that MemoTrove (mtr) files can be automatically converted to XML files for use by other applications (they can also be read and processed directly, as MemoWiki does). In brief:

Here is an example of a more complex data item:

 ) Experimental data item for Long Marston airfield
 ) Long_Marston_airfield.mtr

 [itemtype] airfield
 [name] Long Marston
 [memo] ~7km SSW of Stratford-upon-Avon

 [licence] unlicenced
 [type] private
 [icao] EGBL

 [lat deg] 52.1376166913
 [lon deg] -1.7547204551
 [alt ft] 154

 [[radio]]
   [callsign] Long Marston Radio
   [freq mhz] 129.825

 [[runway.1]]
   [name] 04/22
   [length m]790
   [surface] tarmac

 [[runway.2]]
   [name] 02/20
   [length m] 550
   [surface] grass

A further feature is worth a mention here: an mtr file can, in effect, modify (be based on) another mtr file using the :copy directive. For example, including the line:

  :copy red.mtr

in another mtr file would cause red.mtr to be loaded at that point. Data from red.mtr might override earlier elements already specified, and may be overridden by later elements. :copy directives are usually placed at the start of the data item.


Data items was last edited on 2014-11-07  
Topic: MemoWiki