Datastream typechecking for the Content Model Architecture

Traditionally in Fedora, all data objects was just data objects, there were no types of objects. This changed with the introduction of the Content Model Architecture.

DS-COMPOSITE datastream

Content Models may contain this reserved datastream. It lists the datastreams that must exist in subscribing data objects. Other than declaring the existence of the datastreams, little else can be specified. The MIME type and the format uri are the only specification that can be used by default.

The schema for the datastream can be seen below.

<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:sequence>
            <xsd:attribute name="ID" use="required" type="xsd:NCName"/>
        </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:schema>

The content of a DS-COMPOSITE datastream could look like this

<dsCompositeModel
        xmlns="info:fedora/fedora-system:def/dsCompositeModel#">
    <dsTypeModel ID="DC">
        <form MIME="text/xml"/>
    </dsTypeModel>
    <dsTypeModel ID="STATE">
        <form MIME="text/xml"/>
    </dsTypeModel>
</dsCompositeModel>

Allowing extensions in DS-COMPOSITE

Since Fedora already use DS-COMPOSITE to declare the existence of datastreams, it is the natural location to specify restrictions on the contents of datastreams. Unfortunately, the schema for the DS-COMPOSITE datastream does not allow for any extra content, To that effect, we have made a small change to the schema.

<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"/>

          <!--Changes begin-->
        <xsd:element minOccurs="0" maxOccurs="1" ref="extensions">
          <!--Changes end-->

        </xsd:element>
      </xsd:sequence>
      <xsd:attribute name="ID" use="required" type="xsd:NCName"/>
    </xsd:complexType>
  </xsd:element>

    <!-- Changes begin -->
  <xsd:element name="extensions">
    <xsd:complexType>
      <xsd:sequence>
         <xsd:any namespace="##any" processContents="skip" minOccurs="0" maxOccurs="unbounded"/>
      </xsd:sequence>
      <xsd:attribute name="name" use="optional"/>
    </xsd:complexType>
  </xsd:element>
    <!--Changes end-->

  <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:schema>

With this changed schema, the contents could look like this:

<dsCompositeModel
        xmlns="info:fedora/fedora-system:def/dsCompositeModel#">

    <dsTypeModel ID="DC">
        <form MIME="text/xml"/>
        <extensions name="DOMS">
 
        </extensions>
    </dsTypeModel>
    <dsTypeModel ID="STATE">
        <form MIME="text/xml"/>
        <extensions name="DOMS">

        </extensions>
    </dsTypeModel>
</dsCompositeModel>

What is noteworthy here is that the <dsTypeModel> and the <form> elements are left unchanged. The Fedora code, working with DS-COMPOSITE only looks for these tags, so the new schema will not cause conflicts, and the extensions will be quietly ignored. This is exactly as we want, this change should not make our objects incompatible with an unmodified Fedora.