[xsl] XSL-HTML Table problem

Subject: [xsl] XSL-HTML Table problem
From: "May, Eddie" <Eddie.May@xxxxxxxxxxxx>
Date: Wed, 6 Feb 2002 12:08:17 -0000
Hi,
I'm having a real problem with trying to get my xslt stylesheet to produce a
html table.
 I want the table to look something like the following:
 _________________________________________
 |radio-button description | radio-button description |
 |radio-button description | radio-button description |
 |_________________________________________|

So that each table row has the following:

<tr><td>radio-button</td><td>decsription</td><td>radio-button></td><td>descr
iption</td></tr>

The code in the stylesheet is as follows:

<CODE>
<xsl:template match="table-RdbDataOptions2" >
  <!-- PART ONE : Add the data options and user info -->
   <table width="100%" border="0" align="left">
    <xsl:for-each select="td">
     <tr>
      <td colspan="2">
      <xsl:choose>
        <xsl:when test="position()=1">
           <div align="left" class="subheading"><xsl:value-of select="."
/></div>
      </xsl:when>
     <xsl:when test="position()=2">
       <div align="left"><xsl:value-of select="." /></div>
    </xsl:when>
   </xsl:choose>
</td>
</tr>
</xsl:for-each>
<!-- PART TWO :  now build a 2x row/2x cell table-->
 <xsl:for-each select="rdb-DataOption">
  <xsl:choose>
   <xsl:when test="not(@recfav=' ')">
    <xsl:choose>
     <!-- when an uneven number, start a new table row. Add unevens to this
row -->
      <xsl:when test="position() mod 2=1">
        <tr>
         <xsl:choose>
          <xsl:when test="@dataseriescheck=''">
            <td> <input type="radio" name="rdbDataOptions" value="series"
disabled="disabled"/></td>
            <td><div align="left"><xsl:value-of select="." /></div></td>
          </xsl:when>
          <xsl:otherwise>
           <td> <input type="radio" name="rdbDataOptions" value="series"
disabled="disabled"  checked="checked"/></td>
           <td><div align="left"><xsl:value-of select="." /></div></td>
          </xsl:otherwise>
           <xsl:when test="@aggregatecheck=''">
             <td> <input type="radio" name="rdbDataOptions"
value="aggregate" disabled="disabled"/></td>
             <td><div align="left"><xsl:value-of select="." /></div></td>
           </xsl:when>
          <xsl:otherwise>
             <td><input type="radio" name="rdbDataOptions" value="series"
disabled="disabled" checked="checked"/></td>
             <td><div align="left"><xsl:value-of select="." /></div></td>
          </xsl:otherwise>
         </xsl:choose>
       </tr>    
      </xsl:when><!-- end of test position() mod 2 = 1 -->    
      <xsl:otherwise><!-- Add new row for even numbers --> 
        <tr>
        <xsl:choose>
         <xsl:when test="@cummulativecheck=''">
           <td> <input type="radio" name="rdbDataOption" value="cummulative"
disabled="disabled"/></td>
           <td><div align="left"><xsl:value-of select="." /></div></td>
         </xsl:when>
         <xsl:otherwise>
             <td><input type="radio" name="rdbDataOption"
value="cummulative" disabled="disabled" checked="checked"/></td>
             <td><div align="left"><xsl:value-of select="." /></div></td>
         </xsl:otherwise>
         <xsl:when test="@averagecheck=''">
            <td><input type="radio" name="rdbDataOption" value="Average"
disabled="disabled"/></td>
            <td><div align="left"><xsl:value-of select="." /></div></td>
         </xsl:when>
         <xsl:otherwise>
            <td><input type="radio" name="rdbDataOption" value="Average"
disabled="disabled" checked="checked"/></td>
            <td><div align="left"><xsl:value-of select="." /></div></td>
         </xsl:otherwise>
        </xsl:choose>
       </tr>
      </xsl:otherwise><!-- end of adding new row for even numbers --> 
      </xsl:choose>
     </xsl:when>
    </xsl:choose><!-- end of check for not recents -->
   <xsl:otherwise><!-- Recent -->
    <xsl:choose>
     <!-- when an uneven number, start a new table row. Add unevens to this
row -->
      <xsl:when test="position() mod 2=1">
       <tr>
        <xsl:choose>
         <xsl:when test="@dataseriescheck=''">
              <td><input type="radio" name="rdbDataOptions" value="series"
disabled="disabled"/></td>
              <td><div align="left"><xsl:value-of select="." /></div></td>
         </xsl:when>
         <xsl:otherwise>
             <td> <input type="radio" name="rdbDataOptions" value="series"
disabled="disabled"  checked="checked"/></td>
             <td><div align="left"><xsl:value-of select="." /></div></td>
         </xsl:otherwise>
         <xsl:when test="@aggregatecheck=''">
              <td><input type="radio" name="rdbDataOptions"
value="aggregate" disabled="disabled"/></td>
              <td><div align="left"><xsl:value-of select="." /></div></td>
         </xsl:when>
         <xsl:otherwise>
             <td><input type="radio" name="rdbDataOptions" value="series"
