<!-- edited by Jerome LAURET (Brookhaven National Laboratories) -->
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
        <xsd:element name="AbstractRequest">
                <xsd:annotation>
                        <xsd:documentation>A group of requests and a description of how the requests are organized into
a logical sequence of events (AND, OR, XOR, etc ... relationship) as well
as datasets which may be used by requests</xsd:documentation>
                </xsd:annotation>
                <xsd:complexType>
                        <xsd:choice maxOccurs="unbounded">
                                <xsd:element ref="Request"/>
                                <xsd:element ref="Task"/>
                                <xsd:element ref="Application"/>
                                <xsd:element ref="Dataset" minOccurs="0"/>
                                <xsd:element ref="ResourceSpecifications" minOccurs="0"/>
                                <xsd:element name="WorkFlow" minOccurs="0">
                                        <xsd:annotation>
                                                <xsd:documentation>MergeRequests { id=[xs:ID] }
    RequestID { idref=[xs:IDref] }
       ....
    ChooseBetweenRequests { id=[xs:ID] }
        RequestID { idref=[xs:IDref] }
    SetupRequestDependancy { id=[xs:ID] }
        RequestToBeDoneFirstID { idref=[xs:IDref] }
        RequestWaitingForInputID { idref=[xs:IDref] }
</xsd:documentation>
                                        </xsd:annotation>
                                </xsd:element>
                        </xsd:choice>
                        <xsd:attribute name="version" use="optional" default="V0.50">
                                <xsd:simpleType>
                                        <xsd:restriction base="xsd:NMTOKEN">
                                                <xsd:enumeration value="V0.50"/>
                                                <xsd:enumeration value="V0.5"/>
                                        </xsd:restriction>
                                </xsd:simpleType>
                        </xsd:attribute>
                        <!-- We leave this attribute optional because we don't want users to handle versioning.
However, we may use this version with a GUI XML writer/helper which will be able to re-read
older version and display (self-documenting) the new features. -->
                </xsd:complexType>
        </xsd:element>
        <xsd:element name="Request">
                <xsd:annotation>
                        <xsd:documentation>For easier handling of initialization, end-task garbagge collection and task
wrap up, we may want to define initialization/finalization special requests.
Those could be defined once, and re-used for every job generated by a
single request.
Also, there may be a need to do a unique request (task) for all jobs (not
for each jobs).</xsd:documentation>
                </xsd:annotation>
                <xsd:complexType>
                        <xsd:sequence>
                                <xsd:element name="RequestName" minOccurs="0"/>
                                <xsd:element name="RequestDescription" minOccurs="0"/>
                                <xsd:element name="OutputHandling" minOccurs="0">
                                        <xsd:annotation>
                                                <xsd:documentation>This element may be removed later (only a placeholder for later considertaion).
Ideally, outputs are themselves datasets and currentely, input/output are
non-symetrical.</xsd:documentation>
                                        </xsd:annotation>
                                        <xsd:complexType>
                                                <xsd:choice maxOccurs="unbounded">
                                                        <xsd:element name="Copy">
                                                                <xsd:complexType>
                                                                        <xsd:sequence>
                                                                                <xsd:element name="Source"/>
                                                                                <xsd:element name="Destination"/>
                                                                        </xsd:sequence>
                                                                </xsd:complexType>
                                                        </xsd:element>
                                                        <xsd:element name="Register"/>
                                                </xsd:choice>
                                        </xsd:complexType>
                                </xsd:element>
                        </xsd:sequence>
                        <xsd:attribute name="ID" type="xsd:ID"/>
                        <xsd:attribute name="taskRef" type="xsd:IDREF" use="required"/>
                        <xsd:attribute name="appRef" type="xsd:IDREF" use="required"/>
                        <xsd:attribute name="datasetRef" type="xsd:IDREF" use="optional"/>
                        <xsd:attribute name="resourceRef" type="xsd:IDREF" use="optional"/>
                </xsd:complexType>
        </xsd:element>
        <!-- Basic application: it defines a name and a version. -->
        <xsd:element name="Application" type="applicationType">
                <xsd:annotation>
                        <xsd:documentation>Example: A XXTask will depend (or reference) a XXX aplication. Purpose
