<?xml-stylesheet href="xsltforms/xsltforms.xsl" type="text/xsl"?>
<html
     xmlns="http://www.w3.org/1999/xhtml"
     xmlns:ev="http://www.w3.org/2001/xml-events"
     xmlns:xsd="http://www.w3.org/2001/XMLSchema"
     xmlns:xf="http://www.w3.org/2002/xforms"
		 xmlns:sample="http://www.agencexml.com/sample"
		 >
     <head>
          <title>Using Origin to do a Deep Copy between instances</title>
          <style type="text/css">
               @namespace xf url("http://www.w3.org/2002/xforms");
               body {font-family:Helvetica, sans-serif}
               #source-repeat {border: blue solid 1px;}
               #destination-repeat {border: green solid 1px;}
          </style>
          <xf:model>
               
               <xf:instance id="source">
                    <sample:data>
                         <sample:a>A1</sample:a>
                         <sample:a>A2</sample:a>
                         <sample:a>A3</sample:a>
                    </sample:data>
               </xf:instance>
               
               <xf:instance id="destination">
                    <sample:data/>
               </xf:instance>
               
          </xf:model>
     </head>
     <body>
			<div id="xformControl">
				<span>
					<input type="checkbox" onclick="$('console').style.display = this.checked? 'block' : 'none';"  checked="checked"/> Debug
				</span>
			</div>
          <h1>Example of deep copy using XForms insert origin</h1>
          
          <h3>Source:</h3>
          <xf:repeat id="source-repeat" nodeset="instance('source')/sample:a">
               <xf:output ref="."/>
          </xf:repeat> 
          
          <h3>Destination:</h3>
          <xf:repeat id="destination-repeat" nodeset="instance('destination')/sample:a">
               <xf:output ref="."/>
          </xf:repeat> 
               
          <xf:trigger>
               <xf:label>Copy data from source to destination</xf:label>     
               <xf:action ev:event="DOMActivate">
                        <xf:insert
                             origin="instance('source')"                        
                             nodeset="instance('destination')"/>
               </xf:action>
          </xf:trigger>
			<div id="console"></div>
     </body>
</html>