Link to home
Start Free TrialLog in
Avatar of pcorreya
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:param>
<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='boolean'">
        <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='dropdown'">
        <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='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='radiogroup'">
        <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-of select="$item/@error"/></span>
  </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</xsl:attribute>
        </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</xsl:attribute>
        </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:attribute>
        <xsl:attribute name="rows"><xsl:value-of select="@rows"/></xsl:attribute>
        <xsl:attribute name="cols"><xsl:value-of select="@cols"/></xsl:attribute>

        <!-- 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:attribute>
        </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),'[',$position,']')"/>
            </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:attribute>
              </xsl:when>
              <xsl:when test="$item=node()">
                <!-- this option has been selected (variation for ENUM fields) -->
                <xsl:attribute name="SELECTED">SELECTED</xsl:attribute>
              </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/@foreignfield]"/>

  <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),'[',position(),']')"/>
            </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:attribute>
          </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:attribute>
          </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/@align,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($optionlist),'[',$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</xsl:attribute>
          </xsl:if>
         
          <xsl:if test="$item=node()">
            <!-- this option has been selected (variation for ENUM fields) -->
            <xsl:attribute name="CHECKED">CHECKED</xsl:attribute>
          </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($optionlist),'[',$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</xsl:attribute>
          </xsl:if>
         
          <xsl:if test="$item=node()">
            <!-- this option has been selected (variation for ENUM fields) -->
            <xsl:attribute name="CHECKED">CHECKED</xsl:attribute>
          </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[21737R-009]]></IssueNoReports>
  <HealthStatus label="Health Status" size="10"><![CDATA[3]]></HealthStatus>
  <Status><![CDATA[1]]></Status>
  <selectedIsState><![CDATA[Closed]]></selectedIsState>
  <CustName><![CDATA[AWB LTD.]]></CustName>
  <IssueTitle><![CDATA[xxxxxxxxxxxx REPORTS]]></IssueTitle>
  <Escalate><![CDATA[No]]></Escalate>
  <ReportIssue><![CDATA[No]]></ReportIssue>
  <IssueClass label="Issue Class" control="checkbox" optionlist="issueclassoptions"><![CDATA[Customer]]></IssueClass>
  <IssueClass label="Issue Class" control="checkbox" optionlist="issueclassoptions"><![CDATA[Internal]]></IssueClass>
  <IssueClass label="Issue Class" control="checkbox" optionlist="issueclassoptions"><![CDATA[Service Delivery]]></IssueClass>
  <ProductName><![CDATA[xxxxx Solution]]></ProductName>
  <State><![CDATA[VIC]]></State>
  <IssueAssName><![CDATA[Bugs Bunny]]></IssueAssName>
  <ReqDate type="DATE"><![CDATA[20021101]]></ReqDate>
  <IssueAssName><![CDATA[Mickey Mouse]]></IssueAssName>
  <IssueAssMgr><![CDATA[Joe Blogg]]></IssueAssMgr>
  <IssueSubName><![CDATA[Mickey Mouse]]></IssueSubName>
  <ProjTitle><![CDATA[Corporate Customer Management]]></ProjTitle>
  <ICDelegationPath><![CDATA[]]></ICDelegationPath>
  <EscalationPath><![CDATA[]]></EscalationPath>
  <RODelegationPath control="multiline" rows="5" cols="30" noedit="yes"><![CDATA[xxxxxxxxxxxxxxxx
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[Customer]]></option>
  <option id="Internal"><![CDATA[Internal]]></option>
  <option id="Resource"><![CDATA[Resource]]></option>
  <option id="Project"><![CDATA[Project]]></option>
  <option id="System"><![CDATA[System]]></option>
  <option id="Product"><![CDATA[Product]]></option>
  <option id="Contract"><![CDATA[Contract]]></option>
  <option id="Process"><![CDATA[Process]]></option>
  <option id="Service Delivery"><![CDATA[Service Delivery]]></option>
 </issueclassoptions>
</formdataroot>  
 
SOLUTION
Avatar of rdcpro
rdcpro
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of pcorreya
pcorreya

ASKER

Thank you both for your comments, i got it working. However, I needed to change the structure of the xml tree as shown below. Now it is not processing the group nodes correctly. It appears to iterate through the group nodes without going back to the parent node.

<formdataroot>
 <issue>
  <group>
   <IssueNoReports label="Issue No" noedit="yes" position="Left"><![CDATA[21737R-009]]></IssueNoReports>
   <HealthStatus label="Health Status" size="10" position="Right"><![CDATA[3]]></HealthStatus>
  </group>
  <group>
   <Status position="Left"><![CDATA[1]]></Status>
   <selectedIsState label="State" position="Right"><![CDATA[Closed]]></selectedIsState>
  </group>
  <group>
   <CustName label="Customer Name" position="Left"><![CDATA[AWB LTD.]]></CustName>
  </group>
  <group>
   <IssueTitle position="Left"><![CDATA[TPIPS & WIP FAULT REPORTS]]></IssueTitle>
   <MyManager label="This is my manager" size="10" position="Right"><![CDATA[]]></MyManager>
  </group>
  <group>
   <Escalate position="Left"><![CDATA[No]]></Escalate>
   <ReportIssue position="Right"><![CDATA[No]]></ReportIssue>
  </group>
  <group>
   <IssueClass label="Issue Class" control="checkbox" optionlist="issueclassoptions" position="Left"><![CDATA[Customer
Internal
Service Delivery
]]></IssueClass>
   <ProductName position="Right"><![CDATA[xxxxx Solution]]></ProductName>
  </group>
  <group>
   <State position="Left"><![CDATA[VIC]]></State>
   <IssueAssName position="Right"><![CDATA[xxxxxxxxx]]></IssueAssName>
  </group>
  <group>
   <ReqDate type="DATE"><![CDATA[20021101]]></ReqDate>
  </group>
  <group>
   <IssueAssMgr position="Left"><![CDATA[xxx Reid]]></IssueAssMgr>
   <IssueSubName position="Left"><![CDATA[xxxxxxx]]></IssueSubName>
  </group>
  <group>
   <ProjTitle label="Project Title" position="Left"><![CDATA[xxxxxxxxx]]></ProjTitle>
   <ICDelegationPath label="Delegation Path" position="Right"><![CDATA[]]></ICDelegationPath>
  </group>
  <group>
   <EscalationPath label="Escalation Path" position="Left"><![CDATA[]]></EscalationPath>
   <RODelegationPath control="multiline" rows="5" cols="30" noedit="yes" position="Right"><![CDATA[xxxxxxx
xxxxxxx
xxxxxxxx
]]></RODelegationPath>
  </group>
  <group>
   <IssueResHistory position="Left" control="multiline" rows="10" cols="50" popupname="HistoryZoom" title="Zoom" image="/icons/actn101.gif" onclick="isDocBeingSubmitted=true;alert('hello')"><![CDATA[Don Reid has investigated this issue and it looks as though this is a training issue for a particular individual.]]></IssueResHistory>
  </group>
 </issue>
 <issueclassoptions>
  <option id="Customer" checked="yes"><![CDATA[Customer]]></option>
  <option id="Internal" checked="yes"><![CDATA[Internal]]></option>
  <option id="Resource"><![CDATA[Resource]]></option>
  <option id="Project"><![CDATA[Project]]></option>
  <option id="System"><![CDATA[System]]></option>
  <option id="Product"><![CDATA[Product]]></option>
  <option id="Contract"><![CDATA[Contract]]></option>
  <option id="Process"><![CDATA[Process]]></option>
  <option id="Service Delivery" checked="yes"><![CDATA[Service Delivery]]></option>
 </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>
<xsl:param name="mode">insert</xsl:param>
<xsl:param name="script_time">0.1234</xsl:param>
<xsl:param name="formname">none</xsl:param>

<!-- 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='boolean'">
        <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='dropdown'">
        <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='radiogroup'">
        <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-of select="$item/@error"/></span>
  </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</xsl:attribute>
        </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</xsl:attribute>
        </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:attribute>
        <xsl:attribute name="rows"><xsl:value-of select="@rows"/></xsl:attribute>
        <xsl:attribute name="cols"><xsl:value-of select="@cols"/></xsl:attribute>

        <!-- 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:attribute>
        </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),'[',$position,']')"/>
            </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:attribute>
              </xsl:when>
              <xsl:when test="$item=node()">
                <!-- this option has been selected (variation for ENUM fields) -->
                <xsl:attribute name="SELECTED">SELECTED</xsl:attribute>
              </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),'[',position(),']')"/>
            </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:attribute>
          </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:attribute>
          </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/@optionlist]"/>
  <!-- alignment is 'vertical' or 'horizontal' (default is 'horizontal') -->
  <xsl:variable name="align" select="substring($item/@align,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($optionlist),'[',$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</xsl:attribute>
          </xsl:if>
         
          <xsl:if test="$item=node()">
            <!-- this option has been selected (variation for ENUM fields) -->
            <xsl:attribute name="CHECKED">CHECKED</xsl:attribute>
          </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($item/@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($optionlist),'[',$position,']')"/>
              </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</xsl:attribute>
          </xsl:if>
         
          <xsl:if test="$item=node()">
            <!-- this option has been selected (variation for ENUM fields) -->
            <xsl:attribute name="CHECKED">CHECKED</xsl:attribute>
          </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>