0

我想知道是否有人知道如何使用 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>
4

1 回答 1

0

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>

-阿兰

于 2011-07-09T13:57:16.337 回答