pcorreya
asked on
dynamic form using xsl
I am tailoring the following xsl file to generate a form dynamically using the attached xml. It is working fine for text boxes and multi-lines, but I can't get it to work properly to generate checkboxes. If you can debug it and get it working that will be excellent or suggest an alternative approach will be great.
<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method='html'/>
<!-- param values may be changed during the XSL Transformation -->
<xsl:param name="title">document title</xsl:param>
<xsl:param name="script">script_name< /xsl:param >
<xsl:param name="mode">insert</xsl:pa ram>
<xsl:param name="script_time">0.1234< /xsl:param >
<xsl:param name="formname">none</xsl: param>
<!-- include common templates -->
<xsl:template match="/">
<form name="{$formname}" method="post" action="{$script}">
<div id="detail">
<!-- select only the first record in the XML document -->
<xsl:apply-templates select="//issue[1]" />
</div>
</form>
</xsl:template>
<xsl:template match="issue[1]/*">
<!-- table contains a row for each database field -->
<table class="Form" width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<xsl:choose>
<xsl:when test="@label">
<xsl:value-of select="@label" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="name()" />
</xsl:otherwise>
</xsl:choose>
</td>
<td width="70%">
<xsl:call-template name="datafield">
<xsl:with-param name="item" select="node()"/>
</xsl:call-template>
</td>
</tr>
</table>
</xsl:template>
<xsl:template name="datafield">
<xsl:param name="item"/> <!-- the item name -->
<xsl:param name="multiple"/> <!-- set this for more than one occurrence -->
<!-- do nothing unless the item is present -->
<xsl:if test="$item">
<xsl:choose>
<xsl:when test="$item/@nodisplay">
<!-- 'nodisplay' attribute set, so display nothing -->
<xsl:text> </xsl:text>
</xsl:when>
<xsl:when test="$item/@control='bool ean'">
<xsl:call-template name="boolean">
<xsl:with-param name="item" select="$item"/>
<xsl:with-param name="multiple" select="$multiple"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="$item/@control='drop down'">
<xsl:call-template name="dropdown">
<xsl:with-param name="item" select="$item"/>
<xsl:with-param name="multiple" select="$multiple"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="@control='multiline' ">
<xsl:call-template name="multiline">
<xsl:with-param name="item" select="$item"/>
<xsl:with-param name="multiple" select="$multiple"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="$item/@control='popu p'">
<xsl:call-template name="popup">
<xsl:with-param name="item" select="$item"/>
<xsl:with-param name="multiple" select="$multiple"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="$item/@control='radi ogroup'">
<xsl:call-template name="radiogroup">
<xsl:with-param name="item" select="$item"/>
<xsl:with-param name="multiple" select="$multiple"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="@control='checkbox'" >
<xsl:call-template name="checkbox">
<xsl:with-param name="item" select="$item"/>
<xsl:with-param name="multiple" select="$multiple"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise> <!-- this is the default control type -->
<xsl:call-template name="textfield">
<xsl:with-param name="item" select="$item"/>
<xsl:with-param name="multiple" select="$multiple"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
<!-- check if field has error attribute set -->
<xsl:if test="$item/@error">
<br/><span class="error"><xsl:value-o f select="$item/@error"/></s pan>
</xsl:if>
</xsl:template>
<xsl:template name="boolean">
<xsl:param name="item"/>
<xsl:choose>
<xsl:when test="$mode='read' or $mode='delete' or $item/@noedit">
<!-- field cannot be modified, so display as text -->
<xsl:choose>
<xsl:when test="$item='T' or $item='t' or $item='Y' or $item='y' or $item='1'">
<xsl:text>Yes</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>No</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="$mode='search'">
<!-- create radio buttons for yes/no/undefined -->
<input type="radio" name="{name($item)}" value="" CHECKED="CHECKED" />Undefined
<input type="radio" name="{name($item)}" value="T" />Yes
<input type="radio" name="{name($item)}" value="F" />No
</xsl:when>
<xsl:otherwise>
<!-- field can be input or modified -->
<!-- create radio buttons for 'yes' or 'no' -->
<input type="radio" name="{name($item)}" value="T" >
<xsl:if test="$item='T' or $item='t' or $item='Y' or $item='y' or $item='1'">
<xsl:attribute name="CHECKED">CHECKED</xs l:attribut e>
</xsl:if>
</input>Yes
<input type="radio" name="{name($item)}" value="F" >
<xsl:if test="not($item='T' or $item='t' or $item='Y' or $item='y' or $item='1')">
<xsl:attribute name="CHECKED">CHECKED</xs l:attribut e>
</xsl:if>
</input>No
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="multiline">
<xsl:param name="item"/>
<xsl:choose>
<xsl:when test="$mode='search'">
<!-- use a normal input box instead of a multiline textarea -->
<input type="text" name="{name($item)}" value="{$item}" size="{$item/@cols}"/>
</xsl:when>
<xsl:otherwise>
<!-- create multiline field to allow data to be input or amended -->
<textarea>
<xsl:attribute name="name"><xsl:value-of select="name()"/></xsl:att ribute>
<xsl:attribute name="rows"><xsl:value-of select="@rows"/></xsl:attr ibute>
<xsl:attribute name="cols"><xsl:value-of select="@cols"/></xsl:attr ibute>
<!-- under certain conditions set this field to read only -->
<xsl:if test="$mode='read' or $mode='delete' or @noedit">
<xsl:attribute name="readonly">readonly</ xsl:attrib ute>
</xsl:if>
<xsl:value-of select="$item"/>
</textarea>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="dropdown">
<xsl:param name="item"/> <!-- the lookup value -->
<xsl:param name="multiple"/> <!-- optional, causes position number to be added to item name -->
<xsl:variable name="position" select="position()" />
<!-- this turns the value of the optionlist attribute into a node set -->
<xsl:variable name="optionlist" select="//*[name()=$item/@ optionlist ]"/>
<xsl:choose>
<xsl:when test="$mode='read' or $mode='delete' or $item/@noedit or ($mode='update' and $item/@pkey)">
<!-- item is read only, so output as plain text -->
<!-- look for an option where the id attribute equals the lookup value -->
<xsl:variable name="option" select="$optionlist/*[@id= $item]" />
<xsl:choose>
<xsl:when test="$option">
<!-- entry found, so use it -->
<xsl:value-of select="$option"/>
</xsl:when>
<xsl:otherwise>
<!-- entry not found, so default to lookup value -->
<xsl:value-of select="$item"/>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise> <!-- field can be modified -->
<!-- create a select statement for $item with a list of options -->
<select>
<xsl:attribute name="name">
<xsl:choose>
<!-- if 'multiple' is set then include row number in item name -->
<xsl:when test="$multiple">
<xsl:value-of select="concat(name($item) ,'[',$posi tion,']')" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="name($item)"/>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<xsl:for-each select="$optionlist/*">
<!-- use the 'id' attribute of the node as the 'value' attribute of 'option' -->
<option value="{@id}" >
<xsl:choose>
<xsl:when test="$item=@id">
<!-- this option has been selected -->
<xsl:attribute name="SELECTED">SELECTED</ xsl:attrib ute>
</xsl:when>
<xsl:when test="$item=node()">
<!-- this option has been selected (variation for ENUM fields) -->
<xsl:attribute name="SELECTED">SELECTED</ xsl:attrib ute>
</xsl:when>
</xsl:choose>
<!-- output the value of the current option -->
<xsl:value-of select="node()"/>
</option>
</xsl:for-each>
</select>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="popup">
<xsl:param name="item"/> <!-- key pointing to foreign table -->
<!-- this turns the value of the foreignfield attribute into a node set -->
<xsl:variable name="foreignfield" select="//*[name()=$item/@ foreignfie ld]"/>
<xsl:choose>
<xsl:when test="$mode='read' or $mode='delete' or not($item/@popupname)">
<!-- if $mode is read/delete then field is read only (not editable) -->
<!-- therefore popup button is not wanted -->
<!-- also ignore if $popupname is not supplied -->
</xsl:when>
<xsl:otherwise>
<div class="popup">
<!-- create a popup button -->
<input type="image" name="{$item/@popupname}"
src="images/popup.gif"
alt="Call popup form to obtain value" />
</div>
</xsl:otherwise>
</xsl:choose>
<!-- display the value of the field from the foreign table -->
<xsl:value-of select="$foreignfield"/>
<!-- hold the foreign key field, but do not display it -->
<input type="hidden" name="{name($item)}" value="{$item}" />
</xsl:template>
<xsl:template name="textfield">
<xsl:param name="item"/>
<xsl:param name="multiple"/>
<xsl:choose>
<xsl:when test="$mode='read' or $mode='delete'
or @noedit
or ($mode='update' and $item/@pkey)">
<!-- item is read only, so output value as plain text -->
<xsl:value-of select="$item"/>
</xsl:when>
<xsl:otherwise> <!-- field can be modified -->
<input>
<xsl:choose>
<!-- if 'multiple' indicator is set include position number -->
<xsl:when test="$multiple">
<xsl:attribute name="name">
<xsl:value-of select="concat(name($item) ,'[',posit ion(),']') "/>
</xsl:attribute>
</xsl:when>
<xsl:otherwise> <!-- use item name without any position number -->
<xsl:attribute name="name">
<xsl:value-of select="name()"/>
</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
<xsl:choose>
<!-- set type to either 'password' or 'text' -->
<xsl:when test="$item/@password">
<xsl:attribute name="type">password</xsl: attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="type">text</xsl:attr ibute>
</xsl:otherwise>
</xsl:choose>
<xsl:attribute name="value">
<xsl:value-of select="$item"/>
</xsl:attribute>
<xsl:attribute name="maxlength">
<xsl:value-of select="@size"/>
</xsl:attribute>
<xsl:choose>
<!-- if item size > 40 reduce display area to 40 characters -->
<xsl:when test="@size > 40">
<xsl:attribute name="size">40</xsl:attrib ute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="size">
<xsl:value-of select="@size"/>
</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
</input>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="radiogroup">
<xsl:param name="item"/> <!-- the lookup value -->
<xsl:param name="multiple"/> <!-- optional, causes position number to be added to item name -->
<xsl:variable name="position" select="position()" />
<!-- this turns the value of the optionlist attribute into a node set -->
<xsl:variable name="optionlist" select="//*[name()=$item/@ optionlist ]"/>
<!-- alignment is 'vertical' or 'horizontal' (default is 'horizontal') -->
<xsl:variable name="align" select="substring($item/@a lign,1,1)" />
<xsl:choose>
<xsl:when test="$mode='read' or $mode='delete'
or $item/@noedit
or ($mode='update' and $item/@pkey)">
<!-- item is read only, so output as plain text -->
<!-- look for an option where the id attribute equals the lookup value -->
<xsl:variable name="option" select="$optionlist/*[@id= $item]" />
<xsl:choose>
<xsl:when test="$option">
<!-- entry found, so use it -->
<xsl:value-of select="$option"/>
</xsl:when>
<xsl:otherwise>
<!-- entry not found, so default to lookup value -->
<xsl:value-of select="$item"/>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise> <!-- field can be modified -->
<!-- create an input statement for $item with a list of options -->
<xsl:for-each select="$optionlist/*">
<input type="radio" >
<xsl:attribute name="name">
<xsl:choose>
<!-- if 'multiple' is set then include row number in item name -->
<xsl:when test="$multiple">
<xsl:value-of select="concat(name($optio nlist),'[' ,$position ,']')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="name($optionlist)" />
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<xsl:attribute name="value">
<xsl:value-of select="@id" />
</xsl:attribute>
<!-- use the 'id' attribute of the node as the 'value' attribute -->
<xsl:if test="$item=@id">
<!-- this option has been selected -->
<xsl:attribute name="CHECKED">CHECKED</xs l:attribut e>
</xsl:if>
<xsl:if test="$item=node()">
<!-- this option has been selected (variation for ENUM fields) -->
<xsl:attribute name="CHECKED">CHECKED</xs l:attribut e>
</xsl:if>
</input>
<!-- output the value of the current option -->
<xsl:value-of select="node()"/>
<!-- insert single space as a separator -->
<xsl:text> </xsl:text>
<xsl:if test="$align='v'">
<!-- alignment is vertical, so insert line break after each option -->
<br/>
</xsl:if>
</xsl:for-each>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="checkbox">
<xsl:param name="item"/> <!-- the lookup value -->
<xsl:param name="multiple"/> <!-- optional, causes position number to be added to item name -->
<xsl:variable name="position" select="position()" />
<!-- this turns the value of the optionlist attribute into a node set -->
<xsl:variable name="optionlist" select="//*[name()=$item/@ optionlist ]"/>
<!-- alignment is 'vertical' or 'horizontal' (default is 'horizontal') -->
<xsl:variable name="align" select="substring(@align,1 ,1)"/>
<xsl:choose>
<xsl:when test="$mode='read' or $mode='delete'
or @noedit
or ($mode='update' and $item/@pkey)">
<!-- item is read only, so output as plain text -->
<!-- look for an option where the id attribute equals the lookup value -->
<xsl:variable name="option" select="$optionlist/*[@id= $item]" />
<xsl:choose>
<xsl:when test="$option">
<!-- entry found, so use it -->
<xsl:value-of select="$option"/>
</xsl:when>
<xsl:otherwise>
<!-- entry not found, so default to lookup value -->
<xsl:value-of select="$item"/>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise> <!-- field can be modified -->
<!-- create an input statement for $item with a list of options -->
<xsl:for-each select="$optionlist/*">
<input type="checkbox" >
<xsl:attribute name="name">
<xsl:choose>
<!-- if 'multiple' is set then include row number in item name -->
<xsl:when test="$multiple">
<xsl:value-of select="concat(name($optio nlist),'[' ,$position ,']')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="name($optionlist)" />
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<xsl:attribute name="value">
<xsl:value-of select="@id" />
</xsl:attribute>
<!-- use the 'id' attribute of the node as the 'value' attribute -->
<xsl:if test="$item=@id">
<!-- this option has been selected -->
<xsl:attribute name="CHECKED">CHECKED</xs l:attribut e>
</xsl:if>
<xsl:if test="$item=node()">
<!-- this option has been selected (variation for ENUM fields) -->
<xsl:attribute name="CHECKED">CHECKED</xs l:attribut e>
</xsl:if>
</input>
<!-- output the value of the current option -->
<xsl:value-of select="node()"/>
<!-- insert single space as a separator -->
<xsl:text> </xsl:text>
<xsl:if test="$align='v'">
<!-- alignment is vertical, so insert line break after each option -->
<br/>
</xsl:if>
</xsl:for-each>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
<formdataroot>
<issue>
<IssueNoReports label="Issue No" noedit="yes"><![CDATA[2173 7R-009]]>< /IssueNoRe ports>
<HealthStatus label="Health Status" size="10"><![CDATA[3]]></H ealthStatu s>
<Status><![CDATA[1]]></Sta tus>
<selectedIsState><![CDATA[ Closed]]>< /selectedI sState>
<CustName><![CDATA[AWB LTD.]]></CustName>
<IssueTitle><![CDATA[xxxxx xxxxxxx REPORTS]]></IssueTitle>
<Escalate><![CDATA[No]]></ Escalate>
<ReportIssue><![CDATA[No]] ></ReportI ssue>
<IssueClass label="Issue Class" control="checkbox" optionlist="issueclassopti ons"><![CD ATA[Custom er]]></Iss ueClass>
<IssueClass label="Issue Class" control="checkbox" optionlist="issueclassopti ons"><![CD ATA[Intern al]]></Iss ueClass>
<IssueClass label="Issue Class" control="checkbox" optionlist="issueclassopti ons"><![CD ATA[Servic e Delivery]]></IssueClass>
<ProductName><![CDATA[xxxx x Solution]]></ProductName>
<State><![CDATA[VIC]]></St ate>
<IssueAssName><![CDATA[Bug s Bunny]]></IssueAssName>
<ReqDate type="DATE"><![CDATA[20021 101]]></Re qDate>
<IssueAssName><![CDATA[Mic key Mouse]]></IssueAssName>
<IssueAssMgr><![CDATA[Joe Blogg]]></IssueAssMgr>
<IssueSubName><![CDATA[Mic key Mouse]]></IssueSubName>
<ProjTitle><![CDATA[Corpor ate Customer Management]]></ProjTitle>
<ICDelegationPath><![CDATA []]></ICDe legationPa th>
<EscalationPath><![CDATA[] ]></Escala tionPath>
<RODelegationPath control="multiline" rows="5" cols="30" noedit="yes"><![CDATA[xxxx xxxxxxxxxx xx
xxxxxxxxxxxxx
zzzzzzzzzzzzzz
]]></RODelegationPath>
<IssueResHistory control="multiline" rows="10" cols="50"><![CDATA[bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla.]]></IssueResHistory>
</issue>
<issueclassoptions>
<option id="Customer"><![CDATA[Cus tomer]]></ option>
<option id="Internal"><![CDATA[Int ernal]]></ option>
<option id="Resource"><![CDATA[Res ource]]></ option>
<option id="Project"><![CDATA[Proj ect]]></op tion>
<option id="System"><![CDATA[Syste m]]></opti on>
<option id="Product"><![CDATA[Prod uct]]></op tion>
<option id="Contract"><![CDATA[Con tract]]></ option>
<option id="Process"><![CDATA[Proc ess]]></op tion>
<option id="Service Delivery"><![CDATA[Service Delivery]]></option>
</issueclassoptions>
</formdataroot>
<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method='html'/>
<!-- param values may be changed during the XSL Transformation -->
<xsl:param name="title">document title</xsl:param>
<xsl:param name="script">script_name<
<xsl:param name="mode">insert</xsl:pa
<xsl:param name="script_time">0.1234<
<xsl:param name="formname">none</xsl:
<!-- include common templates -->
<xsl:template match="/">
<form name="{$formname}" method="post" action="{$script}">
<div id="detail">
<!-- select only the first record in the XML document -->
<xsl:apply-templates select="//issue[1]" />
</div>
</form>
</xsl:template>
<xsl:template match="issue[1]/*">
<!-- table contains a row for each database field -->
<table class="Form" width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<xsl:choose>
<xsl:when test="@label">
<xsl:value-of select="@label" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="name()" />
</xsl:otherwise>
</xsl:choose>
</td>
<td width="70%">
<xsl:call-template name="datafield">
<xsl:with-param name="item" select="node()"/>
</xsl:call-template>
</td>
</tr>
</table>
</xsl:template>
<xsl:template name="datafield">
<xsl:param name="item"/> <!-- the item name -->
<xsl:param name="multiple"/> <!-- set this for more than one occurrence -->
<!-- do nothing unless the item is present -->
<xsl:if test="$item">
<xsl:choose>
<xsl:when test="$item/@nodisplay">
<!-- 'nodisplay' attribute set, so display nothing -->
<xsl:text> </xsl:text>
</xsl:when>
<xsl:when test="$item/@control='bool
<xsl:call-template name="boolean">
<xsl:with-param name="item" select="$item"/>
<xsl:with-param name="multiple" select="$multiple"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="$item/@control='drop
<xsl:call-template name="dropdown">
<xsl:with-param name="item" select="$item"/>
<xsl:with-param name="multiple" select="$multiple"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="@control='multiline'
<xsl:call-template name="multiline">
<xsl:with-param name="item" select="$item"/>
<xsl:with-param name="multiple" select="$multiple"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="$item/@control='popu
<xsl:call-template name="popup">
<xsl:with-param name="item" select="$item"/>
<xsl:with-param name="multiple" select="$multiple"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="$item/@control='radi
<xsl:call-template name="radiogroup">
<xsl:with-param name="item" select="$item"/>
<xsl:with-param name="multiple" select="$multiple"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="@control='checkbox'"
<xsl:call-template name="checkbox">
<xsl:with-param name="item" select="$item"/>
<xsl:with-param name="multiple" select="$multiple"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise> <!-- this is the default control type -->
<xsl:call-template name="textfield">
<xsl:with-param name="item" select="$item"/>
<xsl:with-param name="multiple" select="$multiple"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
<!-- check if field has error attribute set -->
<xsl:if test="$item/@error">
<br/><span class="error"><xsl:value-o
</xsl:if>
</xsl:template>
<xsl:template name="boolean">
<xsl:param name="item"/>
<xsl:choose>
<xsl:when test="$mode='read' or $mode='delete' or $item/@noedit">
<!-- field cannot be modified, so display as text -->
<xsl:choose>
<xsl:when test="$item='T' or $item='t' or $item='Y' or $item='y' or $item='1'">
<xsl:text>Yes</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>No</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="$mode='search'">
<!-- create radio buttons for yes/no/undefined -->
<input type="radio" name="{name($item)}" value="" CHECKED="CHECKED" />Undefined
<input type="radio" name="{name($item)}" value="T" />Yes
<input type="radio" name="{name($item)}" value="F" />No
</xsl:when>
<xsl:otherwise>
<!-- field can be input or modified -->
<!-- create radio buttons for 'yes' or 'no' -->
<input type="radio" name="{name($item)}" value="T" >
<xsl:if test="$item='T' or $item='t' or $item='Y' or $item='y' or $item='1'">
<xsl:attribute name="CHECKED">CHECKED</xs
</xsl:if>
</input>Yes
<input type="radio" name="{name($item)}" value="F" >
<xsl:if test="not($item='T' or $item='t' or $item='Y' or $item='y' or $item='1')">
<xsl:attribute name="CHECKED">CHECKED</xs
</xsl:if>
</input>No
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="multiline">
<xsl:param name="item"/>
<xsl:choose>
<xsl:when test="$mode='search'">
<!-- use a normal input box instead of a multiline textarea -->
<input type="text" name="{name($item)}" value="{$item}" size="{$item/@cols}"/>
</xsl:when>
<xsl:otherwise>
<!-- create multiline field to allow data to be input or amended -->
<textarea>
<xsl:attribute name="name"><xsl:value-of select="name()"/></xsl:att
<xsl:attribute name="rows"><xsl:value-of select="@rows"/></xsl:attr
<xsl:attribute name="cols"><xsl:value-of select="@cols"/></xsl:attr
<!-- under certain conditions set this field to read only -->
<xsl:if test="$mode='read' or $mode='delete' or @noedit">
<xsl:attribute name="readonly">readonly</
</xsl:if>
<xsl:value-of select="$item"/>
</textarea>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="dropdown">
<xsl:param name="item"/> <!-- the lookup value -->
<xsl:param name="multiple"/> <!-- optional, causes position number to be added to item name -->
<xsl:variable name="position" select="position()" />
<!-- this turns the value of the optionlist attribute into a node set -->
<xsl:variable name="optionlist" select="//*[name()=$item/@
<xsl:choose>
<xsl:when test="$mode='read' or $mode='delete' or $item/@noedit or ($mode='update' and $item/@pkey)">
<!-- item is read only, so output as plain text -->
<!-- look for an option where the id attribute equals the lookup value -->
<xsl:variable name="option" select="$optionlist/*[@id=
<xsl:choose>
<xsl:when test="$option">
<!-- entry found, so use it -->
<xsl:value-of select="$option"/>
</xsl:when>
<xsl:otherwise>
<!-- entry not found, so default to lookup value -->
<xsl:value-of select="$item"/>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise> <!-- field can be modified -->
<!-- create a select statement for $item with a list of options -->
<select>
<xsl:attribute name="name">
<xsl:choose>
<!-- if 'multiple' is set then include row number in item name -->
<xsl:when test="$multiple">
<xsl:value-of select="concat(name($item)
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="name($item)"/>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<xsl:for-each select="$optionlist/*">
<!-- use the 'id' attribute of the node as the 'value' attribute of 'option' -->
<option value="{@id}" >
<xsl:choose>
<xsl:when test="$item=@id">
<!-- this option has been selected -->
<xsl:attribute name="SELECTED">SELECTED</
</xsl:when>
<xsl:when test="$item=node()">
<!-- this option has been selected (variation for ENUM fields) -->
<xsl:attribute name="SELECTED">SELECTED</
</xsl:when>
</xsl:choose>
<!-- output the value of the current option -->
<xsl:value-of select="node()"/>
</option>
</xsl:for-each>
</select>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="popup">
<xsl:param name="item"/> <!-- key pointing to foreign table -->
<!-- this turns the value of the foreignfield attribute into a node set -->
<xsl:variable name="foreignfield" select="//*[name()=$item/@
<xsl:choose>
<xsl:when test="$mode='read' or $mode='delete' or not($item/@popupname)">
<!-- if $mode is read/delete then field is read only (not editable) -->
<!-- therefore popup button is not wanted -->
<!-- also ignore if $popupname is not supplied -->
</xsl:when>
<xsl:otherwise>
<div class="popup">
<!-- create a popup button -->
<input type="image" name="{$item/@popupname}"
src="images/popup.gif"
alt="Call popup form to obtain value" />
</div>
</xsl:otherwise>
</xsl:choose>
<!-- display the value of the field from the foreign table -->
<xsl:value-of select="$foreignfield"/>
<!-- hold the foreign key field, but do not display it -->
<input type="hidden" name="{name($item)}" value="{$item}" />
</xsl:template>
<xsl:template name="textfield">
<xsl:param name="item"/>
<xsl:param name="multiple"/>
<xsl:choose>
<xsl:when test="$mode='read' or $mode='delete'
or @noedit
or ($mode='update' and $item/@pkey)">
<!-- item is read only, so output value as plain text -->
<xsl:value-of select="$item"/>
</xsl:when>
<xsl:otherwise> <!-- field can be modified -->
<input>
<xsl:choose>
<!-- if 'multiple' indicator is set include position number -->
<xsl:when test="$multiple">
<xsl:attribute name="name">
<xsl:value-of select="concat(name($item)
</xsl:attribute>
</xsl:when>
<xsl:otherwise> <!-- use item name without any position number -->
<xsl:attribute name="name">
<xsl:value-of select="name()"/>
</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
<xsl:choose>
<!-- set type to either 'password' or 'text' -->
<xsl:when test="$item/@password">
<xsl:attribute name="type">password</xsl:
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="type">text</xsl:attr
</xsl:otherwise>
</xsl:choose>
<xsl:attribute name="value">
<xsl:value-of select="$item"/>
</xsl:attribute>
<xsl:attribute name="maxlength">
<xsl:value-of select="@size"/>
</xsl:attribute>
<xsl:choose>
<!-- if item size > 40 reduce display area to 40 characters -->
<xsl:when test="@size > 40">
<xsl:attribute name="size">40</xsl:attrib
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="size">
<xsl:value-of select="@size"/>
</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
</input>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="radiogroup">
<xsl:param name="item"/> <!-- the lookup value -->
<xsl:param name="multiple"/> <!-- optional, causes position number to be added to item name -->
<xsl:variable name="position" select="position()" />
<!-- this turns the value of the optionlist attribute into a node set -->
<xsl:variable name="optionlist" select="//*[name()=$item/@
<!-- alignment is 'vertical' or 'horizontal' (default is 'horizontal') -->
<xsl:variable name="align" select="substring($item/@a
<xsl:choose>
<xsl:when test="$mode='read' or $mode='delete'
or $item/@noedit
or ($mode='update' and $item/@pkey)">
<!-- item is read only, so output as plain text -->
<!-- look for an option where the id attribute equals the lookup value -->
<xsl:variable name="option" select="$optionlist/*[@id=
<xsl:choose>
<xsl:when test="$option">
<!-- entry found, so use it -->
<xsl:value-of select="$option"/>
</xsl:when>
<xsl:otherwise>
<!-- entry not found, so default to lookup value -->
<xsl:value-of select="$item"/>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise> <!-- field can be modified -->
<!-- create an input statement for $item with a list of options -->
<xsl:for-each select="$optionlist/*">
<input type="radio" >
<xsl:attribute name="name">
<xsl:choose>
<!-- if 'multiple' is set then include row number in item name -->
<xsl:when test="$multiple">
<xsl:value-of select="concat(name($optio
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="name($optionlist)"
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<xsl:attribute name="value">
<xsl:value-of select="@id" />
</xsl:attribute>
<!-- use the 'id' attribute of the node as the 'value' attribute -->
<xsl:if test="$item=@id">
<!-- this option has been selected -->
<xsl:attribute name="CHECKED">CHECKED</xs
</xsl:if>
<xsl:if test="$item=node()">
<!-- this option has been selected (variation for ENUM fields) -->
<xsl:attribute name="CHECKED">CHECKED</xs
</xsl:if>
</input>
<!-- output the value of the current option -->
<xsl:value-of select="node()"/>
<!-- insert single space as a separator -->
<xsl:text> </xsl:text>
<xsl:if test="$align='v'">
<!-- alignment is vertical, so insert line break after each option -->
<br/>
</xsl:if>
</xsl:for-each>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="checkbox">
<xsl:param name="item"/> <!-- the lookup value -->
<xsl:param name="multiple"/> <!-- optional, causes position number to be added to item name -->
<xsl:variable name="position" select="position()" />
<!-- this turns the value of the optionlist attribute into a node set -->
<xsl:variable name="optionlist" select="//*[name()=$item/@
<!-- alignment is 'vertical' or 'horizontal' (default is 'horizontal') -->
<xsl:variable name="align" select="substring(@align,1
<xsl:choose>
<xsl:when test="$mode='read' or $mode='delete'
or @noedit
or ($mode='update' and $item/@pkey)">
<!-- item is read only, so output as plain text -->
<!-- look for an option where the id attribute equals the lookup value -->
<xsl:variable name="option" select="$optionlist/*[@id=
<xsl:choose>
<xsl:when test="$option">
<!-- entry found, so use it -->
<xsl:value-of select="$option"/>
</xsl:when>
<xsl:otherwise>
<!-- entry not found, so default to lookup value -->
<xsl:value-of select="$item"/>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise> <!-- field can be modified -->
<!-- create an input statement for $item with a list of options -->
<xsl:for-each select="$optionlist/*">
<input type="checkbox" >
<xsl:attribute name="name">
<xsl:choose>
<!-- if 'multiple' is set then include row number in item name -->
<xsl:when test="$multiple">
<xsl:value-of select="concat(name($optio
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="name($optionlist)"
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<xsl:attribute name="value">
<xsl:value-of select="@id" />
</xsl:attribute>
<!-- use the 'id' attribute of the node as the 'value' attribute -->
<xsl:if test="$item=@id">
<!-- this option has been selected -->
<xsl:attribute name="CHECKED">CHECKED</xs
</xsl:if>
<xsl:if test="$item=node()">
<!-- this option has been selected (variation for ENUM fields) -->
<xsl:attribute name="CHECKED">CHECKED</xs
</xsl:if>
</input>
<!-- output the value of the current option -->
<xsl:value-of select="node()"/>
<!-- insert single space as a separator -->
<xsl:text> </xsl:text>
<xsl:if test="$align='v'">
<!-- alignment is vertical, so insert line break after each option -->
<br/>
</xsl:if>
</xsl:for-each>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
<formdataroot>
<issue>
<IssueNoReports label="Issue No" noedit="yes"><![CDATA[2173
<HealthStatus label="Health Status" size="10"><![CDATA[3]]></H
<Status><![CDATA[1]]></Sta
<selectedIsState><![CDATA[
<CustName><![CDATA[AWB LTD.]]></CustName>
<IssueTitle><![CDATA[xxxxx
<Escalate><![CDATA[No]]></
<ReportIssue><![CDATA[No]]
<IssueClass label="Issue Class" control="checkbox" optionlist="issueclassopti
<IssueClass label="Issue Class" control="checkbox" optionlist="issueclassopti
<IssueClass label="Issue Class" control="checkbox" optionlist="issueclassopti
<ProductName><![CDATA[xxxx
<State><![CDATA[VIC]]></St
<IssueAssName><![CDATA[Bug
<ReqDate type="DATE"><![CDATA[20021
<IssueAssName><![CDATA[Mic
<IssueAssMgr><![CDATA[Joe Blogg]]></IssueAssMgr>
<IssueSubName><![CDATA[Mic
<ProjTitle><![CDATA[Corpor
<ICDelegationPath><![CDATA
<EscalationPath><![CDATA[]
<RODelegationPath control="multiline" rows="5" cols="30" noedit="yes"><![CDATA[xxxx
xxxxxxxxxxxxx
zzzzzzzzzzzzzz
]]></RODelegationPath>
<IssueResHistory control="multiline" rows="10" cols="50"><![CDATA[bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla.]]></IssueResHistory>
</issue>
<issueclassoptions>
<option id="Customer"><![CDATA[Cus
<option id="Internal"><![CDATA[Int
<option id="Resource"><![CDATA[Res
<option id="Project"><![CDATA[Proj
<option id="System"><![CDATA[Syste
<option id="Product"><![CDATA[Prod
<option id="Contract"><![CDATA[Con
<option id="Process"><![CDATA[Proc
<option id="Service Delivery"><![CDATA[Service
</issueclassoptions>
</formdataroot>
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
<formdataroot>
<issue>
<group>
<IssueNoReports label="Issue No" noedit="yes" position="Left"><![CDATA[2
<HealthStatus label="Health Status" size="10" position="Right"><![CDATA[
</group>
<group>
<Status position="Left"><![CDATA[1
<selectedIsState label="State" position="Right"><![CDATA[
</group>
<group>
<CustName label="Customer Name" position="Left"><![CDATA[A
</group>
<group>
<IssueTitle position="Left"><![CDATA[T
<MyManager label="This is my manager" size="10" position="Right"><![CDATA[
</group>
<group>
<Escalate position="Left"><![CDATA[N
<ReportIssue position="Right"><![CDATA[
</group>
<group>
<IssueClass label="Issue Class" control="checkbox" optionlist="issueclassopti
Internal
Service Delivery
]]></IssueClass>
<ProductName position="Right"><![CDATA[
</group>
<group>
<State position="Left"><![CDATA[V
<IssueAssName position="Right"><![CDATA[
</group>
<group>
<ReqDate type="DATE"><![CDATA[20021
</group>
<group>
<IssueAssMgr position="Left"><![CDATA[x
<IssueSubName position="Left"><![CDATA[x
</group>
<group>
<ProjTitle label="Project Title" position="Left"><![CDATA[x
<ICDelegationPath label="Delegation Path" position="Right"><![CDATA[
</group>
<group>
<EscalationPath label="Escalation Path" position="Left"><![CDATA[]
<RODelegationPath control="multiline" rows="5" cols="30" noedit="yes" position="Right"><![CDATA[
xxxxxxx
xxxxxxxx
]]></RODelegationPath>
</group>
<group>
<IssueResHistory position="Left" control="multiline" rows="10" cols="50" popupname="HistoryZoom" title="Zoom" image="/icons/actn101.gif"
</group>
</issue>
<issueclassoptions>
<option id="Customer" checked="yes"><![CDATA[Cus
<option id="Internal" checked="yes"><![CDATA[Int
<option id="Resource"><![CDATA[Res
<option id="Project"><![CDATA[Proj
<option id="System"><![CDATA[Syste
<option id="Product"><![CDATA[Prod
<option id="Contract"><![CDATA[Con
<option id="Process"><![CDATA[Proc
<option id="Service Delivery" checked="yes"><![CDATA[Ser
</issueclassoptions>
</formdataroot>
Here is the xsl
<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method='html'/>
<!-- param values may be changed during the XSL Transformation -->
<xsl:param name="title">document title</xsl:param>
<xsl:param name="script">script_name<
<xsl:param name="mode">insert</xsl:pa
<xsl:param name="script_time">0.1234<
<xsl:param name="formname">none</xsl:
<!-- include common templates -->
<xsl:template match="formdataroot">
<form name="{$formname}" method="post" action="{$script}">
<div id="detail">
<!-- select only the first record in the XML document -->
<!-- table contains a row for each database field -->
<table class="Form" width="100%" border="0" cellspacing="0" cellpadding="0">
<xsl:apply-templates select="issue[1]" />
</table>
</div>
</form>
</xsl:template>
<xsl:template match="issue">
<tr><td colspan="5"><br/></td></tr
<tr>
<xsl:for-each select="group">
<td width="1%"></td>
<td class="FieldLabel" valign="top" width="25%">
<xsl:choose>
<xsl:when test="@label">
<xsl:value-of select="@label" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="name()" />
</xsl:otherwise>
</xsl:choose>
</td>
<td width="24%">
<xsl:call-template name="datafield">
<xsl:with-param name="item" select="."/>
</xsl:call-template>
<xsl:if test="@popupname">
<!-- create a popup button -->
<input type="image" name="{@popupname}"
src="{@image}"
title="{@title}"
onClick="{@onclick}"/>
</xsl:if>
</td>
</xsl:for-each>
</tr>
</xsl:template>
<xsl:template name="datafield">
<xsl:param name="item"/> <!-- the item name -->
<xsl:param name="multiple"/> <!-- set this for more than one occurrence -->
<!-- do nothing unless the item is present -->
<xsl:if test="$item">
<xsl:choose>
<xsl:when test="$item/@nodisplay">
<!-- 'nodisplay' attribute set, so display nothing -->
<xsl:text> </xsl:text>
</xsl:when>
<xsl:when test="$item/@control='bool
<xsl:call-template name="boolean">
<xsl:with-param name="item" select="$item"/>
<xsl:with-param name="multiple" select="$multiple"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="$item/@control='drop
<xsl:call-template name="dropdown">
<xsl:with-param name="item" select="$item"/>
<xsl:with-param name="multiple" select="$multiple"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="@control='multiline'
<xsl:call-template name="multiline">
<xsl:with-param name="item" select="$item"/>
<xsl:with-param name="multiple" select="$multiple"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="@control='popup'">
<xsl:call-template name="popup">
<xsl:with-param name="item" select="$item"/>
<xsl:with-param name="multiple" select="$multiple"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="$item/@control='radi
<xsl:call-template name="radiogroup">
<xsl:with-param name="item" select="$item"/>
<xsl:with-param name="multiple" select="$multiple"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="@control='checkbox'"
<xsl:call-template name="checkbox">
<xsl:with-param name="item" select="$item"/>
<xsl:with-param name="multiple" select="$multiple"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise> <!-- this is the default control type -->
<xsl:call-template name="textfield">
<xsl:with-param name="item" select="$item"/>
<xsl:with-param name="multiple" select="$multiple"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
<!-- check if field has error attribute set -->
<xsl:if test="$item/@error">
<br/><span class="error"><xsl:value-o
</xsl:if>
</xsl:template>
<xsl:template name="boolean">
<xsl:param name="item"/>
<xsl:choose>
<xsl:when test="$mode='read' or $mode='delete' or $item/@noedit">
<!-- field cannot be modified, so display as text -->
<xsl:choose>
<xsl:when test="$item='T' or $item='t' or $item='Y' or $item='y' or $item='1'">
<xsl:text>Yes</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>No</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="$mode='search'">
<!-- create radio buttons for yes/no/undefined -->
<input type="radio" name="{name($item)}" value="" CHECKED="CHECKED" />Undefined
<input type="radio" name="{name($item)}" value="T" />Yes
<input type="radio" name="{name($item)}" value="F" />No
</xsl:when>
<xsl:otherwise>
<!-- field can be input or modified -->
<!-- create radio buttons for 'yes' or 'no' -->
<input type="radio" name="{name($item)}" value="T" >
<xsl:if test="$item='T' or $item='t' or $item='Y' or $item='y' or $item='1'">
<xsl:attribute name="CHECKED">CHECKED</xs
</xsl:if>
</input>Yes
<input type="radio" name="{name($item)}" value="F" >
<xsl:if test="not($item='T' or $item='t' or $item='Y' or $item='y' or $item='1')">
<xsl:attribute name="CHECKED">CHECKED</xs
</xsl:if>
</input>No
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="multiline">
<xsl:param name="item"/>
<xsl:choose>
<xsl:when test="$mode='read' or $mode='delete'
or ($mode='update' and $item/@pkey)">
<!-- item is read only, so output value as plain text -->
<xsl:value-of select="$item"/>
</xsl:when>
<xsl:otherwise>
<!-- create multiline field to allow data to be input or amended -->
<textarea>
<xsl:attribute name="name"><xsl:value-of select="name()"/></xsl:att
<xsl:attribute name="rows"><xsl:value-of select="@rows"/></xsl:attr
<xsl:attribute name="cols"><xsl:value-of select="@cols"/></xsl:attr
<!-- under certain conditions set this field to read only -->
<xsl:if test="$mode='read' or $mode='delete' or @noedit">
<xsl:attribute name="readonly">readonly</
</xsl:if>
<xsl:value-of select="$item"/>
</textarea>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="dropdown">
<xsl:param name="item"/> <!-- the lookup value -->
<xsl:param name="multiple"/> <!-- optional, causes position number to be added to item name -->
<xsl:variable name="position" select="position()" />
<!-- this turns the value of the optionlist attribute into a node set -->
<xsl:variable name="optionlist" select="//*[name()=$item/@
<xsl:choose>
<xsl:when test="$mode='read' or $mode='delete' or $item/@noedit or ($mode='update' and $item/@pkey)">
<!-- item is read only, so output as plain text -->
<!-- look for an option where the id attribute equals the lookup value -->
<xsl:variable name="option" select="$optionlist/*[@id=
<xsl:choose>
<xsl:when test="$option">
<!-- entry found, so use it -->
<xsl:value-of select="$option"/>
</xsl:when>
<xsl:otherwise>
<!-- entry not found, so default to lookup value -->
<xsl:value-of select="$item"/>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise> <!-- field can be modified -->
<!-- create a select statement for $item with a list of options -->
<select>
<xsl:attribute name="name">
<xsl:choose>
<!-- if 'multiple' is set then include row number in item name -->
<xsl:when test="$multiple">
<xsl:value-of select="concat(name($item)
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="name($item)"/>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<xsl:for-each select="$optionlist/*">
<!-- use the 'id' attribute of the node as the 'value' attribute of 'option' -->
<option value="{@id}" >
<xsl:choose>
<xsl:when test="$item=@id">
<!-- this option has been selected -->
<xsl:attribute name="SELECTED">SELECTED</
</xsl:when>
<xsl:when test="$item=node()">
<!-- this option has been selected (variation for ENUM fields) -->
<xsl:attribute name="SELECTED">SELECTED</
</xsl:when>
</xsl:choose>
<!-- output the value of the current option -->
<xsl:value-of select="node()"/>
</option>
</xsl:for-each>
</select>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="popup">
<xsl:param name="item"/> <!-- key pointing to foreign table -->
<xsl:choose>
<xsl:when test="$mode='read' or $mode='delete' or not($item/@popupname)">
<!-- if $mode is read/delete then field is read only (not editable) -->
<!-- therefore popup button is not wanted -->
<!-- also ignore if $popupname is not supplied -->
</xsl:when>
<xsl:otherwise>
<!-- create a popup button -->
<input type="image" name="{$item/@popupname}"
src="{$item/@image}"
title="{$item/@title}"
onClick="{$item/@onclick}"
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="textfield">
<xsl:param name="item"/>
<xsl:param name="multiple"/>
<xsl:choose>
<xsl:when test="$mode='read' or $mode='delete'
or @noedit
or ($mode='update' and $item/@pkey)">
<!-- item is read only, so output value as plain text -->
<xsl:value-of select="$item"/>
</xsl:when>
<xsl:otherwise> <!-- field can be modified -->
<input>
<xsl:choose>
<!-- if 'multiple' indicator is set include position number -->
<xsl:when test="$multiple">
<xsl:attribute name="name">
<xsl:value-of select="concat(name($item)
</xsl:attribute>
</xsl:when>
<xsl:otherwise> <!-- use item name without any position number -->
<xsl:attribute name="name">
<xsl:value-of select="name()"/>
</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
<xsl:choose>
<!-- set type to either 'password' or 'text' -->
<xsl:when test="$item/@password">
<xsl:attribute name="type">password</xsl:
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="type">text</xsl:attr
</xsl:otherwise>
</xsl:choose>
<xsl:attribute name="value">
<xsl:value-of select="$item"/>
</xsl:attribute>
<xsl:attribute name="maxlength">
<xsl:value-of select="$item/@size"/>
</xsl:attribute>
<xsl:choose>
<!-- if item size > 40 reduce display area to 40 characters -->
<xsl:when test="$item/@size > 40">
<xsl:attribute name="size">40</xsl:attrib
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="size">
<xsl:value-of select="$item/@size"/>
</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
</input>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="radiogroup">
<xsl:param name="item"/> <!-- the lookup value -->
<xsl:param name="multiple"/> <!-- optional, causes position number to be added to item name -->
<xsl:variable name="position" select="position()" />
<!-- this turns the value of the optionlist attribute into a node set -->
<xsl:variable name="optionlist" select="//*[name()=$item/@
<!-- alignment is 'vertical' or 'horizontal' (default is 'horizontal') -->
<xsl:variable name="align" select="substring($item/@a
<xsl:choose>
<xsl:when test="$mode='read' or $mode='delete'
or $item/@noedit
or ($mode='update' and $item/@pkey)">
<!-- item is read only, so output as plain text -->
<!-- look for an option where the id attribute equals the lookup value -->
<xsl:variable name="option" select="$optionlist/*[@id=
<xsl:choose>
<xsl:when test="$option">
<!-- entry found, so use it -->
<xsl:value-of select="$option"/>
</xsl:when>
<xsl:otherwise>
<!-- entry not found, so default to lookup value -->
<xsl:value-of select="$item"/>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise> <!-- field can be modified -->
<!-- create an input statement for $item with a list of options -->
<xsl:for-each select="$optionlist/*">
<input type="radio" >
<xsl:attribute name="name">
<xsl:choose>
<!-- if 'multiple' is set then include row number in item name -->
<xsl:when test="$multiple">
<xsl:value-of select="concat(name($optio
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="name($optionlist)"
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<xsl:attribute name="value">
<xsl:value-of select="@id" />
</xsl:attribute>
<!-- use the 'id' attribute of the node as the 'value' attribute -->
<xsl:if test="$item=@id">
<!-- this option has been selected -->
<xsl:attribute name="CHECKED">CHECKED</xs
</xsl:if>
<xsl:if test="$item=node()">
<!-- this option has been selected (variation for ENUM fields) -->
<xsl:attribute name="CHECKED">CHECKED</xs
</xsl:if>
</input>
<!-- output the value of the current option -->
<xsl:value-of select="node()"/>
<!-- insert single space as a separator -->
<xsl:text> </xsl:text>
<xsl:if test="$align='v'">
<!-- alignment is vertical, so insert line break after each option -->
<br/>
</xsl:if>
</xsl:for-each>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="checkbox">
<xsl:param name="item"/> <!-- the lookup value -->
<xsl:param name="multiple"/> <!-- optional, causes position number to be added to item name -->
<xsl:variable name="position" select="position()" />
<!-- this turns the value of the optionlist attribute into a node set -->
<xsl:variable name="optionlist" select="//*[name()=$item/@
<!-- alignment is 'vertical' or 'horizontal' (default is 'horizontal') -->
<xsl:variable name="align" select="substring($item/@a
<xsl:choose>
<xsl:when test="$mode='read' or $mode='delete'
or @noedit
or ($mode='update' and $item/@pkey)">
<!-- item is read only, so output as plain text -->
<!-- look for an option where the id attribute equals the lookup value -->
<xsl:variable name="option" select="$optionlist/*[@id=
<xsl:choose>
<xsl:when test="$option">
<!-- entry found, so use it -->
<xsl:value-of select="$option"/>
</xsl:when>
<xsl:otherwise>
<!-- entry not found, so default to lookup value -->
<xsl:value-of select="$item"/>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise> <!-- field can be modified -->
<!-- create an input statement for $item with a list of options -->
<xsl:for-each select="$optionlist/*">
<input type="checkbox" >
<xsl:attribute name="name">
<xsl:choose>
<!-- if 'multiple' is set then include row number in item name -->
<xsl:when test="$multiple">
<xsl:value-of select="concat(name($optio
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="name($item)"/>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<xsl:attribute name="value">
<xsl:value-of select="@id" />
</xsl:attribute>
<!-- use the 'id' attribute of the node as the 'value' attribute -->
<xsl:if test="@checked">
<!-- this option has been selected -->
<xsl:attribute name="CHECKED">CHECKED</xs
</xsl:if>
<xsl:if test="$item=node()">
<!-- this option has been selected (variation for ENUM fields) -->
<xsl:attribute name="CHECKED">CHECKED</xs
</xsl:if>
</input>
<!-- output the value of the current option -->
<xsl:value-of select="node()"/>
<!-- insert single space as a separator -->
<xsl:text> </xsl:text>
<xsl:if test="$align='v'">
<!-- alignment is vertical, so insert line break after each option -->
<br/>
</xsl:if>
</xsl:for-each>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>