matrixdef File Syntax

The file matrixdef defines the Matrix customization web interface, specifically the form fields that appear, their possible values, and the HTML surrounding and formatting them. It currently allows for sections, labels, check boxes, radio buttons, and text fields, and is broken up into sections, each of which corresponds to a different sub-page of our multi-page questionnaire.

The file consists of a series of form-field declarations, separated by blank lines. The syntax of a form-field definition in matrixdef is as follows:

Keyword Variable-Name "Friendly-Name" ["HTML-before" "HTML-after" [Width]]

The last three parts of a form field definition are irrelevant for keywords Section and Label, and the last, Width, is only relevant only the Text keyword. Irrelevant parts of a definition are ignored.

Radio buttons have additional syntax associated with them. Whereas the other form field definitions consist of single lines separated by blank lines, radio button definitions consist of multiple lines: the first defines the name of the radio button group and the subsequent lines define the radio buttons and the values associated with them. A sample radio button definition appears below:

Notice that the radio button lines have a keyword of ".". This is a placeholder that keeps the number of parts in all definitions consistent. The definition above produces the following HTML:

Select (which creates drop-downs) may also have additional syntax. A 'select' line may be followed by one or more lines specifying the values in the drop-down. These values can be defined overtly as radio button values are defined above. Alternatively, or in addition, select lines may be followed by 'fill' statements that can take zero or more arguments, e.g., fillregex p=number[0-9]+_name n=1, where the arguments in this example are p=pattern and n=1. Possible arguments are defined in deffile.py.

fill commands

The possible fill commands are as follows:

Choice Caching

A questionnaire page does not have direct access to the choices file or other questionnaire subpages, so if you need values from other pages you can use a Cache command to store them in a Javascript array.

Cache CACHENAME REGEXPATTERN DISPLAYSUBKEY

The Javascript variable will be called CACHENAME, and will include any items matching REGEXPATTERN. This regular expression must match the beginning of the choice key, but is not required to match the end of the key. Thus, if you want to get non-terminal choices (e.g. noun1, but not noun1_name, noun1_feat1_name, etc), use a $ at the end of the pattern. DISPLAYSUBKEY, if provided, is used to get the choice value displayed in the questionnaire. For instance, if you want to cache all nouns, but want them to be displayed by their name, use the following:

Cache nouns noun[0-9]+$ name

matrixdef_File_Syntax (last edited 2011-12-06 23:19:21 by MichaelGoodman)

(The DELPH-IN infrastructure is hosted at the University of Oslo)