<?xml version="1.0"?>
<!-- This Relax NG schema is used to validate service responce for getLineage -->
<grammar xmlns="http://relaxng.org/ns/structure/1.0" xmlns:es3="http://es3.bren.ucsb.edu/ES3/ns/structure/1.0">
	<start>
		<element name="ES3Response" xmlns="http://relaxng.org/ns/structure/1.0">
			<attribute name="type"/>
			<oneOrMore>
				<element name="link">
					<es3:annotation>An ES3 link contains a source ('from') and destination ('to') and has a single direction.
						Links must be organized in a Directed Acyclic Graph, such that a link does point backward in the
						graph, thereby creating a loop. The source and destination of a link are ES3 object which are
						identified by a UUID.
						</es3:annotation>
					<optional>
						<attribute name="type"/>
					</optional>
					<interleave>
						<element name="to">
							<es3:annotation>This is the destination of a link object. The 'to' object can contain
								 an ES3 'file' or 'transformation' object.
								</es3:annotation>
							<choice>
								<ref name="file"/>
								<ref name="transformation"/>
							</choice>
						</element>
						<element name="from">
							<es3:annotation>This is the source of a link object. The 'from' object can contain
								an ES3 'file' or 'transformation' object.
								</es3:annotation>
							<choice>
								<ref name="file"/>
								<ref name="transformation"/>
							</choice>
						</element>
					</interleave>
				</element>
			</oneOrMore>
			<optional>
				<element name="unlinked">
					<es3:annotation>An unlinked object in one that is not referenced by any link, but is contained in a workflow.
						</es3:annotation>
					<oneOrMore>
						<choice>
							<ref name="file"/>
							<ref name="transformation"/>
						</choice>
					</oneOrMore>
				</element>
			</optional>
		</element>
	</start>
	
	<define name="file">
		<element name="file">
			<es3:annotation>An ES3 'file' object represents a file that has been read or written by a data transformation.
			</es3:annotation>
			<interleave>
				<element name="workflowUuid">
					<text/>
				</element>
				<oneOrMore>
					<element name="domain">
						<es3:annotation>File 'domains' are well known domains such as 'URL' or 'local file system'. ES3
							will accept any domain name that the client/user wishes to use.
						</es3:annotation>
						<attribute name="name"/>
						<es3:annotation>The domain name, such as "URL"
						</es3:annotation>
						<zeroOrMore>
							<attribute name="reference">
								<es3:annotation>A URL that provides information about
									the domain.</es3:annotation>
							</attribute>
						</zeroOrMore>
						<element name="identifier">
							<es3:annotation>The identifier for this file object that identifies it within the domain.
								</es3:annotation>
							<text/>
						</element>
					</element>
				</oneOrMore>
				<optional>
					<element name="size">
						<attribute name="units"/>
						<text/>
					</element>
				</optional>
				<optional>
					<element name="compressedSize">
						<attribute name="units"/>
						<text/>
					</element>
				</optional>
				<element name="uuid">
					<text/>
				</element>
			</interleave>
		</element>
	</define>
	
	<define name="anything">
		<zeroOrMore>
			<choice>
				<element>
					<anyName/>
					<ref name="anything"/>
				</element>
				<attribute>
					<anyName/>
				</attribute>
				<text/>
			</choice>
		</zeroOrMore>
	</define>
	
	<define name="transformation">
		<element name="transformation">
			<es3:annotation>An ES3 data transformation object.
				</es3:annotation>
			<optional>
				<attribute name="type"/>
			</optional>
			<interleave>
				<optional>
					<element name="timestamp">
						<attribute name="type"/>
						<text/>
					</element>
				</optional>
				<element name="collection">
					<es3:annotation>Transformations are grouped inside ES3 in collections which are designated by a
					directory-like name, i.e. '/painter/modscag/sierra'
					</es3:annotation>
					<text/>
				</element>
				<element name="uuid">
					<text/>
				</element>
				<element name="workflowUuid">
					<es3:annotation>The workflow that this transformation belongs to.
						</es3:annotation>
					<text/>
				</element>
				<optional>
					<element name="containsWorkflowUuid">
						<es3:annotation>An ES3 data transformation may contain a workflow, thus creating a nested structure.
						</es3:annotation>
						<text/>
					</element>
				</optional>
				<element name="name">
					<es3:annotation>The name of the data transformation. The ES3 probulator usually assigns the filename
						portion of a file path as the transformation's name.
					</es3:annotation>
					<text/>
				</element>
				<optional>
					<element name="type">
						<es3:annotation>The type of the transformation, which might be specified as a URL.
						</es3:annotation>
						<text/>
					</element>
				</optional>
				<optional>
					<element name="userMetadata">
						<es3:annotation>The 'userMetadat' section can contain any XML subdocument and is information
							provided by the client/user.
							</es3:annotation>
						<ref name="anything"/>
					</element>
				</optional>
				<optional>
					<element name="arguments">
						<es3:annotation>These are command line arguments to the data
							transformation, i.e. arguments to a Unix shell script or
							executable program.
						</es3:annotation>
						<text/>
					</element>
				</optional>
			</interleave>
		</element>
	</define>
</grammar>
