如何使用 xforms:repeat 显示表格

发布于 2024-11-19 12:56:52 字数 1906 浏览 3 评论 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>

I was wondering if anyone knew how to display data using XForms in a table format. I have a code that displays each column tag as rows however, I was wondering how I can display each column tag as columns. I'd like my output to display like this:

1 1 2

2 3 4

I am a beginner at XForms and have no idea about the basics so if anyone could help me out, that would be great.

Here is my code:

    <?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>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

楠木可依 2024-11-26 12:56:53

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>

-Alain

XSLTForms substitutes XForms elements into HTML elements (have a look with a debugger to check this). Adding DIV elements is a problem with nested repeats.

This has been fixed for the TABLE/TR/TD structure because it can easily be detected by XSLTForms. DIV elements with table-* CSS properties are not in the same situation...

Here is an example working with 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>

-Alain

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文