如何使用 xforms:repeat 显示表格
我想知道是否有人知道如何使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
XSLTForms 将 XForms 元素替换为 HTML 元素(使用调试器查看以检查这一点)。添加 DIV 元素是嵌套重复的一个问题。
这个问题已针对 TABLE/TR/TD 结构进行了修复,因为它可以很容易地被 XSLTForms 检测到。具有 table-* CSS 属性的 DIV 元素的情况不同...
以下是使用 XSLTForms 的示例:
-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:
-Alain