Cartridge Descriptor Schema

Each Cartridge descriptor (andromda-cartridge.xml) must comply with the following XSD Schema:

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
    <xs:element name="cartridge">
        <xs:complexType>
            <xs:sequence>
                <xs:element ref="templateEngine" minOccurs="0" maxOccurs="1"/>
                <xs:element ref="templateObject" minOccurs="0" maxOccurs="unbounded"/>
                <!-- these are references to properties that are expected to
                     be supplied by the calling client through a <namespace/> element.
                     When the property name and its value are supplied in the build
                     file for example, that property is then supplied to the template.  -->
                <xs:element ref="property" minOccurs="0" maxOccurs="unbounded"/>
                <!-- a resource defines any non template resource included in the cartridge,
                     these can include things such as files, images, etc, that are copied
                     to a given outlet, resources are NOT processed by a template engine -->
                <xs:element ref="resource" minOccurs="0" maxOccurs="unbounded"/>
                <!-- these define the templates a cartridge contains, these are processed
                     by an AndroMDA template engine -->
                <xs:element ref="template" minOccurs="1" maxOccurs="unbounded"/>
            </xs:sequence>
            <xs:attribute name="name" type="xs:string" use="optional"/>
        </xs:complexType>
        <xs:unique name="uniquePropertyReference">
            <xs:selector xpath="property"/>
            <xs:field xpath="@reference"/>
        </xs:unique>
    </xs:element>
    <xs:element name="property">
        <xs:complexType>
            <!-- defines a reference to a <property/> element defined within
                 a namespace element in your build file -->
            <xs:attribute name="reference" use="required"/>
        </xs:complexType>
    </xs:element>
    <!-- this is the grouping of all modelElements supported within a template -->
    <xs:element name="modelElements">
        <xs:complexType>
            <xs:sequence>
                <!-- You can define as many modelElements as you want -->
                <xs:element ref="modelElement" minOccurs="1" maxOccurs="unbounded"/>
            </xs:sequence>
            <!-- the default variable name to use for any modelElements define in your <template/>
                 element, this will be used if no variable attribute is defined at the
                 <modelElement/> element -->
            <xs:attribute name="variable" type="xs:string" use="optional"/>
        </xs:complexType>
    </xs:element>
    <xs:element name="modelElement">
        <xs:complexType>
            <xs:sequence>
                <!-- types allow you to group model elements by type of metafacade
                     and by a metafacade's properties -->
                <xs:element name="type" minOccurs="0" maxOccurs="unbounded">
                    <xs:complexType>
                        <xs:sequence>
                            <xs:element name="property" minOccurs="0" maxOccurs="unbounded">
                                <xs:complexType mixed="true">
                                    <!-- This defines the name of the type's property -->
                                    <xs:attribute name="name" use="required"/>
                                </xs:complexType>
                            </xs:element>
                        </xs:sequence>
                        <!-- Specifies the type's name -->
                        <xs:attribute name="name" use="required"/>
                    </xs:complexType>
                </xs:element>
            </xs:sequence>
            <!-- a stereotype name from the model that will be processed (i.e. entity, enumeration, etc.) -->
            <xs:attribute name="stereotype" use="optional"/>
            <!-- defines the variable name that should be placed into the template engine context,
                 for all model elements having the modelElement with the stereotype attribute,
                 if this is not defined, then the variable from the
                 enclosing <modelElements/> element will be used. -->
            <xs:attribute name="variable" use="optional"/>
        </xs:complexType>
        <xs:unique name="uniquePropertyName">
            <xs:selector xpath="property"/>
            <xs:field xpath="@name"/>
        </xs:unique>
    </xs:element>
    <xs:complexType name="resourceType">
        <!-- the resource to process -->
        <xs:attribute name="path" type="xs:string" use="required"/>
        <!-- the pattern to use for defining output -->
        <xs:attribute name="outputPattern" type="xs:string" use="required"/>
        <xs:attribute name="outlet" type="xs:string" use="required"/>
        <!-- true/false on whether we should overwrite results of previous run -->
        <xs:attribute name="overwrite" type="xs:boolean" use="required"/>
    </xs:complexType>
    <xs:element name="resource" type="resourceType"/>
    <xs:element name="template">
        <xs:complexType>
            <xs:complexContent>
                <xs:extension base="resourceType">
                    <!-- You can have as many modelElements as you want for a template or
                         you don't even need to add model elements to your template -->
                    <xs:sequence>
                        <xs:element ref="modelElements" minOccurs="0" maxOccurs="1"/>
                    </xs:sequence>
                    <!-- true/false on whether we should allow generation of empty files-->
                    <xs:attribute name="generateEmptyFiles" type="xs:boolean"/>
                    <!-- if this flag is set to true, then all model elments
                         processed by the template will be output to one template as
                         collection of model elements (instead of on a per model
                         element per file basis) -->
                    <xs:attribute name="outputToSingleFile" type="xs:boolean" use="optional"/>
                    <!-- This only makes sense when outputToSingleFile is true.
                         If this flag is set to true, then the file will be output regardless
                         of whether or not there are no elements found in the collected
                         model elements, if false then the file will not be output -->
                    <xs:attribute name="outputOnEmptyElements" type="xs:boolean" use="optional"/>
                </xs:extension>
            </xs:complexContent>
        </xs:complexType>
    </xs:element>
    <xs:element name="templateObject">
        <xs:complexType>
            <xs:sequence>
                <xs:element ref="property" minOccurs="0" maxOccurs="unbounded"/>
            </xs:sequence>
            <!-- the name of the templateObject (this is the scripting variable name
                 made available to the template being processed) -->
            <xs:attribute name="name" type="xs:string" use="required"/>
            <!-- the class of the templateObject (must have a default constructor) -->
            <xs:attribute name="className" type="xs:string" use="required"/>
        </xs:complexType>
        <xs:unique name="uniqueTemplateObjectPropertyReference">
            <xs:selector xpath="property"/>
            <xs:field xpath="@reference"/>
        </xs:unique>
    </xs:element>
    <!-- Defines a macro library that can be used with commonly used scripting engine macros -->
    <xs:element name="macrolibrary">
        <xs:complexType>
            <xs:attribute name="name" type="xs:string" use="required"/>
        </xs:complexType>
    </xs:element>
    <!-- you configure the template engine through here -->
    <xs:element name="templateEngine">
        <xs:complexType>
            <xs:sequence>
                <xs:element ref="macrolibrary" minOccurs="0" maxOccurs="unbounded"/>
            </xs:sequence>
            <!-- the class of the TemplateEngine implementation (must have a default constructor) -->
            <xs:attribute name="className" type="xs:string" use="optional"/>
        </xs:complexType>
    </xs:element>
</xs:schema>