5. Filter tags

Aus Hugo Doku

Wechseln zu: Navigation, Suche

To write a .filter file, you have root-tags and sub-tags. The root -tags select an amount of files, the sub-tags define instructions what shall happen with the data in the selected files. All selected files are assumed to be XML-files. Because the sub-tags instructions work with DOM.

If you compare the tags to a loop instruction of a programming language, the root-tag would be the head of the loop, the sub-tags would be the instructions within the body of the loop.

All sub-tags can be used below all root-tags.

Important Important

Be aware of that filter works on a list of model files. Normally this list is build out of all files, which are located within the model-path directory. For an overview of the filter concept please refer to Section 1.2.4. Filters


5.1. Root-Tags

For selecting the files amount each root tag uses a Java regular expression. Please refer to the Java documentation, if you do not know how to write a regular expression.


5.1.1. <collect>

Description:

The <collect> tag works like a loop, which only runs once. All files, which are selected by the regular expression, are first stick together to be one collective file, before the sub-tags instructions are called with this file. The collective file is assumed to be a XML file.

Attributes:

Name Description Required Default Value
file The Java regular expression for selecting the files, which should be sticked together. yes
encoding The encoding of the collective file. no "utf-8"
root The root tag of the collective file. no "root"
stage The stage, when the filter is executed. The following stages are possible:
1. gen: usually used for generating-tasks
2. comp: usually used for compiling-tasks
3. link: usually used for linking-tasks
4. doc: usually used for generating documentation-tasks.
no "gen"
section The section, when the filter is executed. The following sections are possible. All this sections exist in each stage!
1. prepare
2. main
3. complete
no "main"

Example 5.1. Filter using <collect>

<example not yet included>

5.1.2. <filter>

Description:

The <filter> tag works like a "for each" loop. It filters an amount of files by a regular expression. For each file of the result amount the sub-tags instructions will be called.

Attributes:

Name Description Required Default Value
file The Java regular expression for filtering files. yes
uuid The name of the tag which is used as a UUID. If this attribute is set and a tag of the .model file does not have this attribute, HuGo will add this attribute and will generate a UUID then. no ""
stage The stage, when the filter is executed. The following stages are possible:
1. gen: usually used for generating-tasks
2. comp: usually used for compiling-tasks
3. link: usually used for linking-tasks
4. doc: usually used for generating documentation-tasks.
no "gen"
section The section, when the filter is executed. The following sections are possible. All this sections exist in each stage!

1. prepare 2. main 3. complete

no "main"

Important Important

Using UUIDs (Universal Unified IDentifiers) is sensible in relation with the naming of coding blocks. By default coding blocks are identified by the methodname they are used. But this can result to problems after you rename your method. For this reason UUIDs may be very helpful to forware them as names to the coding block.
BUT: Normally UUIDs are managed by an editor for the .model file. Because: What is happening if you copy and paste a tag of the .model file? Do you remember, that now a new UUID is needed?
Thus using UUIDs inside a simple XML editor means: be careful!

Example 5.2. Filter using <filter>, in different stections

<example not yet included>

Example 5.3. Filter using <filter>, setting up UUIDs

<example not yet included>


Next: 5.2. Sub-Tags
Persönliche Werkzeuge