is to allow versionning. </xsd:documentation>
                </xsd:annotation>
        </xsd:element>
        <xsd:complexType name="applicationType">
                <xsd:attribute name="ID" type="xsd:ID" use="required"/>
                <xsd:attribute name="type" type="xsd:string" use="optional"/>
                <xsd:attribute name="name" type="xsd:string" use="required"/>
                <xsd:attribute name="ver" type="xsd:string" use="optional"/>
        </xsd:complexType>
        <!-- -->
        <!-- Basic tasks are being implemented as extension of a basic type taskType-->
        <xsd:element name="Task" type="taskType">
                <xsd:annotation>
                        <xsd:documentation>In the newly proposed U-JDL, application and task are merged.</xsd:documentation>
                </xsd:annotation>
        </xsd:element>
        <xsd:complexType name="taskType">
                <xsd:sequence>
                        <xsd:element name="STDIN" type="xsd:anyURI" minOccurs="0"/>
                        <xsd:element name="STDOUT" type="xsd:anyURI" minOccurs="0"/>
                        <xsd:element name="STDERR" type="xsd:anyURI" minOccurs="0"/>
                </xsd:sequence>
                <xsd:attribute name="ID" type="xsd:ID" use="required"/>
                <xsd:attribute name="type" type="xsd:string" use="optional"/>
        </xsd:complexType>
        <!-- Implementation example 0: ROOT Task (maybe the most typical for RHIC/NP) -->
        <xsd:complexType name="rootTaskType">
                <xsd:complexContent>
                        <xsd:extension base="taskType">
                                <xsd:sequence>
                                        <xsd:element name="Macro">
                                                <xsd:complexType>
                                                        <xsd:simpleContent>
                                                                <xsd:extension base="xsd:string"/>
                                                        </xsd:simpleContent>
                                                </xsd:complexType>
                                        </xsd:element>
                                        <xsd:element name="Arguments" type="xsd:string" minOccurs="0" maxOccurs="unbounded"/>
                                </xsd:sequence>
                        </xsd:extension>
                </xsd:complexContent>
        </xsd:complexType>
        <xsd:element name="RootTask" type="rootTaskType" substitutionGroup="Task"/>
        <!-- Implementation example 1: Script Task  -->
        <xsd:complexType name="scriptTaskType">
                <xsd:complexContent>
                        <xsd:extension base="taskType">
                                <xsd:sequence>
                                        <xsd:element name="Script">
                                                <xsd:complexType>
                                                        <xsd:simpleContent>
                                                                <xsd:extension base="xsd:string"/>
                                                        </xsd:simpleContent>
                                                </xsd:complexType>
                                        </xsd:element>
                                        <xsd:element name="Arguments" type="xsd:string" minOccurs="0" maxOccurs="unbounded"/>
                                </xsd:sequence>
                        </xsd:extension>
                </xsd:complexContent>
        </xsd:complexType>
        <xsd:element name="ScriptTask" type="scriptTaskType" substitutionGroup="Task"/>
        <!-- Implementation example 2: Java task. Java requires preparation -->
        <xsd:complexType name="javaTaskType">
                <xsd:complexContent>
                        <xsd:extension base="taskType">
                                <xsd:sequence>
                                        <xsd:element name="ClassName" type="xsd:anyURI">
                                                <xsd:annotation>
                                                        <xsd:documentation>Either a jar or a class name</xsd:documentation>
                                                </xsd:annotation>
                                        </xsd:element>
                                        <xsd:element name="Jar" type="xsd:anyURI">
                                                <xsd:annotation>
                                                        <xsd:documentation>The location of the JAR file containing the main class</xsd:documentation>
                                                </xsd:annotation>
                                        </xsd:element>
                                        <xsd:element name="Arguments" type="xsd:string" minOccurs="0" maxOccurs="unbounded">
                                                <xsd:annotation>
                                                        <xsd:documentation>The arguments to use to execute the JAR file.</xsd:documentation>
                                                </xsd:annotation>
                                        </xsd:element>
                                        <xsd:element name="ClassPath" type="xsd:anyURI" minOccurs="0"/>
                                </xsd:sequence>
                        </xsd:extension>
                </xsd:complexContent>
        </xsd:complexType>
        <xsd:element name="JavaTask" type="javaTaskType" substitutionGroup="Task"/>
        <!-- -->
        <!-- Basic dataset.
