<?xml version="1.0" encoding="UTF-8"?>
<!--
About this Schema:
  This schema describes the "Datastream Composite Model" format,
  a format for specifying the datastream requirements of a Fedora content
  model.  Example instances of this format can be found within the
  demo content model objects.  These datastreams have ID "DS_COMPOSITE_MODEL"
  and FORMAT_URI "info:fedora/fedora-system:FedoraDSCompositeModel-1.0".

Syntax:
  The root element, [dsCompositeModel], may contain any number of [dsTypeModel]
  child elements.  Each [dsTypeModel] element must have an ID attribute, denothing the
  name of the datastream, and an "optional" attribute.,
  The element and may contain any number of [form] child elements and [extension] child
  elements. Each [form] element may have a FORMAT_URI attribute and/or a MIME attribute.
  Each [extension] element must have a name attribute, and can contain arbitrary xml.
  Two extension names have been reserved, "Ontology" and "Schema".

Semantics:
  A [dsCompositeModel] specifies a minimal set of datastream requirements that
  must be met by conforming objects.  If the set of requirements is met,
  an object can be said to conform to the model.  Note that conforming objects
  may contain additional datastreams that are not required by the model.

  A [dsTypeModel] specifies the ID of a datastream that must exist in
  conforming objects, and optionally, a set of format requirements, via
  the [form] element. Additional requirements can be specified via the 
  [extension] element.

  The reserved [extension] "Schema" specify a schema for the contents of the
  datastream. Upon validation, the schema will be read and the datastream
  checked against it.

  The reserved [extension] "Ontology" specify restrictions on the relations of the
  datastream, which can be expressed in the datastream RELS-INT.


  For a given [dsTypeModel]:
  - If no [form] child elements are present, the model does not constrain
    the format of conforming datastreams.
  - If one or more [form] child elements are present, conforming datastreams
    must match at least one.
  - If the "optional" attribute is true, it is not regarded as an error, if the datastream
    does not exist.
  - If one or more the "Schema" [extension] elements are present, conforming datastreams
     must match at least one.
  - There can only be one "Ontology" [extension].
    
  For a given [form]:
  - A candidate datastream matches if the datastream's MIME type matches
    that given in the MIME attribute (if any), AND the datastream's
    FORMAT_URI matches that given in the FORMAT_URI attribute (if any).
  - If the MIME attribute is not present, the candidate datastream's MIME type
    is not constrained by that format requirement.
  - If the FORMAT_URI attribute is not present, the candidate datastream's
    FORMAT_URI is not constrained by that format requirement.
-->
<xsd:schema
        targetNamespace="info:fedora/fedora-system:def/dsCompositeModel#"
        xmlns="info:fedora/fedora-system:def/dsCompositeModel#"
        xmlns:xsd="http://www.w3.org/2001/XMLSchema"
        elementFormDefault="qualified"
        attributeFormDefault="unqualified">
    <xsd:element name="dsCompositeModel">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element minOccurs="0" maxOccurs="unbounded" ref="dsTypeModel"/>
            </xsd:sequence>
        </xsd:complexType>
    </xsd:element>
    <xsd:element name="dsTypeModel">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element minOccurs="0" maxOccurs="unbounded" ref="form"/>
                <xsd:element minOccurs="0" maxOccurs="unbounded" ref="extension"/>
            </xsd:sequence>
            <xsd:attribute name="ID" use="required"/>
            <xsd:attribute name="optional" use="optional" type="xsd:boolean"/>
        </xsd:complexType>
    </xsd:element>
    <xsd:element name="extension">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:any namespace="##any" processContents="skip" minOccurs="0" maxOccurs="unbounded"/>
            </xsd:sequence>
            <xsd:attribute name="name" use="required"/>
        </xsd:complexType>
    </xsd:element>
    <xsd:element name="form">
        <xsd:complexType>
            <xsd:attribute name="FORMAT_URI" use="optional" type="xsd:anyURI"/>
            <xsd:attribute name="MIME" use="optional"/>
        </xsd:complexType>
    </xsd:element>
    <xsd:element name="reference">
        <xsd:complexType>
            <xsd:attribute name="type"/>
            <xsd:attribute name="datastream"/>
        </xsd:complexType>
    </xsd:element>
</xsd:schema>

