Schema definition for FIS

<xs:schema version="1.0" targetNamespace="http://imafis.imaes.ecm.tsystems.com/"
           xmlns:tns="http://imafis.imaes.ecm.tsystems.com/" xmlns:xs="http://www.w3.org/2001/XMLSchema"
           xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
           jxb:version="2.0">
  <xs:element name="operation">
    <xs:complexType>
      <xs:choice>
        <!-- migrate -->
        <xs:element name="document" type="tns:documentType"/>
        <!-- archive -->
        <xs:element name="revision" type="tns:revisionType"/>
        <!-- sapArchive -->
        <xs:element name="sapRevision" type="tns:sapRevisionType"/>
        <!-- export, delete, sapExport, sapDelete -->
        <xs:element name="search" type="tns:search" maxOccurs="unbounded"/>
        <!-- deleteMigrated -->
        <xs:element name="documentIds" type="tns:documentIdsType"/>
        <!-- update -->
        <xs:element name="updateRevision" type="tns:updateRevisionType"/>
        <!-- smartUpdate -->
        <xs:element name="smartUpdateRevision" type="tns:smartUpdateRevisionType"/>
        <!-- registerBlob, unregisterBlob -->
        <xs:element name="blob" type="tns:blobType" maxOccurs="unbounded"/>
        <!-- bulkUpdateAttributes -->
        <xs:element name="bulkUpdateAttributes" type="tns:bulkUpdateAttributesType" maxOccurs="unbounded"/>
      </xs:choice>
      <xs:attribute name="name" type="tns:operationName" use="required"/>
    </xs:complexType>
  </xs:element>

    <xs:complexType name="documentTypeRef">
        <xs:attributeGroup ref="tns:documentTypeAttributes" />
    </xs:complexType>

    <xs:attributeGroup name="documentTypeAttributes">
        <xs:attribute name="name" type="xs:NMTOKEN" use="required"/>
        <xs:attribute name="id" type="xs:string"/>
    </xs:attributeGroup>

    <xs:complexType name="attribute">
        <xs:simpleContent>
            <xs:extension base="xs:string">
                <xs:attribute name="name" type="xs:NMTOKEN" use="required"/>
                <xs:attribute name="id" type="xs:string"/>
            </xs:extension>
        </xs:simpleContent>
    </xs:complexType>

    <xs:complexType name="metadata">
        <xs:sequence>
            <xs:element name="attribute" type="tns:attribute" minOccurs="0" maxOccurs="unbounded"/>
        </xs:sequence>
    </xs:complexType>

    <xs:complexType name="attributeRefs">
        <xs:sequence>
            <xs:element name="attribute" type="tns:tRef" minOccurs="0" maxOccurs="unbounded"/>
        </xs:sequence>
    </xs:complexType>

    <xs:simpleType name="queryLanguage">
        <xs:annotation>
            <xs:appinfo>
                <jxb:javaType name="com.tsystems.ima.fis.common.business.QueryLanguage"
                              parseMethod="com.tsystems.ima.fis.common.xml.QueryLanguageAdapter.unmarshal"
                              printMethod="com.tsystems.ima.fis.common.xml.QueryLanguageAdapter.marshal" />
            </xs:appinfo>
        </xs:annotation>
        <xs:restriction base="xs:NMTOKEN">
            <xs:enumeration value="CMISQL"/>
            <xs:enumeration value="RAQL"/>
        </xs:restriction>
    </xs:simpleType>

    <xs:simpleType name="hashAlgorithmName">
        <xs:restriction base="xs:string">
            <xs:enumeration value="MD2"/>
            <xs:enumeration value="MD5"/>
            <xs:enumeration value="SHA-1"/>
            <xs:enumeration value="SHA-224"/>
            <xs:enumeration value="SHA-256"/>
            <xs:enumeration value="SHA-384"/>
            <xs:enumeration value="SHA-512"/>
            <xs:enumeration value="SHA-512/224"/>
            <xs:enumeration value="SHA-512/256"/>
            <xs:enumeration value="SHA3-224"/>
            <xs:enumeration value="SHA3-256"/>
            <xs:enumeration value="SHA3-384"/>
            <xs:enumeration value="SHA3-512"/>
        </xs:restriction>
    </xs:simpleType>

    <xs:complexType name="contentProperty">
        <xs:simpleContent>
            <xs:extension base="xs:string">
                <xs:attribute name="key" type="xs:NMTOKEN" use="required"/>
            </xs:extension>
        </xs:simpleContent>
    </xs:complexType>

    <xs:complexType name="contentProperties">
        <xs:sequence>
            <xs:element name="property" type="tns:contentProperty" minOccurs="0" maxOccurs="unbounded"/>
        </xs:sequence>
    </xs:complexType>

    <xs:complexType name="documentType">
        <xs:sequence>
            <xs:element name="documentType" type="tns:documentTypeRef"/>
            <xs:element name="revision" type="tns:revisionType" maxOccurs="unbounded"/>
            <xs:element name="systemAttributes" type="tns:metadata" minOccurs="0"/>
        </xs:sequence>
        <xs:attribute name="documentId" type="xs:string"/>
        <xs:attribute name="creationTime" type="xs:string" use="required"/>
        <xs:attribute name="creatingUser" type="xs:string"/>
        <xs:attribute name="recycleBin" type="xs:boolean" default="false"/>
        <xs:attribute name="deletionTime" type="xs:string"/>
        <xs:attribute name="deletingUser" type="xs:string"/>
    </xs:complexType>

    <xs:complexType name="revisionType">
        <xs:sequence>
            <xs:element name="documentType" type="tns:documentTypeRef" minOccurs="0"/>
            <xs:element name="metadata" type="tns:metadata"/>
            <xs:element name="content" type="tns:contentType" minOccurs="0" maxOccurs="unbounded"/>
            <xs:element name="compoundChildren" type="tns:compoundChildrenType" minOccurs="0"/>
            <xs:element name="folderEntry" type="tns:initialFolderEntry" minOccurs="0"/>
        </xs:sequence>
        <xs:attribute name="revisionId" type="xs:string"/>
        <xs:attribute name="documentId" type="xs:string"/>
        <xs:attribute name="modificationTime" type="xs:string"/>
        <xs:attribute name="modifyingUser" type="xs:string"/>
        <xs:attribute name="isLatest" type="xs:boolean" default="true"/>
    </xs:complexType>

    <xs:complexType name="sapRevisionType">
        <xs:sequence>
            <xs:element name="metadata" type="tns:metadata"/>
            <xs:element name="systemAttributes" type="tns:metadata"/>
            <xs:element name="content" type="tns:contentType" minOccurs="0" maxOccurs="unbounded" />
        </xs:sequence>
        <xs:attribute name="revisionId" type="xs:string"/>
    </xs:complexType>

    <xs:complexType name="documentIdsType">
        <xs:sequence>
            <xs:element name="documentId" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
        </xs:sequence>
    </xs:complexType>

    <xs:complexType name="initialFolderEntry">
        <xs:sequence>
            <xs:element name="parent" type="tns:folderEntryRef"/>
            <xs:element name="name" type="xs:string"/>
        </xs:sequence>
    </xs:complexType>

    <xs:complexType name="folderEntryRef">
        <xs:attribute name="id" type="xs:NMTOKEN"/>
        <xs:attribute name="path" type="xs:string"/>
    </xs:complexType>

    <!-- type to define a update operation -->
    <xs:complexType name="updateRevisionType">
        <xs:all>
            <xs:element name="search" type="tns:search"/>
            <xs:element name="updateMetadata" type="tns:metadata" minOccurs="0"/>
            <xs:element name="updateAttributes" type="tns:metadata" minOccurs="0"/>
            <xs:element name="clearAttributes" type="tns:attributeRefs" minOccurs="0"/>
            <xs:element name="deleteAllContents" type="tns:tEmpty" minOccurs="0"/>
            <xs:element name="deleteContents" type="tns:contentsKeyRef" minOccurs="0"/>
            <xs:element name="createContents" type="tns:contents" minOccurs="0"/>
            <xs:element name="updateContents" type="tns:contents" minOccurs="0"/>
        </xs:all>
    </xs:complexType>

    <!-- type to define a update operation -->
    <xs:complexType name="bulkUpdateAttributesType">
        <xs:all>
            <xs:element name="documentType" type="tns:documentTypeRef"/>
            <xs:element name="search" type="tns:search"/>
            <xs:element name="updateAttributes" type="tns:metadata" minOccurs="0"/>
            <xs:element name="clearAttributes" type="tns:attributeRefs" minOccurs="0"/>
        </xs:all>
        <xs:attribute name="id" type="xs:string"/>
    </xs:complexType>


    <!-- type to define a smart update operation -->
    <xs:complexType name="smartUpdateRevisionType">
        <xs:all>
            <xs:element name="search" type="tns:search"/>
            <xs:element name="onCreateOnly" type="tns:tOnCreateOnly"/>
            <xs:element name="updateMetadata" type="tns:metadata" minOccurs="0"/>
            <xs:element name="updateAttributes" type="tns:metadata" minOccurs="0"/>
            <xs:element name="clearAttributes" type="tns:attributeRefs" minOccurs="0"/>
            <xs:element name="deleteAllContents" type="tns:tEmpty" minOccurs="0"/>
            <xs:element name="deleteContents" type="tns:contentsKeyRef" minOccurs="0"/>
            <xs:element name="createContents" type="tns:contents" minOccurs="0"/>
            <xs:element name="updateContents" type="tns:contents" minOccurs="0"/>
        </xs:all>
    </xs:complexType>

    <xs:complexType name="compoundChildrenType">
        <xs:sequence>
            <xs:element name="documentId" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
        </xs:sequence>
    </xs:complexType>

    <xs:complexType name="tOnCreateOnly">
        <xs:sequence>
            <xs:element name="documentType" type="tns:documentTypeRef"/>
        </xs:sequence>
    </xs:complexType>

    <xs:complexType name="contentsKeyRef">
        <xs:sequence>
            <xs:element name="content" type="tns:keyRef" maxOccurs="unbounded" />
        </xs:sequence>
    </xs:complexType>

    <xs:complexType name="contents">
        <xs:sequence>
            <xs:element name="content" type="tns:contentType" maxOccurs="unbounded" />
        </xs:sequence>
    </xs:complexType>

    <xs:complexType name="keyRef">
        <xs:attribute name="key" type="xs:NMTOKEN" use="required" />
    </xs:complexType>

    <xs:complexType name="tEmpty">
        <xs:complexContent>
          <xs:restriction base="xs:anyType">
            <xs:sequence>
            </xs:sequence>
          </xs:restriction>
        </xs:complexContent>
    </xs:complexType>

    <!--
        Operations: export, update export: Search in all revisions with
        'isLatest' = true and the given keys. Result must be one revision.
        update: The same as for export, but there can be no revision as result
        (if createDocIfNotFound = true). Implementation: Tag Metadata is used.
    -->
    <xs:complexType name="searchLatestRevisionByKey">
        <xs:sequence>
            <xs:element name="attribute" type="tns:attribute" maxOccurs="unbounded" />
        </xs:sequence>
    </xs:complexType>

    <!--
        Operations: export, update Search in all revisions with 'isLatest' =
        true and the given documentid. Result must be one revision. update:
        Implementation: Query must be created by FIS
    -->
    <xs:complexType name="searchLatestRevisionByDocumentId">
        <xs:sequence>
            <xs:element name="documentId" type="xs:string"/>
        </xs:sequence>
    </xs:complexType>

    <!--
        Operations: export, delete Search in all revisions with the given
        documentid. Result can be a number of revisions. Delete:
        Implementation: No search necessary, documentId can directly be used
        to delete the document.
    -->
    <xs:complexType name="searchAllRevisionsByDocumentId">
        <xs:sequence>
            <xs:element name="documentId" type="xs:string"/>
        </xs:sequence>
    </xs:complexType>

    <!--
        Operations: export, delete Search in all revisions with 'isLatest' =
        true and the given keys. Result can be a number of revisions. delete:
        Implementation: It's only necessary to get the documentId.
    -->
    <xs:complexType name="searchAllRevisionsByKey">
        <xs:sequence>
            <xs:element name="attribute" type="tns:attribute" maxOccurs="unbounded" />
        </xs:sequence>
    </xs:complexType>


    <!--
        Operations: export, update, delete export, Search in all revisions
        with the given revisionId. Result must be one revision. update: The
        same. Implementation: Query must be created by FIS. delete:
        Implementation: It's only necessary to get the revisionId.
    -->
    <xs:complexType name="searchByRevisionId">
        <xs:sequence>
            <xs:element name="revisionId" type="xs:string"/>
        </xs:sequence>
    </xs:complexType>

    <!--
        Operation: delete delete: Result must be of type revision. An
        additional flag indicates if the revision should be deleted or the
        complete document, it belongs to.
    -->
    <xs:complexType name="searchByQueryToDelete">
        <xs:sequence>
            <xs:element name="language" type="tns:queryLanguage"/>
            <xs:element name="query" type="xs:string"/>
            <xs:element name="deletionObjectType" type="tns:deletionObjectType"/>
        </xs:sequence>
    </xs:complexType>

    <xs:simpleType name="deletionObjectType">
        <xs:restriction base="xs:NMTOKEN">
            <xs:enumeration value="revisions"/>
            <xs:enumeration value="documents"/>
        </xs:restriction>
    </xs:simpleType>

    <!--
        Operations: export, update export: Result can be any number of objects
        of type revision or value update: ResultType must be one revision
    -->
    <xs:complexType name="searchByQuery">
        <xs:sequence>
            <xs:element name="language" type="tns:queryLanguage"/>
            <xs:element name="query" type="xs:string"/>
        </xs:sequence>
    </xs:complexType>

    <xs:complexType name="search">
        <xs:sequence>
            <xs:choice>
                <xs:element name="searchLatestRevisionByKey" type="tns:searchLatestRevisionByKey"/>
                <xs:element name="searchAllRevisionsByKey" type="tns:searchAllRevisionsByKey"/>
                <xs:element name="searchLatestRevisionByDocumentId" type="tns:searchLatestRevisionByDocumentId"/>
                <xs:element name="searchAllRevisionsByDocumentId" type="tns:searchAllRevisionsByDocumentId"/>
                <xs:element name="searchByRevisionId" type="tns:searchByRevisionId"/>
                <xs:element name="searchByQueryToDelete" type="tns:searchByQueryToDelete"/>
                <xs:element name="searchByQuery" type="tns:searchByQuery"/>
                <!-- search for sapExport or sapDelete operations -->
                <xs:element name="searchSapDocument" type="tns:sapSearch"/>
            </xs:choice>
        </xs:sequence>
        <!--
            unique id among all searches in one batch call, will be referenced in
            the result list (hits) helps to say which query is cause of which
            result
        -->
        <xs:attribute name="id" type="xs:string"/>
    </xs:complexType>

    <!-- type for SAP export query -->
    <xs:complexType name="sapSearch">
        <xs:sequence>
            <xs:element name="attribute" type="tns:sapAttribute" minOccurs="2" maxOccurs="2"/>
        </xs:sequence>
    </xs:complexType>

    <xs:complexType name="sapAttribute">
        <xs:simpleContent>
            <xs:extension base="xs:string">
                <xs:attribute name="name" type="tns:sapAttributeName" use="required"/>
            </xs:extension>
        </xs:simpleContent>
    </xs:complexType>

    <xs:simpleType name="sapAttributeName">
        <xs:restriction base="xs:NMTOKEN">
            <xs:enumeration value="_alis_access.sapdocId"/>
            <xs:enumeration value="_alis_access.contRep"/>
        </xs:restriction>
    </xs:simpleType>

    <xs:complexType name="contentType">
        <xs:sequence>
            <xs:element name="properties" type="tns:contentProperties"/>
            <xs:choice>
                <xs:element name="data" type="tns:contentDataType"/>
                <xs:element name="archive" type="tns:archiveContentRefType"/>
            </xs:choice>
        </xs:sequence>
        <xs:attribute name="key" type="xs:NMTOKEN" use="required"/>
        <xs:attribute name="primary" type="xs:boolean"/>
    </xs:complexType>

    <xs:complexType name="contentDataType">
        <xs:sequence>
            <xs:choice>
            <xs:element name="binaryObject" type="tns:binaryObjectType"/>
            <xs:element name="binaryObjectRef" type="tns:binaryObjectRefType"/>
            </xs:choice>
        </xs:sequence>
    </xs:complexType>

    <xs:complexType name="archiveContentRefType">
        <xs:sequence>
            <xs:element name="binaryObjectAttributes" type="tns:binaryObjectType"/>
            <xs:element name="archiveRef" type="tns:archiveRefType" maxOccurs="unbounded"/>
        </xs:sequence>
    </xs:complexType>

    <xs:complexType name="binaryObjectType">
        <xs:attribute name="batchFileName" type="xs:string"/>
        <xs:attribute name="originalFileName" type="xs:string" use="required"/>
        <xs:attributeGroup ref="tns:binaryDataAttributeGroup"/>
    </xs:complexType>
  
    <xs:complexType name="binaryObjectRefType">
        <xs:attribute name="blobId" type="xs:NMTOKEN" use="required"/>
         <xs:attribute name="originalFileName" type="xs:string"/>
        <xs:attributeGroup ref="tns:binaryDataAttributeGroup"/>
    </xs:complexType>

    <!--
        Binary object attributes that can be provided form the
        IntergrationService.
    -->
    <xs:attributeGroup name="binaryDataAttributeGroup">
        <xs:attribute name="fileSize" type="xs:decimal"/>
        <xs:attribute name="mimeType" type="xs:string"/>
        <xs:attribute name="fileHashDigest" type="xs:string"/>
        <xs:attribute name="hashAlgorithm" type="tns:hashAlgorithmName"/>
        <xs:attribute name="creationTime" type="xs:string"/>
        <xs:attribute name="modificationTime" type="xs:string"/>
        <xs:attribute name="id" type="xs:string"/>
    </xs:attributeGroup>

    <xs:complexType name="archiveRefType">
        <xs:attribute name="name" type="xs:string" use="required"/>
        <xs:attribute name="address" type="xs:string" use="required"/>
    </xs:complexType>

    <xs:complexType name="blobType">
    <xs:sequence>     
        <xs:element name="description" type="xs:string" minOccurs="0"/>
    </xs:sequence>
    <xs:attributeGroup ref="tns:blobAttributes"/>
    </xs:complexType>

    <xs:attributeGroup name="blobAttributes">
        <xs:attribute name="blobId" type="xs:NMTOKEN" use="required"/>
        <xs:attribute name="batchFileName" type="xs:string"/>
        <xs:attribute name="fileSize" type="xs:long"/>
        <xs:attribute name="fileHashDigest" type="xs:string"/>
        <xs:attribute name="hashAlgorithm" type="tns:hashAlgorithmName"/>
    </xs:attributeGroup>

    <!-- Operations to be supported by FIS -->
    <xs:simpleType name="operationName">
        <xs:restriction base="xs:NMTOKEN">
            <xs:enumeration value="archive"/>
            <xs:enumeration value="update"/>
            <xs:enumeration value="smartUpdate"/>
            <xs:enumeration value="export"/>
            <xs:enumeration value="delete"/>
            <xs:enumeration value="registerBlob"/>
            <xs:enumeration value="unregisterBlob"/>
            <xs:enumeration value="bulkUpdateAttributes"/>
            <xs:enumeration value="sapArchive"/>
            <xs:enumeration value="sapExport"/>
            <xs:enumeration value="sapDelete"/>
            <xs:enumeration value="migrate"/>
            <xs:enumeration value="deleteMigrated"/>
        </xs:restriction>
    </xs:simpleType>

    <!--
        The structure for the contents of the result file for export
        operations
    -->
    <xs:element name="result">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="searchResult" type="tns:searchResult" minOccurs="0" maxOccurs="unbounded"/>
            </xs:sequence>
            <xs:attribute name="operationName" type="tns:operationName" use="required"/>
        </xs:complexType>
    </xs:element>

    <!--
        Since we can have 1-n queries in a export definition file we collect
        all hits for a query under the searchId. So we can have multiple hits
        tags in a result file.
    -->
    <xs:complexType name="searchResult">
        <xs:sequence>
            <xs:element name="hit" type="tns:hit" minOccurs="0" maxOccurs="unbounded"/>
        </xs:sequence>
        <!--
            references to the search - there can be many in one batch operation
        -->
        <xs:attribute name="searchId" type="xs:string" use="required"/>
    </xs:complexType>

    <!-- One hit from a query which can consist of 1-n  items. -->
    <xs:complexType name="hit">
        <xs:sequence>
            <xs:element name="item" type="tns:item" maxOccurs="unbounded"/>
        </xs:sequence>
        <!-- Ascending number of all hits of the complete result set -->
        <xs:attribute name="no" type="xs:integer" use="required"/>
        <!--
            only used for revisions, which must be stored in the file system
        -->
        <xs:attribute name="section" type="xs:string" use="required"/>
    </xs:complexType>

    <!--
        This is the basic unit to be returned from the hit. A hit can have
        more than one item.
    -->
    <xs:complexType name="item">
        <xs:sequence>
            <xs:choice>
                <xs:element name="literal" type="xs:string"/>
                <xs:element name="revision" type="tns:revisionType"/>
                <xs:element name="sapRevision" type="tns:sapRevisionType"/>
                <xs:element name="documentType" type="tns:tDocumentType"/>
            </xs:choice>
        </xs:sequence>
        <!--  This is the item number from the hit -->
        <xs:attribute name="no" type="xs:integer" use="required"/>
        <!-- Is the column name of the query -->
        <xs:attribute name="projection" type="xs:string"/>
    </xs:complexType>


    <!-- #################################################### -->
    <!-- Define complete document type for the export option. -->
    <!-- Copied from ImaISCore.xsd for completeness.          -->
    <!-- #################################################### -->
    <xs:complexType name="tDocumentType">
        <xs:sequence>
            <xs:element name="attributes" type="tns:tAttributeDefinitions">
                <xs:annotation>
                    <xs:documentation>The attribute definitions of the document type.
                    </xs:documentation>
                </xs:annotation>
            </xs:element>
            <xs:element name="links" type="tns:tLinks" minOccurs="0">
                <xs:annotation>
                    <xs:documentation>The metadata links of this document type.
                    </xs:documentation>
                </xs:annotation>
            </xs:element>
            <xs:element name="description" type="xs:string">
                <xs:annotation>
                    <xs:documentation>The description for the document type.
                    </xs:documentation>
                </xs:annotation>
            </xs:element>
        </xs:sequence>
        <xs:attributeGroup ref="tns:identifierAttributes"/>
        <xs:attribute name="isSystemType" type="xs:boolean" use="required">
            <xs:annotation>
                <xs:documentation>Whether the document type is a system type.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="searchMode" type="xs:NMTOKEN" use="required">
            <xs:annotation>
                <xs:documentation>The way the document type should be indexed for searching.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
    </xs:complexType>

    <xs:complexType name="tIncomingLinks">
        <xs:sequence>
            <xs:element name="link" type="tns:tIncomingLink"
                        minOccurs="0" maxOccurs="unbounded">
                <xs:annotation>
                    <xs:documentation>The list of metadata link definitions.
                    </xs:documentation>
                </xs:annotation>
            </xs:element>
        </xs:sequence>
    </xs:complexType>

    <xs:complexType name="tLinks">
        <xs:sequence>
            <xs:element name="link" type="tns:tLink"
                        minOccurs="0" maxOccurs="unbounded">
                <xs:annotation>
                    <xs:documentation>The list of metadata link definitions.
                    </xs:documentation>
                </xs:annotation>
            </xs:element>
        </xs:sequence>
    </xs:complexType>

    <xs:complexType name="tIncomingLink">
        <xs:sequence>
            <xs:element name="targetDocumentType" type="tns:tRef">
                <xs:annotation>
                    <xs:documentation>
                        The target document type of the link.
                    </xs:documentation>
                </xs:annotation>
            </xs:element>
            <xs:element name="resolver" type="tns:tLinkResolver">
                <xs:annotation>
                    <xs:documentation>
                        The method to resolve the target revision or document of the link.
                    </xs:documentation>
                </xs:annotation>
            </xs:element>
            <xs:element name="description" type="xs:string">
                <xs:annotation>
                    <xs:documentation>
                        The description for the link.
                    </xs:documentation>
                </xs:annotation>
            </xs:element>
        </xs:sequence>
        <xs:attribute name="name" type="xs:NMTOKEN" use="required">
            <xs:annotation>
                <xs:documentation>The link's name.</xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="mode" type="xs:NMTOKEN" use="required">
            <xs:annotation>
                <xs:documentation>The kind of revision in the target document to which to link.</xs:documentation>
            </xs:annotation>
        </xs:attribute>
    </xs:complexType>

    <xs:complexType name="tLink">
        <xs:complexContent>
            <xs:extension base="tns:tIncomingLink">
                <xs:sequence>
                </xs:sequence>
                <xs:attribute name="id" type="xs:NMTOKEN" use="required">
                    <xs:annotation>
                        <xs:documentation>The unique id of the link.</xs:documentation>
                    </xs:annotation>
                </xs:attribute>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>

    <xs:complexType name="tLinkResolver">
        <xs:choice>
            <xs:element name="attributes" type="tns:tLinkResolverAttributes" minOccurs="0" maxOccurs="unbounded">
                <xs:annotation>
                    <xs:documentation>
                        The link is resolved by comparing attributes on the source and target revision.
                        The attributes must match and uniquely identify the target revision/document for the link.
                    </xs:documentation>
                </xs:annotation>
            </xs:element>
            <xs:element name="query" type="xs:string" minOccurs="0" maxOccurs="unbounded">
                <xs:annotation>
                    <xs:documentation>
                        The link is resolved by executing the specified query. The query must result in exactly one revision or
                        document. The source revision of the link to resolved is put in the params:createRevision galaxy.
                    </xs:documentation>
                </xs:annotation>
            </xs:element>
            <xs:element name="extension" type="xs:string" minOccurs="0" maxOccurs="unbounded">
                <xs:annotation>
                    <xs:documentation>
                        The link is resolved by a project specific extension. Needed settings for the extension can be specified
                        in this element.
                    </xs:documentation>
                </xs:annotation>
            </xs:element>
        </xs:choice>
    </xs:complexType>

    <xs:complexType name="tLinkResolverAttributes">
        <xs:attribute name="sourceKey" type="xs:NMTOKEN" use="required">
            <xs:annotation>
                <xs:documentation>
                    The name of the attribute in the source document type that establishes the link.
                    This attribute must have minOccurs=maxOccurs=1
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="targetKey" type="xs:NMTOKEN" use="required">
            <xs:annotation>
                <xs:documentation>
                    The name of the attribute in the target document type that establishes the link.
                    This attribute must have minOccurs=maxOccurs=1
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
    </xs:complexType>

    <xs:complexType name="tIncomingAttributeDefinitions">
        <xs:sequence>
            <xs:choice minOccurs="0" maxOccurs="unbounded">
                <xs:element name="attribute" type="tns:tIncomingAttributeDefinition">
                    <xs:annotation>
                        <xs:documentation>An attribute definition.
                        </xs:documentation>
                    </xs:annotation>
                </xs:element>
                <xs:element name="linkedAttribute" type="tns:tIncomingLinkedAttributeDefinition">
                    <xs:annotation>
                        <xs:documentation>An attribute linked to another document type.
                        </xs:documentation>
                    </xs:annotation>
                </xs:element>
            </xs:choice>
        </xs:sequence>
    </xs:complexType>

    <xs:complexType name="tIncomingAttributeDefinition">
        <xs:complexContent>
            <xs:extension base="tns:tBaseAttributeDefinition">
                <xs:sequence>
                    <xs:element name="constraints" type="tns:tIncomingConstraints" minOccurs="0">
                        <xs:annotation>
                            <xs:documentation>The list of constraints attached to this attribute definition.</xs:documentation>
                        </xs:annotation>
                    </xs:element>
                </xs:sequence>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>

    <xs:complexType name="tIncomingLinkedAttributeDefinition">
        <xs:sequence>
            <xs:element name="link" type="tns:tRef">
                <xs:annotation>
                    <xs:documentation>
                        Reference to the link used for this attribute. Only a name can be specified.
                        A link with the specified name must be present on the document type to be created.
                    </xs:documentation>
                </xs:annotation>
            </xs:element>
            <xs:element name="targetAttribute" type="tns:tRef">
                <xs:annotation>
                    <xs:documentation>
                        References the attribute in the target document type of the link to which this
                        attribute should be linked. The reference can be made by id or name.
                        If both - name and id - are present they must match.
                    </xs:documentation>
                </xs:annotation>
            </xs:element>
            <xs:element name="description" type="xs:string">
                <xs:annotation>
                    <xs:documentation>
                        The description for the attribute.
                    </xs:documentation>
                </xs:annotation>
            </xs:element>
        </xs:sequence>
        <xs:attribute name="name" type="xs:NMTOKEN" use="required">
            <xs:annotation>
                <xs:documentation>The attribute's name.</xs:documentation>
            </xs:annotation>
        </xs:attribute>
    </xs:complexType>

    <xs:complexType name="tAttributeDefinitions">
        <xs:sequence>
            <xs:choice minOccurs="0" maxOccurs="unbounded">
                <xs:element name="attribute" type="tns:tAttributeDefinition">
                    <xs:annotation>
                        <xs:documentation>An attribute definition.
                        </xs:documentation>
                    </xs:annotation>
                </xs:element>
                <xs:element name="linkedAttribute" type="tns:tLinkedAttributeDefinition">
                    <xs:annotation>
                        <xs:documentation>An attribute linked to another document type.
                        </xs:documentation>
                    </xs:annotation>
                </xs:element>
            </xs:choice>
        </xs:sequence>
    </xs:complexType>

    <xs:complexType name="tBaseAttributeDefinition">
        <xs:sequence>
            <xs:element name="type" type="tns:tRef">
                <xs:annotation>
                    <xs:documentation>References the attribute type by id or by name. The
                        attribute type should already exist. If both - name and id - are
                        present they should match.</xs:documentation>
                </xs:annotation>
            </xs:element>
            <xs:element name="description" type="xs:string">
                <xs:annotation>
                    <xs:documentation>
                        The description for the attribute.
                    </xs:documentation>
                </xs:annotation>
            </xs:element>
        </xs:sequence>
        <xs:attribute name="name" type="xs:NMTOKEN" use="required">
            <xs:annotation>
                <xs:documentation>The attribute's name.</xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="isKey" type="xs:boolean" use="required">
            <xs:annotation>
                <xs:documentation>Whether the attribute is a key attribute for the
                    document type.</xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attributeGroup ref="tns:multiValueSpecificationAttributes"/>
    </xs:complexType>

    <xs:complexType name="tAttributeDefinition">
        <xs:complexContent>
            <xs:extension base="tns:tBaseAttributeDefinition">
                <xs:sequence>
                    <xs:element name="constraints" type="tns:tConstraints">
                        <xs:annotation>
                            <xs:documentation>The list of constraints attached to this attribute definition.</xs:documentation>
                        </xs:annotation>
                    </xs:element>
                </xs:sequence>
                <xs:attribute name="id" type="xs:NMTOKEN" use="optional">
                    <xs:annotation>
                        <xs:documentation>The attribute definition's UUID.
                        </xs:documentation>
                    </xs:annotation>
                </xs:attribute>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>

    <xs:complexType name="tLinkedAttributeDefinition">
        <xs:complexContent>
            <xs:extension base="tns:tIncomingLinkedAttributeDefinition">
                <xs:attribute name="id" type="xs:NMTOKEN" use="optional">
                    <xs:annotation>
                        <xs:documentation>The attribute definition's UUID.
                        </xs:documentation>
                    </xs:annotation>
                </xs:attribute>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>

    <xs:complexType name="tConstraints">
        <xs:sequence>
            <xs:element name="constraint" type="tns:tConstraint"
                        minOccurs="0" maxOccurs="unbounded">
                <xs:annotation>
                    <xs:documentation>The list of constraints.
                    </xs:documentation>
                </xs:annotation>
            </xs:element>
        </xs:sequence>
    </xs:complexType>

    <xs:complexType name="tIncomingConstraints">
        <xs:sequence>
            <xs:element name="constraint" type="tns:tIncomingConstraint"
                        minOccurs="0" maxOccurs="unbounded">
                <xs:annotation>
                    <xs:documentation>The list of constraints.
                    </xs:documentation>
                </xs:annotation>
            </xs:element>
        </xs:sequence>
    </xs:complexType>

    <xs:complexType name="tIncomingConstraint">
        <xs:sequence>
            <xs:element name="settings" type="xs:string" minOccurs="0" maxOccurs="unbounded">
                <xs:annotation>
                    <xs:documentation>The (list of) constraint settings.</xs:documentation>
                </xs:annotation>
            </xs:element>
        </xs:sequence>
        <xs:attribute name="checker" type="xs:NMTOKEN" use="required">
            <xs:annotation>
                <xs:documentation>The constraint checker name.</xs:documentation>
            </xs:annotation>
        </xs:attribute>
    </xs:complexType>

    <xs:complexType name="tConstraint">
        <xs:complexContent>
            <xs:extension base="tns:tIncomingConstraint">
                <xs:attribute name="id" type="xs:NMTOKEN" use="required">
                    <xs:annotation>
                        <xs:documentation>The UUID that identifies this constraint.</xs:documentation>
                    </xs:annotation>
                </xs:attribute>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>

    <xs:attributeGroup name="multiValueSpecificationAttributes">
        <xs:attribute name="minOccurs" type="xs:nonNegativeInteger"
                      use="required">
            <xs:annotation>
                <xs:documentation>The attribute's minimum occurrence. It should be
                    greater equal 0 and lower equal maxOccurs.</xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="maxOccurs" type="tns:tNaturalNumbers" use="required">
            <xs:annotation>
                <xs:documentation>The attribute's maximum occurrence. It should be
                    greater equal minOccurs or 'unbounded'.</xs:documentation>
            </xs:annotation>
        </xs:attribute>
    </xs:attributeGroup>

    <xs:simpleType name="tNaturalNumbers">
        <xs:union memberTypes="xs:nonNegativeInteger">
            <xs:simpleType>
                <xs:restriction base="xs:NMTOKEN">
                    <xs:enumeration value="unbounded" />
                </xs:restriction>
            </xs:simpleType>
        </xs:union>
    </xs:simpleType>

    <xs:complexType name="tRef">
        <xs:attributeGroup ref="tns:identifierAttributes" />
    </xs:complexType>

    <xs:attributeGroup name="identifierAttributes">
        <xs:attribute name="name" type="xs:NMTOKEN" use="optional">
            <xs:annotation>
                <xs:documentation>The object's name.</xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="id" type="xs:NMTOKEN" use="optional">
            <xs:annotation>
                <xs:documentation>The object's UUID</xs:documentation>
            </xs:annotation>
        </xs:attribute>
    </xs:attributeGroup>
</xs:schema>