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要素の追加は、ネストされた繰り返しの問題です。

これは、XSLTFormsで簡単に検出できるため、TABLE / TR/TD構造で修正されました。テーブルを持つDIV要素-*CSSプロパティは同じ状況ではありません...

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 に答える