7.4.1. Schema Definition for Custom Types

The figure below shows the contents of the types.xsd file, the XML schema definition (XSD) used for defining custom types in EKM. You can find this file in the EKM_HOME/schema folder in your EKM server installation.

Figure 7.10:  Contents of the types.xsd Schema File

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:ekmTypes="http://www.ansys.com/ekm/types"
    targetNamespace="http://www.ansys.com/ekm/types"
    xmlns:ekmScript="http://www.ansys.com/ekm/script">

    <xsd:import namespace="http://www.ansys.com/ekm/script" schemaLocation="script.xsd"/>

    <xsd:simpleType name="Version">
        <xsd:restriction base="xsd:string">
            <xsd:pattern value="[0-9]+(\.[0-9]+)*"/>
        </xsd:restriction>
    </xsd:simpleType>

    <xsd:complexType name="Constraint">
        <xsd:attribute name="name" type="xsd:string" use="required"/>
        <xsd:attribute name="value" type="xsd:string" use="required"/>
    </xsd:complexType>

    <xsd:complexType name="Property">
        <xsd:sequence>
            <xsd:element name="defaultValue" type="xsd:string" minOccurs="0" maxOccurs="unbounded"/>
            <xsd:element name="enumeration" type="xsd:string" minOccurs="0" maxOccurs="unbounded"/>
            <xsd:element name="constraint" type="ekmTypes:Constraint" minOccurs="0" maxOccurs="unbounded"/>
        </xsd:sequence>
        <xsd:attribute name="name" type="xsd:string" use="required"/>
        <xsd:attribute name="type" use="required">
            <xsd:simpleType>
                <xsd:restriction base="xsd:string">
                    <xsd:enumeration value="Boolean"/>
                    <xsd:enumeration value="Date"/>
                    <xsd:enumeration value="Double"/>
                    <xsd:enumeration value="Long"/>
                    <xsd:enumeration value="String"/>
                    <xsd:enumeration value="Reference"/>
                </xsd:restriction>
            </xsd:simpleType>
        </xsd:attribute>
        <xsd:attribute name="specifiedBy" use="optional">
            <xsd:simpleType>
                <xsd:restriction base="xsd:string">
                    <xsd:enumeration value="extractor"/>
                    <xsd:enumeration value="system"/>
                    <xsd:enumeration value="user"/>
                </xsd:restriction>
            </xsd:simpleType>
        </xsd:attribute>
        <xsd:attribute name="label" type="xsd:string" use="optional"/>
        <xsd:attribute name="multivalued" type="xsd:boolean" use="optional"/>
        <xsd:attribute name="required" type="xsd:boolean" use="optional"/>
        <xsd:attribute name="category" type="xsd:string" use="optional"/>
        <xsd:attribute name="displayOrder" type="xsd:int" use="optional"/>
    </xsd:complexType>

    <xsd:complexType name="Properties">
        <xsd:sequence>
            <xsd:element name="property" type="ekmTypes:Property" minOccurs="0" maxOccurs="unbounded"/>
        </xsd:sequence>
    </xsd:complexType>

    <xsd:complexType name="Action">
        <xsd:attribute name="name" type="xsd:string" use="required"/>
        <xsd:attribute name="macro" type="xsd:string" use="required"/>
        <xsd:attribute name="permissions" type="xsd:string" use="required"/>
        <xsd:attribute name="icon" type="xsd:string" use="optional"/>
		<xsd:attribute name="multiSelectEnabled" type="xsd:boolean" use="optional"/>
    </xsd:complexType>
    
    <xsd:complexType name="View">
        <xsd:attribute name="name" type="xsd:string" use="required"/>
        <xsd:attribute name="initMacro" type="xsd:string" use="required"/>
    </xsd:complexType>
    
    <xsd:complexType name="Views">
        <xsd:sequence>
            <xsd:element name="view" type="ekmTypes:View" minOccurs="0" maxOccurs="unbounded"/>
            <xsd:element name="defaultView" type="xsd:string" minOccurs="0" />
        </xsd:sequence>
    </xsd:complexType>

    <xsd:complexType name="Actions">
        <xsd:sequence>
            <xsd:element name="script" type="ekmScript:Script" minOccurs="0"/>
            <xsd:element name="action" type="ekmTypes:Action" minOccurs="0" maxOccurs="unbounded"/>
            <xsd:element name="removedAction" type="xsd:string" minOccurs="0" maxOccurs="unbounded"/>
        </xsd:sequence>
    </xsd:complexType>

    <xsd:complexType name="Extension">
        <xsd:sequence>
            <xsd:element name="mixins" type="ekmTypes:Mixins" minOccurs="0"/>
            <xsd:element name="actions" type="ekmTypes:Actions" minOccurs="0"/>
            <xsd:element name="views" type="ekmTypes:Views" minOccurs="0"/>
        </xsd:sequence>
        <xsd:attribute name="name" type="xsd:string" use="optional"/>
        <xsd:attribute name="extends" type="xsd:string" use="required"/> 
    </xsd:complexType>

    <xsd:complexType name="Mixin">
        <xsd:sequence>
            <xsd:element name="properties" type="ekmTypes:Properties" minOccurs="0"/>
            <xsd:element name="children" type="ekmTypes:Children" minOccurs="0"/>
        </xsd:sequence>
        <xsd:attribute name="name" type="xsd:string" use="required"/>
        <xsd:attribute name="version" type="ekmTypes:Version" use="required"/> 
    </xsd:complexType>

    <xsd:complexType name="Mixins">
        <xsd:sequence>
            <xsd:element name="mixin" type="xsd:string" minOccurs="0" maxOccurs="unbounded"/>
        </xsd:sequence>
    </xsd:complexType>

    <xsd:complexType name="Child">
        <xsd:attribute name="name" type="xsd:string" use="required"/>
        <xsd:attribute name="type" type="xsd:string" use="required"/>
        <xsd:attribute name="occurs" use="required">
            <xsd:simpleType>
                <xsd:restriction base="xsd:string">
                    <xsd:enumeration value="list"/>
                    <xsd:enumeration value="optional"/>
                    <xsd:enumeration value="required"/>
                </xsd:restriction>
            </xsd:simpleType>
        </xsd:attribute>
    </xsd:complexType>

    <xsd:complexType name="Children">
        <xsd:sequence>
            <xsd:element name="child" type="ekmTypes:Child" minOccurs="0" maxOccurs="unbounded"/>
        </xsd:sequence>
    </xsd:complexType>

    <xsd:complexType name="TypeAttribute">
        <xsd:attribute name="name" type="xsd:string" use="required"/>
        <xsd:attribute name="value" type="xsd:string" use="required"/>
    </xsd:complexType>

    <xsd:complexType name="TypeAttributes">
        <xsd:sequence>
            <xsd:element name="typeAttribute" type="ekmTypes:TypeAttribute" minOccurs="0" 
            maxOccurs="unbounded"/>
        </xsd:sequence>
    </xsd:complexType>

    <xsd:complexType name="Type">
        <xsd:all>
            <xsd:element name="properties" type="ekmTypes:Properties" minOccurs="0"/>
            <xsd:element name="children" type="ekmTypes:Children" minOccurs="0"/>
            <xsd:element name="mixins" type="ekmTypes:Mixins" minOccurs="0"/>
            <xsd:element name="typeAttributes" type="ekmTypes:TypeAttributes" minOccurs="0"/>
            <xsd:element name="actions" type="ekmTypes:Actions" minOccurs="0"/>
            <xsd:element name="views" type="ekmTypes:Views" minOccurs="0"/>
        </xsd:all>
        <xsd:attribute name="name" type="xsd:string" use="required"/>
        <xsd:attribute name="extends" type="xsd:string" use="optional"/>
        <xsd:attribute name="label" type="xsd:string" use="optional"/>
        <xsd:attribute name="version" type="ekmTypes:Version" use="required"/>
    </xsd:complexType>

    <xsd:complexType name="Types">
        <xsd:choice minOccurs="1" maxOccurs="1">
            <xsd:element name="type" type="ekmTypes:Type"/>
            <xsd:element name="mixin" type="ekmTypes:Mixin"/>
            <xsd:element name="extension" type="ekmTypes:Extension"/>
        </xsd:choice>
    </xsd:complexType>

    <xsd:element name="types" type="ekmTypes:Types"/>

</xsd:schema>

The file indicates that a custom type file consists of a root element called types that can have one child element that can be a type, mixin or extension.

type

This element is used to define a new data type.

extension

This element is used to extend a built-in type.

mixin

This element is used to create sharable groups of children and properties that can be included in more than one type or extension element. A mixin can have properties or child types as sub-elements. Child types are used for enforcing an object hierarchy. An extension can have mixins as sub-elements. A type can have properties, child types, mixins or type attributes as sub-elements. Type attributes are used to specify type-specific attributes such as applications for extracting metadata or reports. These are primarily used for defining custom file formats.

You must specify a version attribute for types and mixins. By convention, a version in EKM consists of three revision numbers: X.Y.Z where X Y and Z are integers that represent the major revision, minor revision, and patch revision of the type, respectively. All versions start with 1.0.0. You are free to choose a different version convention that can consist of greater or fewer revision numbers.


Release 18.2 - © ANSYS, Inc. All rights reserved.