<?xml version="1.0" encoding="utf-8"?>
<xs:schema targetNamespace="http://echo.nasa.gov/v9/echoforms/autopopulate" elementFormDefault="qualified" xmlns="http://echo.nasa.gov/v9/echoforms/autopopulate" xmlns:xs="http://www.w3.org/2001/XMLSchema">

	<!-- This schema defines the autopopulate extension to  ECHO Forms.  For more information see the autopopulate section of the ECHO Forms Specification -->

	<xs:element name="expressions" type="ListOfExpressions">
		<xs:annotation>
			<xs:documentation>
				The root of the extension is the expressions element. 
				This contains a list of one or more autopopulate expressions to evaluate.
			</xs:documentation>
		</xs:annotation>
	</xs:element>
	<xs:complexType name="ListOfExpressions">
		<xs:annotation>
			<xs:documentation>A list of expressions</xs:documentation>
		</xs:annotation>
		<xs:sequence>
			<xs:element minOccurs="0" maxOccurs="unbounded" name="expression" type="Expression" />
		</xs:sequence>
	</xs:complexType>
	<xs:complexType name="Expression">
		<xs:annotation>
			<xs:documentation>
				An expression element represents one autopopulate XPath to evaluate. 
				The expression element must occur in an expressions element.
			</xs:documentation>
		</xs:annotation>
		<xs:sequence/>
		<xs:attribute name="ref" type="xs:string">
			<xs:annotation>
				<xs:documentation>
					<ul>
      					<li>Computed Expression: Yes</li>
						<li>Legal Values: any XPath expression that returns an element or attribute node</li>
						<li>Default Value: None</li>
						<li>Inheritance rules: refer to ECHO Forms Specification section 4.5 XPath Context.</li>
					</ul>
					<p>
					The ref attribute indicates which node in the instance the resolved metadata elements will be added to. 
					In the example below it points to the granulesize element in the instance.
					</p>
				</xs:documentation>
			</xs:annotation>
		</xs:attribute>
		<xs:attribute name="metadata" type="xs:string">
			<xs:annotation>
				<xs:documentation>
					<ul>
      					<li>Computed Expression: Yes</li>
						<li>Legal Values: any XPath expression into the catalog item metadata</li>
						<li>Default Value: None</li>
						<li>Inheritance rules: No inheritance</li>
					</ul>
					<p>
					Metadata is an XPath expression that will be resolved against the metadata of a collection or granule. 
					It can refer to a node, node set, or string value.
					</p>
				</xs:documentation>
			</xs:annotation>
		</xs:attribute>
	</xs:complexType>
</xs:schema>