<?xml version="1.0" encoding="UTF-8"?>
<!--
  +===========================================================================+
  |                                                                           |
  |                    NATIONAL GEOSPATIAL DIGITAL ARCHIVE                    |
  |                 University of California at Santa Barbara                 |
  |                                                                           |
  +===========================================================================+
-->
<!-- $Header: /export/home/gjanee/ngda/data-model/RCS/template.rnc,v 1.2 2006/02/15 18:08:40 gjanee Exp $ -->
<!--
  DESCRIPTION
  
      RELAX NG schema for archival object templates.
  
      A template defines the common structure of a class of objects.
      It is essentially identical to a manifest, except that
      quantities that are specific to individual objects (object
      identifiers, file sizes, etc.) are not present, and in a
      template components may be marked as optional.
  
      A template is purely an ingest aid.  An archival object may, at
      any time, deviate from the structure specified by an associated
      template.
  
      Storage note: the storage of templates has been left
      deliberately ambiguous in this specification.  Templates may be
      stored as archival objects in the archive, or, they may be
      stored by the archive server by any other means.  The only
      requirement either way is that they be referencable by URI.
  
      If a template is stored as an archival object, the recommended
      representation is to store it as a file named "template.xml" in
      the archival object's root directory.  In other words, templates
      adhere to the following meta-template:
  
          <template>
            <templateIdentifier>meta-template</templateIdentifier>
            <file>
              <name>template.xml</name>
              <definitionRef> (this specification) </definitionRef>
            </file>
          </template>
  
  AUTHOR
  
      Greg Janee
      gjanee@alexandria.ucsb.edu
  
  HISTORY
  
      $Log: template.rnc,v $
      Revision 1.2  2006/02/15 18:08:40  gjanee
      Parallel changes to match those made to manifest.rnc.  Also,
      added an "optional" attribute to components.  This schema is
      fully backward-compatible with the previous version except for
      the version change in the XML namespace.  (There is a new
      restriction on object identifiers that is not
      backward-compatible in theory, but in practice the change should
      have no implications.)
  
      Revision 1.1  2005/11/14 00:38:13  gjanee
      Initial revision
  
-->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="tag:ngda.org,2005:schemas/1.1/template" xmlns:template="tag:ngda.org,2005:schemas/1.1/template">
  <!-- Note that the identifier here identifies the template. -->
  <xs:element name="template">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="template:templateIdentifier"/>
        <xs:element minOccurs="0" maxOccurs="unbounded" ref="template:relationship"/>
        <xs:element minOccurs="0" maxOccurs="unbounded" ref="template:definitionRef"/>
        <xs:element minOccurs="0" ref="template:lineage"/>
        <xs:element minOccurs="0" maxOccurs="unbounded" ref="template:Component"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="templateIdentifier" type="xs:anyURI"/>
  <xs:element name="relationship">
    <xs:complexType>
      <xs:attribute name="type" use="required"/>
      <xs:attribute name="targetObjectRef" use="required" type="xs:anyURI"/>
    </xs:complexType>
  </xs:element>
  <xs:element name="Component" abstract="true" type="template:CommonComponentElements"/>
  <xs:complexType name="CommonComponentElements">
    <xs:sequence>
      <xs:element ref="template:name"/>
      <xs:element minOccurs="0" maxOccurs="unbounded" ref="template:definitionRef"/>
      <xs:element minOccurs="0" ref="template:lineage"/>
    </xs:sequence>
    <xs:attribute name="optional" default="false" type="xs:boolean"/>
  </xs:complexType>
  <xs:element name="name" type="xs:NCName"/>
  <xs:element name="directory" substitutionGroup="template:Component">
    <xs:complexType>
      <xs:complexContent>
        <xs:extension base="template:CommonComponentElements">
          <xs:sequence>
            <xs:element minOccurs="0" maxOccurs="unbounded" ref="template:Component"/>
          </xs:sequence>
          <xs:attribute name="type" use="required">
            <xs:simpleType>
              <xs:restriction base="xs:token">
                <xs:enumeration value="subcomponents"/>
                <xs:enumeration value="alternatives"/>
              </xs:restriction>
            </xs:simpleType>
          </xs:attribute>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>
  <xs:element name="file" substitutionGroup="template:Component"/>
  <xs:element name="definitionRef" type="xs:anyURI"/>
  <xs:element name="lineage">
    <xs:complexType>
      <xs:sequence>
        <xs:element minOccurs="0" maxOccurs="unbounded" ref="template:sourceComponentRef"/>
        <xs:element minOccurs="0" ref="template:notes"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="sourceComponentRef" type="xs:anyURI"/>
  <xs:element name="notes" type="xs:string"/>
  <!--
    The extra-schema validity checks listed in manifest.rnc apply to
    templates as well.
  -->
</xs:schema>
