css - 如何使用 xforms 显示表格 :repeat

标签 css repeat css-tables xforms xsltforms

我想知道是否有人知道如何使用 XForms 以表格格式显示数据。我有一个将每个列标记显示为行的代码,但是我想知道如何将每个列标记显示为列。我希望我的输出显示如下:


1 1 2
2 3 4

我是 XForms 的初学者,对基础知识一无所知,所以如果有人能帮助我,那就太好了。

这是我的代码:

    <?xml version="1.0" encoding="UTF-8"?>
    <?xml-stylesheet href="xsltforms/xsltforms.xsl" type="text/xsl"?>
    <html xmlns="http://www.w3.org/1999/xhtml"
     xmlns:xf="http://www.w3.org/2002/xforms"
     xmlns:ev="http://www.w3.org/2001/xml-events">
     <head>
  <title>Table with CSS and Divs</title>
  <xf:model><xf:instance>
    <disp xmlns="">
       <row><col>1</col><col>2</col></row>
       <row><col>3</col><col>4</col></row>
    </disp>
  </xf:instance></xf:model>
  <style type="text/css">
    * {
  font-family: Arial, Helvetica, sans-serif;
  border-collapse: collapse;
  }
  /* example of doing layout of a table without using the HTML table tags */

  .table { 
  display:table;
   }

  .tableHeader, .tableRow, .tableFooter, .myRow  {
   display: table-row;
   }

  .leftHeaderCell, .leftCell, .leftFooterCell, 
  .rightHeaderCell, .rightCell, .rightFooterCell,
  .myCell
  {
   display:  table-cell;
   }    
 .myCell {
   padding: 5px 5px 5px 5px;
   border: solid black 2px
   }
  </style>
   </head>
   <body>
    <div class="table">

        <xf:repeat nodeset="row" id="idrow"> 
        <div class="myRow">  
            <div class="myCell"><xf:output ref="position()"/></div> 
                <xf:repeat nodeset="col" id="idcol">    
            <div class="myCell"><xf:output ref="."/></div>

             </xf:repeat>
        </div>
        </xf:repeat> 
    </div>
         </body>
       </html>

最佳答案

XSLTForms 将 XForms 元素替换为 HTML 元素(使用调试器检查一下)。添加 DIV 元素是嵌套重复的问题。

已针对 TABLE/TR/TD 结构修复此问题,因为它可以很容易地被 XSLTForms 检测到。具有 table-* CSS 属性的 DIV 元素不是同一种情况...

这是一个使用 XSLTForms 的例子:

    <body>
    <table>
        <xf:repeat nodeset="row" id="idrow"> 
            <tr>
                <td>
                    <xf:output value="position()"/>
                </td> 
                <td>
                    <table>
                        <tr>
                            <xf:repeat nodeset="col" id="idcol">    
                                <td>
                                    <xf:output ref="."/>
                                </td>
                            </xf:repeat>
                        </tr>
                    </table>
                </td>
            </tr>
        </xf:repeat> 
    </table>
</body>

-阿兰

关于css - 如何使用 xforms 显示表格 :repeat,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6628609/

相关文章:

html - 如何使用 HTML5 和 CSS3 制作动画?是否有免费的应用程序可以做到这一点?

javascript - jquery从div中的一组图像中获取图像元素ID

json - Redux 和 Calendar 重复事件

html - 卡住html表格中的顶部标题行

html - DIV 没有放在单元格的顶部

jquery - 垂直居中文本 (jQuery)

html - 如何使 "child"div 不会自行溢出并使用其父 div 的填充来呈现?

android - Android中重复动画时执行 Action

html - 图像没有正确重复

html - 显示 :table, 最大宽度、文本溢出、溢出在 IE8 中不起作用