<?xml version = "1.0" encoding = "UTF-8"?>
<!--
	#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	#
	# Copyright (C) 2003-2008 Open Microscopy Environment
	#       Massachusetts Institute of Technology,
	#       National Institutes of Health,
	#       University of Dundee,
	#       University of Wisconsin at Madison
	#
	#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-->
<!--
	#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	# Written by:  Josiah Johnston <siah@nih.gov>, Andrew J Patterson
	#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-->
<xsd:schema 
	xmlns:xsd = "http://www.w3.org/2001/XMLSchema"
	targetNamespace = "http://www.openmicroscopy.org/Schemas/BinaryFile/2008-09"
	xmlns:Bin = "http://www.openmicroscopy.org/Schemas/BinaryFile/2008-09"
	xmlns:xml="http://www.w3.org/XML/1998/namespace"
	version = "1"
	elementFormDefault = "qualified">
	<xsd:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="http://www.w3.org/2001/xml.xsd"/>
	<xsd:annotation>
		<xsd:documentation>
			The elements in this file are not yet represented by classes in the EA diagrams - ajp
		</xsd:documentation>
	</xsd:annotation>
	<xsd:element name = "External"> <!-- top level definition -->
		<xsd:annotation>
			<xsd:documentation>Describes a file location.  Can optionally specify a portion of a file using Offset and a ReadLength.
If Offset and ReadLength are specified in conjuction with Compression, then they point into the uncompressed file.
			</xsd:documentation>
		</xsd:annotation>
		<xsd:complexType>
			<xsd:attribute name = "href" use = "required" type = "xsd:anyURI">
				<xsd:annotation>
					<xsd:documentation>file location</xsd:documentation>
				</xsd:annotation>
			</xsd:attribute>
			<xsd:attribute name = "SHA1" use = "required" type = "Bin:Hex40">
				<xsd:annotation>
					<xsd:documentation>The digest of the file specified in href.</xsd:documentation>
				</xsd:annotation>
			</xsd:attribute>
			<xsd:attribute name = "Compression" default = "none" use="optional">
				<xsd:annotation>
					<xsd:documentation>Specifies the compression scheme used to encode the data.</xsd:documentation>
				</xsd:annotation>
				<xsd:simpleType>
					<xsd:restriction base = "xsd:string">
						<xsd:enumeration value = "zlib"/>
						<xsd:enumeration value = "bzip2"/>
						<xsd:enumeration value = "none"/>
					</xsd:restriction>
				</xsd:simpleType>
			</xsd:attribute>
		</xsd:complexType>
	</xsd:element>
	<xsd:element name = "BinData"> <!-- top level definition -->
		<xsd:annotation>
			<xsd:documentation>The contents of this element are base64-encoded.  These are not CDATA sections, just a base64 stream.</xsd:documentation>
		</xsd:annotation>
		<xsd:complexType>
			<xsd:simpleContent>
				<xsd:extension base = "xsd:base64Binary">
					<xsd:attribute name = "Compression" default = "none" use="optional">
						<xsd:annotation>
							<xsd:documentation>Specifies the compression scheme used to encode the data. </xsd:documentation>
						</xsd:annotation>
						<xsd:simpleType>
							<xsd:restriction base = "xsd:string">
								<xsd:enumeration value = "zlib"/>
								<xsd:enumeration value = "bzip2"/>
								<xsd:enumeration value = "none"/>
							</xsd:restriction>
						</xsd:simpleType>
					</xsd:attribute>
					<xsd:attribute name="Length" use="required">
						<xsd:annotation>
							<xsd:documentation>Character count attribute for the BinData field. This is the length of the base-64 encoded block. It allows easy skipping of the block when parsing the file.
							Added in response to Evolution document - ajp</xsd:documentation>
						</xsd:annotation>
						<xsd:simpleType>
							<xsd:restriction base="xsd:nonNegativeInteger">
							</xsd:restriction>
						</xsd:simpleType>
					</xsd:attribute>
				</xsd:extension>
			</xsd:simpleContent>
		</xsd:complexType>
	</xsd:element>
	<xsd:element name = "BinaryFile"> <!-- top level definition -->
		<xsd:annotation>
			<xsd:documentation>Describes a binary file.</xsd:documentation>
		</xsd:annotation>
		<xsd:complexType>
			<xsd:choice minOccurs="1" maxOccurs="1">
				<xsd:element ref = "Bin:External" minOccurs="1" maxOccurs="1"/>
				<xsd:element ref = "Bin:BinData" minOccurs="1" maxOccurs="1"/>
			</xsd:choice>
			<xsd:attribute name = "FileName" use = "required">
				<xsd:simpleType>
					<xsd:restriction base = "xsd:string">
						<xsd:maxLength value = "64"/>
					</xsd:restriction>
				</xsd:simpleType>
			</xsd:attribute>
			<xsd:attribute name = "Size" use = "required" type = "xsd:integer">
				<xsd:annotation>
					<xsd:documentation>Size (in bytes) of the uncompressed file.</xsd:documentation>
				</xsd:annotation>
			</xsd:attribute>
		</xsd:complexType>
	</xsd:element>
	<xsd:simpleType name = "Hex40">
		<xsd:restriction base = "xsd:hexBinary">
			<xsd:length value = "20"/>
		</xsd:restriction>
	</xsd:simpleType>
</xsd:schema>
