Wizzi Model DOMs

Wizzi Model DOMs are javascript objects, inspired by Xml document objects, that can load mTrees , applying a type to their nodes.

Wizzi Model DOMs are software artifacts generated by artifact generators of the wizzi-core plugin.

From a wfschema ITTF Document, Wizzi generates:
  • a Wizzi Model DOM (javascript module)
  • a Wizzi Model instance factory (javascript module)
  • a JSON documentation (JSON file).

wfschema artifact generators for Wizzi MOdel DOMs and links to source code

artifact name output file name source code
wfschema/factory {schema-name}-factory.g.js ittf javascript
wfschema/model {schema-name}-model.g.js ittf javascript
wfschema/json_docs {schema-name}-schema.g.json ittf javascript
Wizzi Model DOMs generation

Wizzi Model DOMs are generated calling the generateModelDoms method of an instance of the wizzi.WizziFactory class, instantiated with use of the wizzi-core , wizzi-js and wizzi-web plugins.

The wizzi.WizziFactory.generateModelDoms method.

                                
1 ...
2 m generateModelDoms
3 string wfschemaIttfDocumentUri
4 # The full path to the primary ITTF document of the `wfschema` declaration.
5 string outputPackagePath
6 # The full path of the package folder where the generated artifacts will be written
7 string wfschemaName
8 # The schema name, for composing the names of the generated artifacts
9 { mTreeBuildUpContext
10 # An object that will be the evaluation context object
11 # during the mTree processing of the `wfschema` ITTF document
12 callback
13 # Returns error or null
The Wizzi Model DOM javascript module

A Wizzi Model DOM module is a single file that contains a javascript class for each element defined in its wfschema and some standard base classes.

Wizzi Model classes

wzSourceLineInfo source map item with source file path, row, col of a node
{schema-name}Exception exception object for this Wizzi Model
{schema-name}Context context object for the methods wzInitialize and wzVerify
{schema-name}Base base class for all element classes
{element-name} one class for each element of the `wfschema`

 

The wzSourceLineInfo API

                                
1 class wzSourceLineInfo
2 ctor
3 integer row
4 # 1-based row position of the source ittf node
5 integer col
6 # 1-based column position position of the source ittf node
7 string sourceKey
8 # Key to the source ITTF Document infos stored in the 'loadHistory' object
9 # The 'loadHistory' is a property of the root element
10 m toString
11 { elementInstance?
The {schema-name}Exception API

                                
1 class {schema-name}Exception
2 ctor
3 string message
4 { ittfNode
5 { elementInstance
The {schema-name}Context API

                                
1 class {schema-name}Context
2 boolean schemaIsValid
3 m addError
4 string message
5 { mTreeNode
6 m verifyEnum
7 string valueType
8 string valueName
9 string value
10 [ allowed
11 string allowedValue
12 { mTreeNode
The {schema-name}Base API

                                
1 class {schema-name}Base
2 string wzName
3 string wzTag
4 [ wzChildren
5 ctor
6 string name
7 # the node-value of the source mTreeNode
8 # that becomes the 'wzName' of the newly created element
9 { sourceLineInfo
10 api-ref wizzimodel.wzSourceLineInfo
11 m wzRoot
12 # Return the model root element instance
13 m wzSourceFilepath
14 # Returns the filepath of an ittf source document given its 'sourceKey'
15 string sourceKey
16 m wzAddChild
17 # Add a child node to the wzChildren collection
18 { elementInstance
19 m wzLoadToChildColl
20 # Creates a new element instance given the type of its source mTreeNode
21 # Append it to the collection passed as parameter.
22 # Call the loadFromNode method of the newly created element
23 # with the source mTreeNode as argument.
24 { mTreeNode
25 # the mTreeNode that we are loading
26 { type
27 # the javascript class of the Wizzi Model element
28 # that is the type for mTreeNode given its node-name
29 { coll
30 # the collection to which the newly created element should be appended
31 m wzLoadToChildren
32 # Creates a new element instance given the type of its source mTreeNode
33 # Append it to the wzChildren collection.
34 # Call the loadFromNode method of the newly created element
35 # with the source mTreeNode as argument.
36 { mTreeNode
37 { type
38 m wzLoadOneToOne
39 # Creates a new element instance given the type of its source mTreeNode
40 # Assign it to the `fieldName` property.
41 # Call the loadFromNode method of the newly created element
42 # with the source mTreeNode as argument.
43 { mTreeNode
44 { type
45 string fieldName
46 m error
47 # throw a {schema-name}Exception
48 string message
49 { mTreeNode
The `element-name` API

                                
1 class `element-name`
2 m loadChild
3 # Tests if the mTreeNode name is a valid child element or attribute.
4 # If yes call the proper add method and return true.
5 # If no return false.
6 { mTreeNode
7 m loadFromNode
8 # Calls the loadChild method on this element
9 # for each child node of the mTreeNode to load.
10 { mTreeNode
11 m wzInitialize
12 # Initialize the element
13 # Called after the source mTree has been succesfully loaded.
14 param ctx
15 api-ref {schema-name}Context
16 m wzVerify
17 # Verify if the element is valid
18 # Called after the wzInitialize method.
19 { ctx
20 api-ref {schema-name}Context