TODO: is still unclear if the type should be there and how should be used -->
        <xsd:element name="Dataset" type="datasetType">
                <xsd:annotation>
                        <xsd:documentation>Below, some ideas from DIAL
Dataset{  identity=[xs:ID],
               mutability=[locked,appending],
               location=[virtual,logical,physical,staged,mixed],
               composite=[xs:boolean]
            }
Contentlist
             ContentKey { type=[xs:string] }</xsd:documentation>
                </xsd:annotation>
        </xsd:element>
        <xsd:complexType name="datasetType">
                <xsd:attribute name="ID" type="xsd:ID" use="required"/>
        </xsd:complexType>
        <!-- Basic extra.
TODO: a better name would be required for this -->
        <!-- Catalog type may be a replica or file catalog. Not entirely settled yet, this may take other form based on feedback -->
        <xsd:complexType name="catalogType">
                <xsd:sequence>
                        <xsd:element name="Type" type="xsd:string" minOccurs="0"/>
                        <xsd:element name="Name" type="xsd:anyURI" minOccurs="0"/>
                        <xsd:element name="Query" type="xsd:string"/>
                </xsd:sequence>
        </xsd:complexType>
        <!-- General Dataset. This dataset consists of (??)  -->
        <xsd:element name="GenericDataset" substitutionGroup="Dataset">
                <xsd:annotation>
                        <xsd:documentation>In this case, type should specify what this generic set relates to (Physical, Logical, Event data-sets etc ...). Note that because the model is multiple-choice un-bounded, list is implied as soon as one element has been chosen.</xsd:documentation>
                </xsd:annotation>
                <xsd:complexType>
                        <xsd:complexContent>
                                <xsd:extension base="genericDatasetType">
                                        <xsd:attribute name="type" use="required">
                                                <xsd:simpleType>
                                                        <xsd:restriction base="xsd:NMTOKEN">
                                                                <xsd:enumeration value="Logical"/>
                                                                <xsd:enumeration value="Physical"/>
                                                                <xsd:enumeration value="Virtual"/>
                                                                <xsd:enumeration value="Mixed"/>
                                                        </xsd:restriction>
                                                </xsd:simpleType>
                                        </xsd:attribute>
                                </xsd:extension>
                        </xsd:complexContent>
                </xsd:complexType>
        </xsd:element>
        <xsd:complexType name="genericDatasetType">
                <xsd:complexContent>
                        <xsd:extension base="datasetType">
                                <xsd:choice>
                                        <xsd:element name="Name" type="xsd:anyURI" maxOccurs="unbounded">
                                                <xsd:annotation>
                                                        <xsd:documentation>LFN, PFN, ...</xsd:documentation>
                                                </xsd:annotation>
                                        </xsd:element>
                                        <xsd:element name="Id" type="xsd:long" maxOccurs="unbounded">
                                                <xsd:annotation>
                                                        <xsd:documentation>Event ID, ...</xsd:documentation>
                                                </xsd:annotation>
                                        </xsd:element>
                                        <xsd:element name="DataSetIDRef" type="xsd:IDREF" maxOccurs="unbounded">
                                                <xsd:annotation>
                                                        <xsd:documentation>Reference to other DataSets (merging)</xsd:documentation>
                                                </xsd:annotation>
                                        </xsd:element>
                                        <xsd:element name="Range" maxOccurs="unbounded">
                                                <xsd:annotation>
                                                        <xsd:documentation>Range may be used for event number ranges. It may not have any special significance for physical files. A range defines however a collection and fits well with Catalog and List.</xsd:documentation>
                                                </xsd:annotation>
                                                <xsd:complexType>
                                                        <xsd:sequence>
                                                                <xsd:element name="Minimum" type="xsd:anySimpleType"/>
                                                                <xsd:element name="Maximum" type="xsd:anySimpleType"/>
                                                        </xsd:sequence>
                                                </xsd:complexType>
                                        </xsd:element>
                                        <xsd:element name="Catalog" type="catalogType" maxOccurs="unbounded">
                                                <xsd:annotation>
                                                        <xsd:documentation>Catalog element is the connection to any relevant catalog for the DataSet. Here, we envision the handling of Event, MetaData or File catalogs. We may
