开发者

How to display tables using xforms:repeat

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>
  <sty开发者_如何学Pythonle 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 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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