<?xml version="1.0"?>
<!--Author: TVR-->
<?xml-stylesheet type="text/css" href="../xhtml2.css"?>
<!DOCTYPE html [
	<!ATTLIST section
	id ID #IMPLIED
>
	<!ATTLIST h
	id ID #IMPLIED
>
	<!ATTLIST div
	id ID #IMPLIED
>
	<!ATTLIST nl
	id ID #IMPLIED
>
]>
<html xmlns="http://www.w3.org/2002/06/xhtml2" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:e="urn:x-e-shop" xml:lang="en">
	<head>
		<title>Dynamic Shopping Cart To Test Repeat And Itemset</title>
		<xforms:model id="cart" schemaXX="cart.xsd">
		<!--
			<xsd:schema src="cart.xsd" targetNamespace="urn:x-e-shop"/>
			-->
			<xforms:instance id="c1" xmlns="urn:x-e-shop">
				<cart>
					<line-item>
						<item>
							<product/>
						</item>
						<quantity/>
						<!-- cost includes:
	    price, tax and shipping -->
						<cost/>
					</line-item>
				</cart>
			</xforms:instance>
			<xforms:instance id="cat" xmlns="urn:x-e-shop">
				<catalog>
					<product sku="a1">
						<description>abc</description>
						<price>123</price>
						<shipping>20</shipping>
					</product>
					<product sku="a2">
						<description>def</description>
						<price>321</price>
						<shipping>40</shipping>
					</product>
				</catalog>
			</xforms:instance>
			<xforms:bind nodeset="xforms:instance('c1')/e:line-item/e:cost" calculate="../e:item/e:product/e:price *../e:quantity * 1.08 + ../e:item/e:product/e:shipping"/>
		</xforms:model>
	</head>
	<body>
		<xforms:group model="cart" ref=".">
			<xforms:label>Shopping Cart</xforms:label>
			<xforms:switch>
				<xforms:case id="cartUI">
					<xforms:repeat id="cart_repeat" nodeset="instance('c1')/e:line-item" startindexX="1" numberX="3">
						<p>inside repeat</p>
						<xforms:select1 ref="e:item" appearance="minimal">
							<xforms:label>Select Product</xforms:label>
							<xforms:itemset nodeset="xforms:instance('cat')/e:product">
								<xforms:label>
	      Description:
	      <xforms:output ref="e:description"/> 
	      Price:
	      <xforms:output ref="e:price"/>
								</xforms:label>
								<xforms:copy ref="."/>
							</xforms:itemset>
						</xforms:select1>
						<xforms:input ref="e:quantity">
							<xforms:label>Quantity</xforms:label>
						</xforms:input>
	Price +Tax +  Shipping:
	<xforms:output ref="e:cost"/>
					</xforms:repeat>
					<xforms:group ref="/cart">
						<xforms:label>Shopping Cart Tool-bar</xforms:label>
						<xforms:trigger id="addItem">
							<xforms:label>Create Item</xforms:label>
							<xforms:insert nodeset="instance('c1')/e:line-item" at="index('cartUI')" position="after" ev:event="DOMActivate"/>
						</xforms:trigger>
						<xforms:trigger id="del">
							<xforms:label>Remove Item</xforms:label>
							<xforms:delete nodeset="instance('c1')/e:line-item" at="index('cartUI')" ev:event="DOMActivate"/>
						</xforms:trigger>
						<xforms:trigger id="forward">
							<xforms:label>Scroll Forward</xforms:label>
							<xforms:setindex repeat="cartUI" index="index('cartUI')+1"/>
						</xforms:trigger>
						<xforms:trigger id="back">
							<xforms:label>Scroll Back</xforms:label>
							<xforms:setindex repeat="cartUI" index="index('cartUI')-1"/>
						</xforms:trigger>
					</xforms:group>
					<xforms:trigger>
						<xforms:label>Show Invoice</xforms:label>
						<xforms:toggle case="invoice" ev:event="DOMActivate"/>
					</xforms:trigger>
				</xforms:case>
				<xforms:case id="invoice">
					<xforms:group>
						<label>Invoice</label>
						<xforms:trigger ev:event="DOMActivate">
							<xforms:label>Cart UI</xforms:label>
							<xforms:toggle case="cartUI" ev:event="DOMActivate"/>
						</xforms:trigger>
					</xforms:group>
				</xforms:case>
			</xforms:switch>
		</xforms:group>
	</body>
</html>
