The wfschema, implemented by the wizzi-core plugin, is the meta model of a wizzi schema. It models a wizzi schema with the same semantic with which a wizzi schema models a Wizzi Model.
This documentation section has a circularity that may give an headache. It documents a schema that describe a schema using the same schema notation of the documented schema.
Some hints may help.
- A wizzi schema describes a model in terms of element types, with attributes, and relations between elements. Elements can extend super elements. Relations, that do not have attributes, can be of kind parent-children (one-to-many, the default) or parent-singlechild (one-to-one).
- Elements are described in a flat list. Relations hierarchy and element derivations are inferred from definitions.
- The root element can be declared using the element attribute 'isRoot'. If not declared the root element is the first of the list.
- Elements and attributes may have an optional tag attribute that defines a name alias shorter or with an easier mnemonic. wfschema examples:
- 'e' for 'element'
- 'a' for 'attribute'
- 'r' for 'relation'
- Node names of mTree nodes simply map to an element or attribute tag (or name, if a tag is not declared).
The wfschema elements are
- wfschema
- exportTo
- require
- element
- attribute, string, boolean, integer, float, date
- relation
- restrict, enum, minLength, maxLength, minValue, maxValue, regexp
- method, function
- parameter
wfschema element
The root element of a 'wfschema'.
1 e wfschema `name`
2 r require/s
3 r exportTo/s
4 r element/s
exportTo element
An exportTo element causes the insertion in the Wizzi Model classes of the prototype functions for exporting the tree data structure of the model in the requested format
The entire Wizzi Model can be exported calling this methods on the root element.
1 ...
2 e export-to [json|xml]
require element
A Wizzi Model can contain user defined methods and functions, that could need to import objects from other modules. This element allow to insert require statements in the generated Wizzi Model module.
1 e require `import-name`
2 string declareVar `name`
3 tag declare-var
4 optional
5 default `import-name`
6 string invoke `invoke-string`
7 optional
8 string kind [module]
9 # At now we have only one kind, and this attribute is superflous.
10 # Other kinds could be added in the future.
11 optional
12 default module
The generated statement is built in this way:
1 var `declareVar` = require('`import-name`')[`invoke`]
Example
1 ...
2 require wizzi-utils
3 declare-var verify
4 invoke .verify
5 generates:
6 var verify = require('wizzi-utils').verify
Element element
Describes an element type of the schema.
1 e element `name` [: `super-element-name`]
2 tag e
3 string super `super-element-name`
4 string tag `tag`
5 string xmlTag `tag`
6 tag xml-tag
7 boolean isAbstract
8 tag is-abstract
9 default-when-declared true
10 boolean isRoot
11 tag is-root
12 default-when-declared true
13 boolean nameIsRequired
14 tag name-is-required
15 default-when-declared true
16 boolean addToChildren
17 tag add-to-children
18 default-when-declared true
19 r attribute/s
20 r relation/s
21 r method/s
Relation element
1 e relation `related-element-name`[-`plural-suffix-a`]/`plural-suffix-b`
2 # Examples
3 # r column/s (element: column, collection: columns)
4 # r propert-y/ies (element: property, collection: properties)
5 tag r
6 boolean oneToOne
7 tag one-to-one
8 default-when-declared true
9 boolean noGet
10 tag no-get
11 default-when-declared true
Example:
1 ...
2 e table : dbitem
3 r column/s
4 r propert-y/ies
5 r displayLayout
6 one-to-one
related-element-name plus the eventual plural-suffix-a must give the name of an element defined in the schema (that is the related element); in the example: column, property, displayLayout.
attribute element
Describes an attribute of an element
1 e attribute `name`
2 tag a
3 string tag `tag`
4 string xmlTag `tag`
5 tag xml-tag
6 string type [string|integer|float|boolean|date]
7 default string
8 string default `default-value`
9 string defaultWhenDeclared `default-value`
10 tag default-when-declared
11 boolean isDatatype
12 tag is-datatype
13 default-when-declared true
14 boolean isRequired
15 tag is-required
16 default-when-declared true
17 r restrict/s
string element
1 e string `attribut-name` : attribute
boolean element
1 e boolean `attribut-name` : attribute
integer element
1 e integer `attribut-name` : attribute
float element
1 e float `attribut-name` : attribute
date element
1 e date `attribut-name` : attribute
restrict element
1 e restrict
2 is-abstract
enum element
1 e enum `enum-value` : restrict
maxLength element
1 e maxLength `value` : restrict
2 tag max-length
minLength element
1 e minLength `value` : restrict
2 tag min-length
maxValue element
1 e maxValue `value` : restrict
2 tag max-value
minValue element
1 e minValue `value` : restrict
2 tag min-value
regexp element
1 e regexp `value` : restrict
method element
Declares a method that will be added to the element class. A method can access and manipulate the entire Wizzi Model, having access to the 'this.wzRoot()' method of the `schema-name`Base class.
1 e method `name`
2 tag m
3 r param/s
4 r statement/s
param element
statement element
The statement element uses a subset of the schema 'js' implemented by the plugin wizzi-js.
function element
Declares a method that will be added to the module and will be a private function for methods of the model instances.
1 e function `name`
2 tag m
3 r param/s
4 r statement/s