Generated Files (Profile)

Generated files assemble GTL templates for generation as files or for previewing on the object property sheet Preview tab.

  1. Right-click a metaclass, stereotype, or criterion, and select New > Generated File.
    Only objects, such as tables or classes, support file generation. However, you can still create generated files for sub-objects, such as columns and attributes, to preview code generated for them on their property sheet Preview tab.
  2. Enter the following properties as appropriate:

    Property

    Description

    Name

    Specifies a name for the generated file item in the resource editor.

    If an extension attached to the model contains a generated file name identical to one defined in the main resource file, then only the extension generated file will be generated.

    File Name

    Specifies the name of the file that will be generated. This field can contain GTL variables. For example, to generate an XML file with the code of the object for its name, you would enter %code%.xml.

    If you leave this field empty, then no file will be generated, but you can view the code produced in the object's Preview tab.

    If this field contains a recognized extension, the code is displayed with the corresponding language editor and syntactic coloring.

    Type

    Specifies the type of file to provide appropriate syntax coloring in the Preview window.

    Encoding

    Specifies the encoding format for the file. Click the ellipsis tool to the right of the field to choose an alternate encoding from the Text Output Encoding Format dialog, where you can specify the following options:
    • Encoding - Encoding format of the generated file
    • Abort on character loss - Specifies to stop generation if characters cannot be identified and are to be lost in current encoding

    Comment

    Specifies additional information about the generated file.

    Use package hierarchy as file path

    Specifies that the package hierarchy should be used to generate a hierarchy of file directories.

  3. Enter GTL code (see Customizing Generation with GTL) or the name of a template to populate the file in the text zone.

    In the following example, a generated file is defined for OOM classes. A file will be generated for each class in the model with a name derived from the class %Name%, and containing the contents generated from the %myTemplate% template (see Templates (Profile)):



  4. Click OK to save your changes and close the resource editor.

    The file is immediately available as a sub-tab on the Preview tab of the object property sheet: