[英]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.