4.4.5. Text files (plain files)

MetaFactory produces 3 different kinds of files:

  • java source code,

  • xml files and

  • plain text files.

The <xml files> element is the way to create create plain text files such as HTML and Javascript.

Usage

Listing 4.39 <text files/> syntax
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
<pattern>
        ...
        <file name=""
                        path=""
                        description=""
                        trimLeading=""
                        trimTrailing=""
                        foreach="package|object|attribute|reference"
                        package=""
                        condition=""
                        var0=""
                        var1=""
                        var2=""
                        var3=""
                        var4=""
                        var5=""
                        skip="">
                <body></body>
        </file>
        ...
</pattern>

The name attribute is mandatory and indicates the name of the file.

Attributes

Table 4.36 attributes of <text files/>

Name

Details

name

The name of the file made.

path

Path where the file is saved.

description

Description of the file. Not used in the produced file.

trimLeading

true or false. If true, leading spaces are removed.

trimTrailing

true or false. If true, trailing spaces are removed.

foreach

Indicates if parameter must be created foreach element in model (value of foreach determines what model element). Possible values: package, object, attribute, reference.

condition

An expression that evaluates to true or false. Generation of the current file wil precede if true and otherwise not.

Example: .. code-block:

condition="${object.name}=Person"

In this case, the attribute is made only if the current model object has the name: Person. This works only if all model objects are iterated (foreach=”object”).

package

The name of the package in the model (model.xml) that must be used to apply the foreach attribute.

var0

Value that you wish to store in the pre-defined variable with the name var0. Reference to this value can be made later by means of: ${var0}. This can be used in both the pattern and in a snippet (freemarker or velocity template).

var1

Value that you wish to store in the pre-defined variable with the name var1. Reference to this value can be made later by means of: ${var1}. This can be used in both the pattern and in a snippet (freemarker or velocity template).

var2

Value that you wish to store in the pre-defined variable with the name var2. Reference to this value can be made later by means of: ${var2}. This can be used in both the pattern and in a snippet (freemarker or velocity template).

var3

Value that you wish to store in the pre-defined variable with the name var3. Reference to this value can be made later by means of: ${var3}. This can be used in both the pattern and in a snippet (freemarker or velocity template).

var4

Value that you wish to store in the pre-defined variable with the name var4. Reference to this value can be made later by means of: ${var4}. This can be used in both the pattern and in a snippet (freemarker or velocity template).

var5

Value that you wish to store in the pre-defined variable with the name var5. Reference to this value can be made later by means of: ${var5}. This can be used in both the pattern and in a snippet (freemarker or velocity template).

skip

true or false. If true and the menu check box “Use @skip of packages” (menu Transform) is checked, then the package is not made. This function is intended to prevent everything having to be re-generated each time, thereby saving time. This function enables you to work on a specific package by setting all skip attributes to true, except for those you are currently working on.

Sub elements

Table 4.37 sub elements of <file/>

Name

Details

Number

body

Contents of file. A snippet can also be used.

0 or 1