name the DataSets difefrentely for clarity but the genericDataSet is meant to cover everything as needed. The return value of a Catalog is compatible with a List (otherwise, use Token)</xsd:documentation>
                                                </xsd:annotation>
                                        </xsd:element>
                                        <xsd:element name="Token" type="xsd:anyType" maxOccurs="unbounded">
                                                <xsd:annotation>
                                                        <xsd:documentation>A token is a referral to an extrenal iterrator returning the DataSet of interrest. For example, the scheduler may declare to an external service its intent to work on a perticular DataSet and given back a token which will be later used by the application to retreive that DataSet. In case of planners, the Token mechanism would be more appropriate. A token based DataSet is most likely virtual (here again, don't know how to add the constraint)</xsd:documentation>
                                                </xsd:annotation>
                                        </xsd:element>
                                </xsd:choice>
                        </xsd:extension>
                </xsd:complexContent>
        </xsd:complexType>
        <!-- Now we have one more derivation allowing for not only logical / physical Datasets but also -->
        <!-- a more generic event, track or whatever quantity which may be relevant ...                          -->
        <!-- Not sure this is needed actually (makes it complex but more readable as the chosen DS       -->
        <!-- name is self-documented)                                                                                                         -->
        <!-- xsd:element name="LogicalDataSet" type="genericDatasetType" substitutionGroup="GenericDataset"/ -->
        <!-- xsd:element name="PhysicalDataSet" type="genericDatasetType" substitutionGroup="GenericDataset"/ -->
        <!-- xsd:element name="EventDataSet" type="genericDatasetType" substitutionGroup="GenericDataset"/ -->
        <!-- -->
        <!-- Simple text DataSet -->
        <xsd:element name="Text" type="textType" substitutionGroup="Dataset">
                <xsd:annotation>
                        <xsd:documentation>Any text, including command line arguments</xsd:documentation>
                </xsd:annotation>
        </xsd:element>
        <xsd:complexType name="textType">
                <xsd:complexContent>
                        <xsd:extension base="datasetType">
                                <xsd:sequence>
                                        <xsd:element name="Line" type="xsd:string" maxOccurs="unbounded"/>
                                </xsd:sequence>
                        </xsd:extension>
                </xsd:complexContent>
        </xsd:complexType>
        <!-- Environement bundle borrowed from DIAL dataset.dtd and reshaped to fit global type-->
        <xsd:element name="Environment" type="environmentType" substitutionGroup="Dataset"/>
        <xsd:complexType name="environmentType">
                <xsd:annotation>
                        <xsd:documentation>Environment is a list (unbounded) of EnvironmentVariables. The notion was taken from datasets.dtd with change of attributes to elements.</xsd:documentation>
                </xsd:annotation>
                <xsd:complexContent>
                        <xsd:extension base="datasetType">
                                <xsd:sequence>
                                        <xsd:element name="EnvironmentVariable" maxOccurs="unbounded">
                                                <xsd:complexType>
                                                        <xsd:sequence>
                                                                <xsd:element name="Name" type="xsd:string"/>
                                                                <xsd:element name="Value" type="xsd:string"/>
                                                        </xsd:sequence>
                                                </xsd:complexType>
                                        </xsd:element>
                                </xsd:sequence>
                        </xsd:extension>
                </xsd:complexContent>
        </xsd:complexType>
        <!-- -->
        <!-- Resource specifications will provide input to Schedulers as per how much 
the request will be consuming -->
        <!-- InputResource and OutputResource will have several implementations to clearly indentify the quanta we deal with-->
        <xsd:element name="ResourceSpecifications">
                <xsd:complexType>
                        <xsd:sequence>
                                <xsd:element ref="MemoryPerProcess" minOccurs="0"/>
                                <xsd:element ref="InputResource" minOccurs="0"/>
                                <xsd:element ref="OutputResource" minOccurs="0"/>
                                <xsd:element name="Time"/>
                                <xsd:any namespace="##any" minOccurs="0" maxOccurs="unbounded">
                                        <xsd:annotation>
                                                <xsd:documentation>The number of resource requirements may change in future.</xsd:documentation>
                                        </xsd:annotation>
                                </xsd:any>
                        </xsd:sequence>
                        <xsd:attribute name="ID" type="xsd:ID" use="required"/>
                </xsd:complexType>
        </xsd:element>
        <xsd:complexType name="resourceType">
                <xsd:sequence>
                        <xsd:element name="MininumUnitsRequired" type="xsd:long" minOccurs="0">
                                <xsd:annotation>
                                        <xsd:documentation>Minimum may be used for dispatching purposes. A process will not start unless the available resource is above this minimum.</xsd:documentation>
                                </xsd:annotation>
                        </xsd:element>
                        <xsd:element name="MaximumUnitsEstimated" type="xsd:long" minOccurs="0">
                                <xsd:annotation>
                                        <xsd:documentation>If unspecified, there are no known upper limits. If specified, this value indicates that the job will use this value as  maximum quanta of the resource will be taken.
*** SUGGESTS *** The definition does not match the name "estimated". It appears to be strict limit. Change to Required ??</xsd:documentation>
                                </xsd:annotation>
                        </xsd:element>
                        <xsd:choice minOccurs="0">
                                <xsd:element name="AverageSizeOfUnit" type="xsd:float">
                                        <xsd:annotation>
                                                <xsd:documentation>If specified and applies, unit is in MB</xsd:documentation>
                                        </xsd:annotation>
                                </xsd:element>
                                <xsd:element name="UnitsPerSeconds" type="xsd:float">
                                        <xsd:annotation>
                                                <xsd:documentation>Rate estimated by the user for his request. Note that if this is used, the quanta may be unit-less.</xsd:documentation>
                                        </xsd:annotation>
                                </xsd:element>
                        </xsd:choice>
                </xsd:sequence>
        </xsd:complexType>
        <xsd:element name="MemoryPerProcess" type="resourceType">
                <xsd:annotation>
                        <xsd:documentation>Total Memory (Virtual + RAM). Distinction is not relevant to users ??</xsd:documentation>
                </xsd:annotation>
        </xsd:element>
        <xsd:element name="InputResource" type="resourceType">
                <xsd:annotation>
                        <xsd:documentation>In SUMS, we implemented a numFilesPerHour. This gave an indication of
the input rate for a request. The request would then be split into sub-jobs
according to available resources (CPUtime limit associated to a queue). A
job would end up with 100 files each for example ... while the dataset would
be of several 1000 files. BUT, input may be implemented with a different
concept than files. For example, input can be events, tracks, gene
sequence, etc ... This tries to generalize the idea.</xsd:documentation>
                </xsd:annotation>
        </xsd:element>
        <!--InputResource  - extensions of resourceType - They may be extended types-->
        <xsd:element name="InputFiles" type="resourceType" substitutionGroup="InputResource"/>
        <xsd:element name="InputTracks" type="resourceType" substitutionGroup="InputResource"/>
        <xsd:element name="InputEvents" type="resourceType" substitutionGroup="InputResource"/>
        <xsd:element name="OutputResource" type="resourceType">
                <xsd:annotation>
                        <xsd:documentation>Symetric of input ... Note that the type of storage is not specified here (like
if the storage is NFS, AFS, Db, etc ...). The rate combined with the unit
size will obviously limit the possibilities of where the jobs can run. This
implies that this resource alone may map to several low-level JDL
requirements (TransferRate, Type from the StorageDevice element
in Glue CE, or event connection speed if we speak of db)</xsd:documentation>
                </xsd:annotation>
        </xsd:element>
        <!-- All below elements are extensions of  resourceType - Note that they may be extended-->
        <xsd:element name="OutputFiles" type="resourceType" substitutionGroup="OutputResource"/>
        <xsd:element name="OutputTracks" type="resourceType" substitutionGroup="OutputResource"/>
        <xsd:element name="OutputEvents" type="resourceType" substitutionGroup="OutputResource"/>
</xsd:schema>