<?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:e-shop" 
  xml:lang="en">
  <head>
    <title>Dynamic Shopping Cart To Test Repeat And Itemset</title>
    <xforms:model id="cart">
      <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>
<table>
      <tr  id="cart_repeat"
	repeat-nodeset="xforms:instance('c1')/e:line-item"
	repeat-startindex="1"
	repeat-number="3">
<td>
	<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></td>

<td>
	<xforms:input ref="e:quantity">
	  <xforms:label>Quantity</xforms:label>
	</xforms:input>
          </td>
<td>
	Price +Tax +  Shipping:
	<xforms:output ref="e:cost"/>
          </td>
      </tr>
      </table>
<xf:group ref="/cart">
    <xf:label>Shopping Cart Tool-bar</xf:label>
    <xf:trigger id="addItem">
      <xf:label>Create Item</xf:label>
      <xf:insert nodeset="line-item"
        at="index('cartUI')"
        position="after"
        ev:event="xforms-activate"/>
    </xf:trigger>
    <xf:trigger id="del">
      <xf:label>Remove Item</xf:label>
      <xf:delete nodeset="line-item"
        at="index('cartUI')"
        ev:event="xforms-activate"/>
    </xf:trigger>
    <xf:trigger id="forward">
      <xf:label>Scroll Forward</xf:label>
      <xf:setindex repeat="cartUI"
        index="index('cartUI')+1"/>
    </xf:trigger>
    <xf:trigger id="back">
      <xf:label>Scroll Back</xf:label>
      <xf:setindex repeat="cartUI"
        index="index('cartUI')-1"/>
    </xf:trigger>
  </xf:group>
    </xforms:group>
    
  </body>
</html>
