<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"/>
<!-- ###### EDIT THIS TEMPLATE TO CUSTOMISE THE FORM -->
<xsl:template match="form-config">
<form name='inputForm' onSubmit='return validate()'>
<table cellspacing="0" border="1">
<xsl:for-each select="var">
<tr>
<td><xsl:value-of select="description"/></td>
<td><xsl:text disable-output-escaping="yes">&nbsp;</xsl:text></td>
<td><xsl:call-template name="form-element"/></td>
<td>
<xsl:choose>
<xsl:when test="validation-error">
<xsl:attribute name="class">formError</xsl:attribute>
<xsl:value-of select="validation-message"/>
</xsl:when>
<xsl:otherwise>
<xsl:text disable-output-escaping="yes">&nbsp;</xsl:text>
</xsl:otherwise>
</xsl:choose>
</td>
</tr>
</xsl:for-each>
<tr>
<td><xsl:text disable-output-escaping="yes">&nbsp;</xsl:text></td>
<td><xsl:text disable-output-escaping="yes">&nbsp;</xsl:text></td>
<td>
<input type="submit" value="ok" name="formAction"/>
<input type="submit" value="cancel" name="formAction"/>
<input type="submit" value="apply" name="formAction"/>
</td>
<td><xsl:text disable-output-escaping="yes">&nbsp;</xsl:text></td>
</tr>
</table>
</form>
</xsl:template>
<!-- ###### THIS TEMPLATE DOES NOT NORMALLY NEED TO BE EDITED -->
<xsl:template name="form-element">
<xsl:choose>
<xsl:when test='@type="text"'> <!-- TEXT FIELD -->
<input>
<xsl:attribute name="name"><xsl:value-of select="@name"/></xsl:attribute>
<xsl:attribute name="type">text</xsl:attribute>
<xsl:attribute name="value"><xsl:value-of select="value"/></xsl:attribute>
<xsl:for-each select="html-display-option">
<xsl:attribute name="{@name}"><xsl:value-of select="@value"/></xsl:attribute>
</xsl:for-each >
</input>
</xsl:when>
<xsl:when test='@type="textarea"'> <!-- TEXTAREA FIELD -->
<textarea>
<xsl:attribute name="name"><xsl:value-of select="@name"/></xsl:attribute>
<xsl:for-each select="html-display-option">
<xsl:attribute name="{@name}"><xsl:value-of select="@value"/></xsl:attribute>
</xsl:for-each >
<xsl:value-of select="value"/>
</textarea>
</xsl:when>
<xsl:when test='@type="select"'> <!-- SINGLE SELECT FIELD -->
<xsl:variable name="default"><xsl:value-of select="value"/></xsl:variable>
<select>
<xsl:attribute name="name"><xsl:value-of select="@name"/></xsl:attribute>
<xsl:attribute name="type">text</xsl:attribute>
<xsl:for-each select="html-display-option">
<xsl:attribute name="{@name}"><xsl:value-of select="@value"/></xsl:attribute>
</xsl:for-each >
<xsl:for-each select="option" >
<option>
<xsl:attribute name="value"><xsl:value-of select="@value"/></xsl:attribute>
<xsl:if test="$default=@value">
<xsl:attribute name="selected">yes</xsl:attribute>
</xsl:if>
<xsl:value-of select="."/>
</option>
</xsl:for-each>
</select>
</xsl:when>
<xsl:when test='@type="multiselect"'> <!-- MULTIPLE SELECT FIELD -->
<select>
<xsl:attribute name="name"><xsl:value-of select="@name"/>[]</xsl:attribute>
<xsl:attribute name="type">text</xsl:attribute>
<xsl:attribute name="multiple">yes</xsl:attribute>
<xsl:for-each select="html-display-option">
<xsl:attribute name="{@name}"><xsl:value-of select="@value"/></xsl:attribute>
</xsl:for-each >
<xsl:for-each select="option" >
<option>
<xsl:attribute name="value"><xsl:value-of select="@value"/></xsl:attribute>
<xsl:variable name="value"><xsl:value-of select="@value"/></xsl:variable>
<xsl:for-each select="../value"> <!-- CAN HAVE MULTIPLE VALUES -->
<xsl:if test=".=$value">
<xsl:attribute name="selected">yes</xsl:attribute>
</xsl:if>
</xsl:for-each>
<xsl:value-of select="."/>
</option>
</xsl:for-each >
</select>
</xsl:when>
<xsl:when test='@type="checkbox"'> <!-- CHECKBOX FIELD -->
<xsl:variable name="name"><xsl:value-of select="@name"/></xsl:variable> <!-- NAME OF FIELD -->
<xsl:for-each select="option" >
<xsl:variable name="value"><xsl:value-of select="@value"/></xsl:variable> <!-- VALUE OF FIELD -->
<input>
<xsl:attribute name="name"><xsl:value-of select="$name"/>[<xsl:number format="0"/>]</xsl:attribute>
<xsl:attribute name="type">checkbox</xsl:attribute>
<xsl:for-each select="../html-display-option">
<xsl:attribute name="{@name}"><xsl:value-of select="@value"/></xsl:attribute>
</xsl:for-each >
<xsl:attribute name="value"><xsl:value-of select="@value"/></xsl:attribute>
<xsl:for-each select="../value"> <!-- CAN HAVE MULTIPLE VALUES -->
<xsl:if test=".=$value">
<xsl:attribute name="checked">yes</xsl:attribute>
</xsl:if>
</xsl:for-each>
<xsl:value-of select="."/>
</input>
</xsl:for-each >
</xsl:when>
<xsl:when test='@type="radio"'> <!-- RADIO BUTTON FIELD -->
<xsl:variable name="name"><xsl:value-of select="@name"/></xsl:variable> <!-- NAME OF FIELD -->
<xsl:variable name="default"><xsl:value-of select="value"/></xsl:variable>
<xsl:for-each select="option">
<input>
<xsl:attribute name="name"><xsl:value-of select="$name"/></xsl:attribute>
<xsl:attribute name="type">radio</xsl:attribute>
<xsl:for-each select="../html-display-option">
<xsl:attribute name="{@name}"><xsl:value-of select="@value"/></xsl:attribute>
</xsl:for-each>
<xsl:attribute name="value"><xsl:value-of select="@value"/></xsl:attribute>
<xsl:if test="$default=@value">
<xsl:attribute name="checked">yes</xsl:attribute>
</xsl:if>
<xsl:value-of select="."/>
</input>
</xsl:for-each>
</xsl:when>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
|