Write the .uax files for the Universal Importer

Describe the objects, links, project and manifest to import with the Universal Importer in .uax, xxx_project.uax and .uaxdirectory files
Updated

Overview

The Universal Importer reads three kinds of file: .uax files that describe the objects and links to import, an xxx_project.uax file that defines the project they belong to, and a .uaxdirectory manifest that lists them. This page describes the format of each file. The examples import part of a GraphTalk application.

All three files are XML. Save them in UTF-8, with this declaration:

<?xml version="1.0" encoding="UTF-8"?>

.uax files

A .uax file contains a list of instance elements under a root instances element. Each instance is an object or a link. Its instanceOf attribute is a type defined in the metamodel of the language package, and its child elements set the properties of the categories that the type inherits.

Instances can appear in any order: a link can be declared before the objects it connects.

Example

The following file, accntng.uax, declares a package accntng in the project AIA_V3, and a shell accntng_explorer that belongs to the package:

<?xml version="1.0" encoding="UTF-8"?>
<instances>
    <!-- The package object -->
    <instance id="WPDi60000KY0M" instanceOf="GTpackage">
        <identification name="accntng" fullName="Package - $accntng"/>
        <persistent guid="package.accntng"/>
    </instance>

    <!-- The package is internal to the project AIA_V3 -->
    <instance id="" instanceOf="isInProjectLink">
        <isInProjectLink projectRelationKind="0"/>
        <link callee="AIA_V3" caller="WPDi60000KY0M"/>
    </instance>

    <!-- The package belongs to the root of the project -->
    <instance id="" instanceOf="parentLink">
        <link callee="%ProjectRoot%" caller="WPDi60000KY0M"/>
    </instance>

    <!-- The shell object -->
    <instance id="sh3SQ00023Y0O" instanceOf="GTshell">
        <identification name="accntng_explorer" fullName="Shell - $accntng:accntng_explorer"/>
        <persistent guid="package.accntng.shell.accntng_explorer"/>
    </instance>

    <!-- The shell is external to the project -->
    <instance id="" instanceOf="isInProjectLink">
        <isInProjectLink projectRelationKind="1"/>
        <link callee="AIA_V3" caller="sh3SQ00023Y0O"/>
    </instance>

    <!-- The shell belongs to the package -->
    <instance id="" instanceOf="parentLink">
        <link callee="WPDi60000KY0M" caller="sh3SQ00023Y0O"/>
    </instance>
</instances>

Object instances

Element or attribute Description
instance/@id The identifier of the object, which links refer to. It must be unique within the set of .uax files imported together.
identification/@name The name of the object. It does not need to be unique. Required.
identification/@fullName The full name of the object. Keep it reasonably short: long full names slow down the analysis and increase the size of the results. Required.
persistent/@guid The persistent identifier of the object. See Object GUIDs.
checksum/@CodeAndCommentsChecksum, checksum/@CodeOnlyChecksum Optional checksums of the object. Use decimal values only: hexadecimal values are not read correctly.

Objects without both identification/@name and identification/@fullName are not displayed.

A link is an instance whose id is empty and whose instanceOf is a link type. Its link element has a caller and a callee attribute that refer to the id of objects:

Link type Description
isInProjectLink Attaches an object to the project. Its projectRelationKind attribute is 0 for an object that is internal to the application, and 1 for an external object, such as a third-party component. Only internal objects are included in snapshots.
parentLink Makes the caller a child of the callee. Top-level objects are children of %ProjectRoot%, which is replaced by the project.
Any link type defined in the metamodel For example callLink or useLink.

To link to an object that another analyzer has already saved in the analysis schema, see Link to objects from other analyzers. Do not use parentLink with such external objects: it gives inconsistent results.

Split an instance

You can split the definition of an instance across several instance elements with the same id, but all the properties of one category must be in the same element. This is valid:

<instance id="C:\test.php" instanceOf="sourceFile">
    <identification name="test.php" fullName="C:\eiffel\test\php\test.php"/>
</instance>
<instance id="C:\test.php" instanceOf="sourceFile">
    <bookmark source="C:\test.php"/>
</instance>

This is not valid, because the properties of the identification category are split:

<instance id="C:\test.php" instanceOf="sourceFile">
    <identification name="test.php"/>
</instance>
<instance id="C:\test.php" instanceOf="sourceFile">
    <identification fullName="C:\eiffel\test\php\test.php"/>
</instance>

Object GUIDs

Each object saved in the analysis schema has a GUID, which CAST Imaging uses to recognize the same object from one analysis to the next. Set it with the guid attribute of the persistent element:

<instance id="C:\test.php" instanceOf="sourceFile">
    <bookmark source="C:\test.php"/>
    <persistent guid="thefileguid"/>
    <identification name="test.php" fullName="C:\eiffel\test\php\test.php"/>
</instance>
  • The GUID must be unique across all projects in the analysis schema.
  • The GUID must stay the same for an object in every delivery. Otherwise the object is recorded as changed, which skews the results in the dashboards.
  • If you do not set a GUID, the Universal Importer currently builds one from the id of the instance. Future releases may change how this default GUID is built, so always set the GUID explicitly. If you have relied on the default until now, set the GUID to the value of id to keep the same GUIDs.

xxx_project.uax file

This file defines the project that the imported objects belong to. You can give it any name with the .uax extension: CAST recommends xxx_project.uax. For example:

<?xml version="1.0" encoding="UTF-8"?>
<instances>
    <instance id="AIA_V3" instanceOf="GraphtalkProject">
        <identification name="AIA_V3" fullName="AIA_V3"/>
    </instance>
    <instance id="" instanceOf="projectDependencyLink">
        <link callee="%ProjectRoot%" caller="AIA_V3"/>
        <projectDependencyLink dependencyKind="0"/>
    </instance>
    <instance id="" instanceOf="isInProjectLink">
        <isInProjectLink projectRelationKind="0"/>
        <link callee="AIA_V3" caller="AIA_V3"/>
    </instance>
</instances>
Instance Description
The project Its id must be unique. Its instanceOf is the project type defined in the metamodel. CAST recommends using the id as the name and full name.
projectDependencyLink Makes the project a child of the root of the import.
isInProjectLink Attaches the project to itself. Use the project id as both caller and callee.

.uaxdirectory file

The .uaxdirectory file is a manifest that lists the project file and the .uax files. You can give it any name with the .uaxdirectory extension. Save it in the same folder as the .uax files:

<?xml version="1.0" encoding="UTF-8"?>
<UAXFiles>
    <UAXOption name="technicalVersion" value="1.1"/>
    <UAXFile path="CAST_project.uax" name="AIA_V3" type="GraphtalkProject">
        <UAXFile path="accntng.uax" name="" type="GTpackage">
        </UAXFile>
    </UAXFile>
</UAXFiles>
Entry Description
UAXOption name="technicalVersion" Optional. Records the version of the external analyzer that produced the files.
UAXFile for the project path is the path of the project file, name the name of the project defined in it, and type its project type, which must exist in the metamodel.
UAXFile for each .uax file Nested in the project entry, one per .uax file. path is the path of the file, name is empty, and type is the type of the objects the file describes.

You can configure the external analyzer to generate the .uaxdirectory and project files, or write them yourself.