include "common.rnc"

start |= Program

Program = element program {
	Service
}

InvocationHead &=		(
		 ## executable name
		 element command {
			## custom path	
			attribute path { text }?&
			text
			}?&
		 ## environment variable for program invocation
		 element env { 
			## name
			attribute name { text }&
			## value
			text 
			}*
		 )?&
		 ## progress report output for the program
		 # displayed even before the program completes
		 element progressReport {
		    ## prompt to "label" the progress report
		    attribute prompt { text }?&
		    text
		 }?

InvocationParagraph &= Argpos?

InvocationParameterElements &=
	(
	(
	 ## command parameter
	 # iscommand : if true& this parameter specify the line of command to run the program  used when the command line is more complicated.
	 attribute iscommand { xsd:boolean }?|
	 ## parameter file
	 element paramfile { text }?
	)&
	## command line chunk evaluation code 
	Format?&
	## command line chunk position index
	Argpos?&
	## result file(s) mask(s) 
	# this element is relevant only for output parameters, it is used to find the files in which the results are stored
	# each code must have ONLY ONE file unix mask 
	element filenames { Code+ }?
	)

Argpos =
	## command line chunk position index 
	# in parameter: specifies the position of this parameter on the command line
	# in paragraph: specifies the position on the command line for all parameters of this paragraph
	# by convention the argpos of command must be 0. if we want args before command we could get negative argpos.
	element argpos { xsd:integer }
	
Format =
	## command line chunk construction code
	# a code which will be evaluated to form the command line
	element format { Code+ }
	
InterfaceType &= ("form"|"job_input"|"job_output")