<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="XForms.xsl"?>
<!--
	XForms based form description sample.	
	Author: Konstantin Piroumian, 21-Feb-2002
	Email: kpiroumian@flagship.ru
-->

<!-- Root element of the document. Can be in HTML, XHTML or some other namespace -->
<page>
	<!-- Data model used in this form -->
	<model xmlns:xlink="http://foo.com/xlink">
		<!-- XML Schema for the instance data -->
		<schema xlink:href="XForms.xsd"/>
		
		<!-- Instance data: initial values -->
		<instance>
			<customer id="102038" type="individual">
				<firstname>John</firstname>
				<lastname>Lennon</lastname>
				<citizenship>RU</citizenship>
				<has-car>false</has-car>
				<car-info>
				        <issue-year>1999</issue-year>
				        <model>Volkswagen Passat</model>
				</car-info>
			</customer>
		</instance>
		
		<!-- Data binding with simple constraints -->
		<bind ref="customer/@id" readOnly="true"/>
		<bind ref="customer/firstname" required="true"/>
		<bind ref="customer/lastname" required="true"/>
		<bind ref="customer/citizenship" relevant="customer/@type='individual'"/>
     	<bind ref="customer/car-info/issue-year" relevant="customer/has-car='true'" required="true" />
     	<bind ref="customer/car-info/model" relevant="customer/has-car='true'" required="true" />

		<!-- What and where to submit -->
		<submitInfo action="http://example.com/submit" method="post" id="s00"/>
	</model>
	
	<!-- The form UI definition itself. Normally, it can be mixed with other markup: HTML, WML or other to provide a customized layout -->
	<group ref="customer" class="table">
		<output ref="@id">
		    <caption>Customer ID</caption>
		</output>
		<input ref="firstname">
			<caption>First name</caption>
			<hint>Your first name</hint>
			<isValid>false</isValid>
			<message type="info" class="error">Firstname is required</message>
		</input>
		<input ref="lastname" class="info">
			<caption>Last name(s)</caption>
			<hint>Your last name</hint>
			<message type="info">Use this field to enter all your last names</message>
		</input>
		<singleSelect ref="citizenship" selectUI="menu" selection="closed" class="citizenship">
			<caption>Citizenship</caption>
			<item id="US">
				<caption>United States</caption>
				<value>US</value>
			</item>
			<item id="CA">
				<caption>Canada</caption>
				<value>CA</value>
			</item>
			<item id="RU">
				<caption>Russian Federation</caption>
				<value>RU</value>4
			</item>
		</singleSelect>
		<singleSelect ref="has-car" selectUI="checkbox">
			<caption>Own a car?</caption>
			<item>
			    <caption>(Yes or No)</caption>
			</item>
		</singleSelect>

          <group ref="car-info" class="sub-table">
        		<input ref="issue-year">
		        	<caption>Car Issue Year</caption>
			    <hint>The year when the car was issued</hint>
		    </input>
        		<input ref="model">
		        	<caption>Car Model</caption>
			    <hint>Model of your car</hint>
		    </input>              
          </group>
		
		<!-- This can be displayed as a submit button, a link or somehow else -->
		<submit submitInfo="s00" class="button">
			<caption>Save</caption>
		</submit>
	</group>
</page>

