﻿<?xml-stylesheet href="../xsltforms/xsltforms.xsl" type="text/xsl"?>
<?xsltforms-options debug="no"?>
<html xmlns="http://www.w3.org/1999/xhtml" 
      xmlns:h="http://www.w3.org/1999/xhtml" 
      xmlns:xf="http://www.w3.org/2002/xforms"
      xmlns:ev="http://www.w3.org/2001/xml-events"
      xmlns:math="http://exslt.org/math"
>
<head>
	<title>Game</title>
	<style type="text/css">
	body {margin-left: 2em; font-size: 200%}
	.row {display: block}
	.cell {display: inline-block; height: 2em; width: 2em; border: thin green solid; text-align: center; }
	.xforms-repeat-item {display: inline}
	</style>
	<model xmlns="http://www.w3.org/2002/xforms">
		<instance>
		  <data xmlns="">
		    <row><cell>1</cell><cell>5</cell><cell>8</cell><cell>12</cell></row>
		    <row><cell>2</cell><cell>6</cell><cell>9</cell><cell>13</cell></row>
		    <row><cell>3</cell><cell>7</cell><cell>10</cell><cell>14</cell></row>
		    <row><cell>4</cell><cell>.</cell><cell>11</cell><cell>15</cell></row>
		  </data>
		</instance>
	</model>
</head>
<body>
    <group xmlns="http://www.w3.org/2002/xforms">
	<repeat nodeset="row"> 
	    <group class="row">
		<repeat nodeset="cell" >
		    <trigger class="cell" appearance="minimal">
			<label><output ref="."/></label>
			<action ev:event="DOMActivate" if="following-sibling::cell[1]='.' or preceding-sibling::cell[1]='.' or ../following-sibling::row[1]/cell[1+count(context()/preceding-sibling::cell)]='.' or ../preceding-sibling::row[1]/cell[1+count(context()/preceding-sibling::cell)]='.'">
			    <setvalue ref="//cell[.='.']" value="context()"/>
			    <setvalue ref="." value="'.'"/>
			</action>
		    </trigger>
		</repeat>
	    </group>
	</repeat>
    </group>
</body>
</html>
