<?xml version='1.0'?>
<!DOCTYPE xsl:stylesheet SYSTEM "xsl.dtd">
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">


<xsl:output method ="html" version="1.0" encoding="UTF-8" omit-xml-declaration="no" standalone="yes" />

<!--
///////////////////////////////////////////////////////////////////////////////
///// BEGIN FORM TEMPLATES ////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
-->
<xsl:template match="/">
	<html>
	<head>
	<title>Form Entry: <xsl:value-of select="mysql_table/@tbl_name" /></title>
	<link href="style.css" rel="stylesheet" type="text/css" />
	</head>
	<body>
		<div id="contain">	
			<form method="POST" action="process.php">
			<input type="hidden" name="tbl_name">
				<xsl:attribute name="value"><xsl:value-of select="mysql_table/@tbl_name" /></xsl:attribute>
			</input>
				<xsl:apply-templates />
			</form>
			<p>Return to the <a href="index.php">main page</a>.</p>
		</div>
	</body>
	</html>
</xsl:template>

<xsl:template match="table_definition">
	<table cellspacing="0" cellpadding="3">
		<tr class="header">
			<td colspan="2">Data Entry for <xsl:value-of select="/mysql_table/@tbl_name" /></td>
		</tr>
		<xsl:apply-templates />
		<tr class="header">
			<td> </td>
			<td><input name="FORM_SUBMIT" type="submit" value="Submit" /></td>
		</tr>
	</table>
</xsl:template>

<xsl:template match="column_definition">
	<tr>
		<td class="field_name">
			<xsl:value-of select="@col_name" />:
		</td>
		<td>
			<xsl:apply-templates select="type" />
		</td>
	</tr>
</xsl:template>



<xsl:template match="type">
	<xsl:apply-templates />
</xsl:template>

<xsl:template match="ENUM|SET">
	<select>
		<xsl:attribute name="name">input_<xsl:value-of select="../../@col_name" /></xsl:attribute>
		<xsl:apply-templates select="SET_ITEM" />	
	</select>
</xsl:template>

<xsl:template match="SET_ITEM">
	<option>
	<xsl:if test="string(../../../@DEFAULT) = string(@value)">
		<xsl:attribute name="selected" />
	</xsl:if>
	<xsl:value-of select="@value" />
	</option>
</xsl:template>

<xsl:template match="TINYINT|SMALLINT|MEDIUMINT|INT|INTEGER|BIGINT|REAL|DOUBLE|FLOAT|DECIMAL|NUMERIC|DATE|TIME|TIMESTAMP|DATETIME|CHAR|VARCHAR">
	<input>
	<xsl:attribute name="name">input_<xsl:value-of select="../../@col_name" /></xsl:attribute>
	<xsl:if test="count(../../@DEFAULT)>0">
		<xsl:attribute name="value"><xsl:value-of select="../../@DEFAULT" /></xsl:attribute>
	</xsl:if>
	</input>
</xsl:template>

<xsl:template match="TEXT|TINYTEXT|MEDIUMTEXT|LONGTEXT|BLOB|MEDIUMBLOB|TINYBLOB|LONGBLOB">
	<textarea>
	<xsl:attribute name="name">input_<xsl:value-of select="../../@col_name" /></xsl:attribute>	
	<xsl:if test="count(../../@DEFAULT)>0">
		<xsl:value-of select="../../@DEFAULT" />
	</xsl:if>
	</textarea>
</xsl:template>

<!-- GET RID OF THESE -->
<xsl:template match="PRIMARY_KEY|KEY|INDEX|UNIQUE|FOREIGN_KEY|CHECK">
</xsl:template>

</xsl:stylesheet>