disabled="disabled" checked="checked"/></td>
             <td><div align="left"><xsl:value-of select="." /></div></td>
         </xsl:otherwise>
        </xsl:choose>
       </tr>     
      </xsl:when><!-- end of test position() mod 2 = 1 -->    
      <xsl:otherwise><!-- Add new row for even numbers --> 
       <tr>
        <xsl:choose>
         <xsl:when test="@cummulativecheck=''">
            <td><input type="radio" name="rdbDataOption" value="cummulative"
disabled="disabled"/></td>
            <td><div align="left"><xsl:value-of select="." /></div></td>
         </xsl:when>
         <xsl:otherwise>
             <td> <input type="radio" name="rdbDataOption"
value="cummulative" disabled="disabled" checked="checked"/></td>
             <td><div align="left"><xsl:value-of select="." /></div></td>
         </xsl:otherwise>
          <xsl:when test="@averagecheck=''">
            <td><input type="radio" name="rdbDataOption" value="Average"
disabled="disabled"/></td>
            <td><div align="left"><xsl:value-of select="." /></div></td>
          </xsl:when>
          <xsl:otherwise>
             <td><input type="radio" name="rdbDataOption" value="Average"
disabled="disabled" checked="checked"/></td>
             <td><div align="left"><xsl:value-of select="." /></div></td>
          </xsl:otherwise>
        </xsl:choose>
       </tr>
      </xsl:otherwise><!-- end of adding new row for even numbers --> 
     </xsl:choose>
    </xsl:otherwise>
   </xsl:for-each> 
  </table>
 </xsl:template>  
</CODE>

The jsp creates the table in the following way:
<CODE>

<table-RdbDataOptions2>

<td><%=Lang.get("DataOptions", User.getPrimary(), User.getFallback())%></td>

<td><%=Lang.get("SelectDataOption", User.getPrimary(),
User.getFallback())%></td>

<rdb-DataOption recfav="<%=strDisabled %>"
dataseriescheck="<%=strDataOption[0] %>" ><%=Lang.get("ShowDataSeries",
User.getPrimary(), User.getFallback())%></rdb-DataOption>

<rdb-DataOption recfav="<%=strDisabled %>"
cumulativecheck="<%=strDataOption[1] %>" ><%=Lang.get("ShowCumulative",
User.getPrimary(), User.getFallback())%></rdb-DataOption>

<rdb-DataOption recfav="<%=strDisabled %>"
aggregatecheck="<%=strDataOption[2] %>" ><%=Lang.get("ShowAggregate",
User.getPrimary(), User.getFallback())%></rdb-DataOption>

<rdb-DataOption recfav="<%=strDisabled %>" averagecheck="<%=strDataOption[3]
%>" ><%=Lang.get("ShowDataSeriesAverage", User.getPrimary(),
User.getFallback())%></rdb-DataOption>

</table-RdbDataOptions2>
</CODE>

The problem is that altho' the first part of the code works, the second part
is returning empty. It's basically failing on the 1st test  (  <xsl:when
test="not(@recfav=' ')">) but is not dropping into the <xsl:otherwise>
clause.
However, if I replace (<xsl:for-each select="rdb-DataOption">) with
(<xsl:for-each select=".">) I get all the stuff that I expect except that is
all crammed into one table row & one table cell.
 

I can easily produce a table with like this: 
 ____________________
 |radio-button description |
 |radio-button description |
 |radio-button description |
 |radio-button description |
 |___________________|


but unfortunately that's not what's req'd!

Any help in disciplining the above stylesheet so that it does what its told
would be greatly appreciated.

Yours, with respect!
Eddie.


Eddie May
Java Developer

> IMServ Europe Ltd.,
> St Anne's House,
> Caldecotte Lake Drive,
> Caldecotte Business Park,
> Caldecotte,
> MK7 8JU.
> 
Tel: 01908 335243
Fax: 01908 335385


IMServ Europe Ltd
Scorpio, Rockingham Drive, Linford Wood, Milton Keynes. MK14 6LY
Registered in England and Wales No. 2749624 
Registered Address: Invensys House, Carlisle Place, London SW1P 1BX
Tel: 01908 696000                Fax:  01908 692791

Disclaimer Notice
This message is private and confidential and should only be read by those to
whom it is addressed. If you are not the intended recipient, you should not
copy it or use if for any purpose, nor disclose its contents to any other
person, please also telephone IMServ Europe Limited ("IMServ") immediately,
delete the message from your computer and destroy any copies.
This message is not intended to be relied upon without subsequent written
confirmation of its contents. IMServ therefore cannot accept any liability
of any kind which may arise from any person acting upon the contents of the
message without having had written confirmation.
Although this email and any attachments is believed to be free of any virus,
or other defect which might affect any computer or IT system into which it
is received and opened, it is the responsibility of the recipient to ensure
that it is virus free and no responsibility is accepted by IMServ for any
loss or damage arising in any way from its use.





 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread