以文本方式查看主题

-  计算机科学论坛  (http://bbs.xml.org.cn/index.asp)
--  『 XSL/XSLT/XSL-FO/CSS 』  (http://bbs.xml.org.cn/list.asp?boardid=8)
----  [求助]用xsl定义一个2行2列的table...  (http://bbs.xml.org.cn/dispbbs.asp?boardid=8&rootid=&id=58355)


--  作者:82331235
--  发布时间:1/22/2008 4:57:00 PM

--  [求助]用xsl定义一个2行2列的table...
现在有个xml文件,如下:

//workflow.xml
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type='text/xsl' href='workflow.xsl'?>
<basetable>
<row id="row1">
<cell>111</cell>
<cell>222</cell>
<cell>333</cell>
</row>

<row id="row2">
<cell>111</cell>
<cell>222</cell>
<cell>333</cell>
</row>
</basetable>

我需要把以上xml文件每个row中的前两个cell拼在一个2行2列的table中,请问应该怎样定义?我现在要么将它定义为1行4列,要么定义为4行1列,郁闷啊!急!
如这样的格式:
<table>
<tr>
<td rowspan="2">
    <table>
    <tr><td></td><td></td></tr>
    <tr><td></td><td></td></tr>
    </table>
</td>
<td></td>
</tr>

<tr>
<td></td>
</tr>
</table>


--  作者:孤独
--  发布时间:1/24/2008 9:51:00 PM

--  
http://www.joysou.com/template/Main/all.xsl
这个是我N年前写的系统的一个xsl文件
你看搜一下visitors
<xsl:template match="Visitors">
  <xsl:if test="@show = 'true'">
   <table width="776" border="0" align="center" cellpadding="0" cellspacing="0" class="TableOuTWithTop">
    <tbody>
     <tr>
      <td style="BORDER-RIGHT: #d8d8d8 1px solid" valign="top">总在线人数:<xsl:value-of select="number(UserOnline) + number(VisitorOnline)"/></td>
     </tr>
     <tr>
      <td style="BORDER-RIGHT: #d8d8d8 1px solid" valign="top">
       <table align="center" width="100%" border="0" cellpadding="0" cellspacing="0">
        <tr height="1">
         <td align="center">
         名单图例:
         <img src="../Images/Main/Group/Master.gif"/> 管理员 ‖
         
         <img src="../Images/Main/Group/superadmin.gif"/> 超级版主 ‖
         
         <img src="../Images/Main/Group/admin.gif"/> 版主 ‖
         
         <img src="../Images/Main/Group/vip.gif"/> 贵宾 ‖
         
         <img src="../Images/Main/Group/user.gif"/> 注册用户 ‖
         
         <img src="../Images/Main/Group/visitor.gif"/> 未注册/未登录用户
        </td>
        </tr>
       </table>
      </td>
     </tr>
     <tr>
      <td style="BORDER-RIGHT: #d8d8d8 1px solid" valign="top">
       <table align="center" width="80%" border="0" cellpadding="0" cellspacing="0">
        <tr height="1">
         <td width="20%"/>
         <td width="20%"/>
         <td width="20%"/>
         <td width="20%"/>
         <td width="20%"/>
        </tr>
        <xsl:variable name="total" select="count(Visitor)"/>
        <xsl:for-each select="Visitor[position() &lt; ($total - ($total mod 5))+1]">
         <xsl:if test="(position() mod 5)= 1">
          <xsl:text disable-output-escaping="yes">&lt;tr&gt;</xsl:text>
         </xsl:if>
         <td class="bg_2">
          <xsl:apply-templates select="."/>
         </td>
         <xsl:if test="(position() mod 5)= 0">
          <xsl:text disable-output-escaping="yes">&lt;/tr&gt;</xsl:text>
         </xsl:if>
        </xsl:for-each>
        <tr>
         <xsl:for-each select="Visitor[position() &gt; ($total - ($total mod 5))]">
          <td class="bg_2">
           <xsl:apply-templates select="."/>
          </td>
         </xsl:for-each>
         <td colspan="{5-($total mod 5)}" class="bg_2">
          <xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>
         </td>
        </tr>
       </table>
      </td>
     </tr>
    </tbody>
   </table>
  </xsl:if>
 </xsl:template>
看看循环就明白了:)
--  作者:孤独
--  发布时间:1/24/2008 9:52:00 PM

--  
附:http://www.joysou.com/system/main.asp?show=xml
xml文件
W 3 C h i n a ( since 2003 ) 旗 下 站 点
苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
46.875ms