我有一个包含测试数据的加载一个XML。 我使用XSLT来呈现在浏览器中的HTML这个数据。 每个测试有包含Teststeps的表。 如果通过与否每次测试运行的表时更新表中的数据。 然后在浏览器重新加载页面。 我想它总是跳转到它是做什么工作的桌子上。 我怎样才能做到这一点? 我的XSLT文件:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<head>
<script type="text/javascript">
var testnum = 0;
if(document.cookie.indexOf('testnum=') !== -1) {
testnum = document.cookie.split('testnum=')[1].split(';')[0];
document.cookie = 'testnum=' + testnum + 1 + ';expires=Sat, 14 May 2015 18:00:00 GMT";';
} else {
document.cookie = 'testnum=1;expires=Sat, 14 May 2015 18:00:00 GMT";';
}
var w = $(window);
var row = $('#test').find('tr').eq( testnum );
if (row.length){
w.scrollTop( row.offset().top - (w.height()/2) );
}
</script>
<title>HMI Automotive Testing</title>
<link rel="stylesheet" type="text/css" href="report.css" />
</head>
<body>
<center>
<h1>HMI Automotive Testing</h1>
<br></br>
<div style="height:650px;width:824px;border:1px solid;overflow:auto;">
<table border="1" id ="test">
<xsl:for-each select= "TestSuite/TestCase">
<tr>
<b><xsl:value-of select="@name"/></b>
</tr>
<xsl:for-each select="Verification|Command">
<tr>
<xsl:choose>
<xsl:when test="contains(name() , 'Verification')">
<td>Verification <xsl:value-of select="@type"/></td>
<td><xsl:value-of select="@status"/></td>
</xsl:when>
<xsl:when test="contains(name() , 'Command')">
<td>Command <xsl:value-of select="@type"/></td>
<td><xsl:value-of select="@status"/></td>
</xsl:when>
</xsl:choose>
</tr>
</xsl:for-each>
</xsl:for-each>
</table>
</div>
</center>
</body>
</html>
</xsl:template>
</xsl:stylesheet>