[英]CSS not working properly in XSLT
我使用以下代码使用XSLT将XML文件显示为HTML
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="Report/Scripts">
<html>
<head>
<title>Mobiuss.rtp Test Execution Results</title>
<link rel="stylesheet" href="xmlstyle.css" />
</head>
<body>
<xsl:for-each select="Script">
<h1><xsl:value-of select="@File"/></h1>
Execution log
<br>
</br>
<table class="sortable">
<tr>
<th>Time</th>
<th>Position</th>
<th>Type</th>
<th>Message</th>
</tr>
<xsl:for-each select="Message">
<tr>
<td> <xsl:value-of select="@Time"/></td>
<td>Line <xsl:value-of select="@Line"/></td>
<td> <xsl:value-of select="@Type"/></td>
<td> <xsl:value-of select="@Message"/></td>
</tr>
</xsl:for-each>
</table>
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
上面的代码将XML文件显示为html,它创建了约4个表(取决于XML),但是由于某种原因,我不知道第一个表是跟随CSS的所有其他表都没有样式。
CSS代码在这里:
@CHARSET "ISO-8859-1";
.sortable {width:100%; height:40px; border:1px solid #ccc; background-color:#EEE0E5}
.sortable th {padding:4px 6px 6px; background:#444; color:#fff; text-align:center; color:#ccc}
.sortable td {padding:2px 4px 4px; background:#fff; border-bottom:1px solid #ccc; overflow:auto}
.sortable .head {background:#444 url(images/sort.gif) 6px center no-repeat; cursor:pointer; padding-left:18px}
.sortable .desc {background:#222 url(images/desc.gif) 6px center no-repeat; cursor:pointer; padding-left:18px}
.sortable .asc {background:#222 url(images/asc.gif) 6px center no-repeat; cursor:pointer; padding-left:18px}
.sortable .head:hover, .sortable .desc:hover, .sortable .asc:hover {color:#fff}
.sortable .even td {background:#f2f2f2}
.sortable .odd td {background:#fff}
请指导我在代码中进行哪些更改,以便正确创建所有表的样式。
因此,这是一个简单的测试: http : //jsbin.com/azaqog/1/似乎工作正常。 您所面临的问题在提供的数据中并不明显。
我现在可以怀疑的一件事是,您从XML解析的数据包含导致最终HTML无效的内容。 我建议您将XML + XSLT解析为原始文本文件,然后查看输出。 您应该在那里看到破坏HTML的内容。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.