<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="shopping.css" type="text/css"?>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:xforms="http://www.w3.org/2002/xforms/cr" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:eye="http://www.novell.com/forms/examples/" xmlns:ev="http://www.w3.org/2001/xml-events" xml:lang="en">
	<head>
		<title>Shop</title>
		<style type="text/css">
			trigger.removetrigger {width: 200px;height:20px;}
		</style>
		<xforms:model id="defaultModel">
			<xforms:instance>
				<shopping xmlns="http://www.novell.com/forms/examples/">
					<items>
						<item>
							<name>60GB harddisk</name>
							<price>75</price>
						</item>
						<item>
							<name>80GB harddisk</name>
							<price>100</price>
						</item>
						<item>
							<name>17" monitor</name>
							<price>150</price>
						</item>
						<item>
							<name>19" monitor</name>
							<price>175</price>
						</item>
						<item>
							<name>mainboard</name>
							<price>125</price>
						</item>
						<item>
							<name>cpu 2GHz</name>
							<price>200</price>
						</item>
						<item>
							<name>cpu 2.2GHz</name>
							<price>220</price>
						</item>
						<item>
							<name>cpu 2.4GHz</name>
							<price>420</price>
						</item>
					</items>
					<cart>
						<itemcount/>
						<totalprice/>
						<items>
							<item>
								<name></name>
								<price>0</price>
							</item>
						</items>
					</cart>
				</shopping>
			</xforms:instance>
			<xforms:bind nodeset="/eye:shopping/eye:cart/eye:items/eye:item"/>
			<!--
			<xforms:bind nodeset="/eye:shopping/eye:cart/eye:itemcount" calculate="count(../eye:items/eye:item/eye:name[text()!=''])"/>
			<xforms:bind nodeset="/eye:shopping/eye:cart/eye:totalprice" calculate="sum(/eye:shopping/eye:cart/eye:items/eye:item/eye:price[text()!=''])"/>-->
			<xforms:bind nodeset="/eye:shopping/eye:cart/eye:itemcount" calculate="count(../eye:items/eye:item/eye:name)"/>
			<xforms:bind nodeset="/eye:shopping/eye:cart/eye:totalprice" calculate="sum(/eye:shopping/eye:cart/eye:items/eye:item/eye:price)"/>
		</xforms:model>
	</head>
	<body>
		<xforms:group ref="/eye:shopping">
			<xforms:group ref="eye:cart" class="inline">
				<xforms:group ref="." class="cart">
					<xforms:input ref="eye:itemcount">
						<xforms:label>Number of items</xforms:label>
					</xforms:input>
				</xforms:group>
				<xforms:group ref="." class="cart">
					<xforms:input ref="eye:totalprice">
						<xforms:label>Total price</xforms:label>
					</xforms:input>
				</xforms:group>
				<xforms:repeat nodeset="eye:items/eye:item" id="shopped">
					<xforms:group ref=".">
						<xforms:trigger class="removetrigger">
							<xforms:label ref="eye:name"/>
							<xforms:hint>remove this item</xforms:hint>
							<xforms:delete nodeset="." at="1" ev:event="xforms-activate"/>
						</xforms:trigger>
					</xforms:group>
				</xforms:repeat>
			</xforms:group>
			<xforms:repeat nodeset="eye:items/eye:item" id="items" class="inline">
				<xforms:group ref=".">
					<xforms:output ref="eye:name"/>
					<xforms:output ref="eye:price"/>
					<xforms:trigger>
						<xforms:label>Add To Cart</xforms:label>
						<xforms:action ev:event="xforms-activate">
							<xforms:insert nodeset="/eye:shopping/eye:cart/eye:items/eye:item" at="count(/eye:shopping/eye:cart/eye:items/eye:item)" position="after"/>
							<xforms:setvalue ref="/eye:shopping/eye:cart/eye:items/eye:item[last()]/eye:name" value="/eye:shopping/eye:items/eye:item[index('items')]/eye:name"/>
							<xforms:setvalue ref="/eye:shopping/eye:cart/eye:items/eye:item[last()]/eye:price" value="/eye:shopping/eye:items/eye:item[index('items')]/eye:price"/>
						</xforms:action>
					</xforms:trigger>
				</xforms:group>
			</xforms:repeat>
		</xforms:group>
	</body>
</html>

