【发布时间】:2019-12-10 12:29:58
【问题描述】:
以下数据来自数据库,
姓名指定工资离职
Vignesh SE 50000 技术
vivah SSE 100000 技术指标
这我必须使用 xslt 填充到 html 表中,如下表形式。在这里我应该也可以读取列名。
名字 vignesh vivah
名称 SE SSE
工资50000 100000
离开技术技术
通过查看一些参考资料,我尝试了这样的做法,
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:template match="/">
<html>
<head>
<title/>
<style type="text/css">
table.ma-temp-data-table {
margin:5px;
}
.ma-temp-data-table tr:nth-of-type(odd) {
background-color:#eee;
}
.ma-temp-data-table tr:nth-of-type(even) {
background-color:#ddd;
}
.ma-temp-data-table th {
background-color:#ccc;
}
.ma-temp-data-table td {
padding: 2px;
}
.ma-temp-data-table th {
padding: 4px;
font-weight: bold;
}
</style>
</head>
<body>
<table class="ma-temp-data-table">
<xsl:variable name="rowdata" select="root/row"/>
<xsl:for-each select="$rowdata">
<tr>
<xsl:for-each select="$rowdata">
<xsl:variable name="pos" select="position()"/>
<td style="font-weight:bold"><xsl:value-of select="$rowdata[$pos]"/></td>
</xsl:for-each>
</tr>
</table>
</body>
</html>
</xsl:template>
表格是这样填充的,
VigneshSE50000技术 vivahSSE100000技术
这里的问题是列空间没有出现。 我是 XSLT 的新手,谁能帮忙实现一下。
【问题讨论】: