Schema QuickRef
Following is a breakdown of the purpose of all the elements and attributes required in a schema section for an XApp application. Firstly here's a sample schema.
Note: A DTD is provided with the XApp distribution to validate the config.xml file if you're using a validating editor
Common Elements
The common elements found within the schema but outside of the field definitions are discussed first
- recordname
- name of the parent element for each record in the data file. this value is used in conjunction with rootname to build various XPath queries used to interpret the data file contents
- groupby
- path to the foreign key data file which is used to build the dropdown menu and identify data files in the data set that are available for editing
- minOccurs & maxOccurs
- minimum and maximum number of records that must/can be present in any data file. If these bounds are exceeded a UI error will be presented. and if theyre close the Add and Delete buttons will be removed from the UI so a user cant say add if maxOccurs has already been reached
- clientsidevalidation
- if contains the string 'Javascript' will embed JS client side subs that will validate forms in the browser before allowing user to submit them. Any other value in this element is currently ignored.
Fields Elements
An XApp schema is similar to a SQL table definition and can contain any number of fields of various types and definition. Each field has certain mandatory attributes and depending on 'type' of field has type specific attributes as well. These are discussed following:
- name
- a mandatory field which is unique to each field and used as the name of any form fields generated in the UI and submitted to the controller.cgi for processing. should follow normal cgi variable naming conventions, be short and not contain whitespace.
- label
- used for display purposes only in the edit interface where the name field may not be as human readable. Can contain whitespace and be mixed case.
- format
- specifies the data type format that XApp will treat the record as and corresponds to field types in a SQL sense. Currently supported formats are 'text', 'textarea', 'enum', 'date', 'time' and 'boolean'
- type
- differs from format in that this indicates how the field should be presented in the UI and possible values are similar to standard HTML INPUT field types. currently support types are 'text', 'textarea', 'wysiwyg', 'password', 'checkbox', 'radio', 'select', 'date' and 'time'
- values
- when the field type is 'enum' the values atribute is used to contain a comma seperated list of the selectable values for the enumerated type
- default
- will be the value that a field is set to by default when creating a new record. this is an optional attribute and if not present a field in a new record will be blank. In the case of date or time fields a value here of DATENOW or TIMENOW will direct XApp to populate these fields with the current active time or date when creating a new record
- isindex
- signifies that this particular field is the index field for the record type. only one field should be marked as isindex and the controller will always ensure a value is supplied for it, producing an error if not
- size
- only relevent for text type fields and specifies their input box display length. is also optional and XApp will use a default length if not present
- maxlength
- used to specify the maximum length accepted for text type fields. is optional and submission is not validated unless a length specified.
- rows & cols
- on relevent when specifiying a textarea type field, equivalent to the same HTML attributes for this input type. optional and XApp will use defaults if not specified in the schema
- required
- will force XApp to demand a value from the user for this record when adding a new one or editing an existing one. is implied if isindex field is set to '1' and not required if thats the case
- tip
- any content in a tip attribute will be presented in a mouseover for a small image placed beside the fields label in the edit interface to queue the user of XApp as to the purpose of the fields content
Authored using: XApperator