Files
SyncHome/trunk/workspace/Fibex/LuSci/table.xsl
2023-03-13 08:36:51 +00:00

439 lines
17 KiB
XML

<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<head>
<title><xsl:value-of select="TESTRESULT/@title"/></title>
<link rel="shortcut icon" href="_styles/logo.ico" type="image/ico"> </link>
<style type="text/css">
table { border-collapse:collapse; width:100%}
th { border:2px solid #606060; vertical-align:top; overflow:visible; font-family:Arial; font-size:14px}
td { border:1px solid #606060; vertical-align:top; overflow:visible; font-family:Courier New; font-size:14px}
h1 { font-family:Arial; font-size:20px}
h2 { font-family:Arial; font-size:18px}
h3 { font-family:Arial; font-size:16px}
caption { font-family:Arial; font-size:18px; text-align:center}
c { font-family:Arial; font-size:18px; text-align:center}
p { font-family:Arial; font-size:16px; text-align:left}
a:link { text-decoration:none; font-weight:bold; color:#0000FF; }
a:visited { text-decoration:none; font-weight:bold; color:#800000; }
a:hover { text-decoration:none; font-weight:bold; background-color:#ffff00; }
a:active { text-decoration:none; font-weight:bold; background-color:#0c6000; }
a:focus { text-decoration:none; font-weight:bold; background-color:#10ff00; }
</style>
<script type="text/javascript">
<![CDATA[
/**
* Returns an element in the current HTML document.
*
* @param elementID Identifier of HTML element
* @return HTML element object
*/
function getElementObject(elementID) {
var elemObj = null;
if (document.getElementById) {
elemObj = document.getElementById(elementID);
}
return elemObj;
}
/**
* Closes a collapseable box.
*
* @param boxObj Collapseable box
* @param buttonObj Button controlling box
*/
function closeBox(boxObj) {
if (boxObj == null) {
// Box not found
} else {
// Change 'display' CSS property of box
boxObj.style.display="none";
}
}
/**
* Opens a collapseable box.
*
* @param boxObj Collapseable box
* @param buttonObj Button controlling box
*/
function openBox(boxObj) {
if (boxObj == null) {
// Box not found
} else {
// Change 'display' CSS property of box
boxObj.style.display="";
}
}
/**
* Sets the state of a collapseable box.
*
* @param boxID Identifier of box
* @param open If true, box is "opened",
* Otherwise, box is "closed".
*/
function setState(Table_ID, open) {
var Table_Obj = getElementObject(Table_ID);
if (Table_Obj == null) {
// Table not found
} else {
for (idx = 0; idx < Table_Obj.rows.length; idx++){
row_Obj = Table_Obj.rows[idx]
if (open) {
openBox(row_Obj);
openBox(Table_Obj.caption);
} else {
closeBox(boxObj);
closeBox(Table_Obj.caption);
}
}
}
}
/**
* Switches the state of a collapseable box, e.g.
* if it's opened, it'll be closed, and vice versa.
*
* @param boxID Identifier of box
*/
function switchState(Table_ID, option) {
var Table_Obj = getElementObject(Table_ID);
if (Table_Obj == null) {
// Table not found
} else {
for (idx = 0; idx < Table_Obj.rows.length; idx++){
row_Obj = Table_Obj.rows[idx]
if (row_Obj.style.display=="none") {
// Row is closed, so open it
openBox(row_Obj);
openBox(Table_Obj.caption);
} else if(row_Obj.style.display==""){
if (row_Obj.title.match(option) != null) {
closeBox(row_Obj);
closeBox(Table_Obj.caption);
}
}
}
}
}
/**
*
* remove not displayed rows from table
*
*
*/
function remove_hidden_row(Table_ID) {
var Table_Obj = getElementObject(Table_ID);
if (Table_Obj == null) {
// Table not found
} else if (Table_Obj.caption != null) {
if (Table_Obj.caption.style.display=="none"){
Table_Obj.deleteCaption();
}
for (idx = 0; idx < Table_Obj.rows.length; idx++){
row_Obj = Table_Obj.rows[idx]
if (row_Obj.style.display=="none") {
// Row is closed, so delete it
Table_Obj.deleteRow(idx);
idx--;
}
}
}
}
/**
* Closes all boxes in a given list.
*
* @param boxList Array of box IDs
*/
function switchStateAll(option) {
Tables=document.getElementsByTagName("table");
for (i1 = 0; i1 < Tables.length; i1++){
if (Tables[i1].id != ""){
switchState(Tables[i1].id, option);
}
}
}
/**
* Select Text.
*
*/
function selectText() {
if (window.getSelection){
alert(window.getSelection());
} else if (document.getSelection){
alert (document.getSelection());
} else if (document.selection){
alert(document.selection.createRange().text);
}
}
]]>
</script>
</head>
<body>
<p>
PASSED:
<xsl:value-of select="round(count(//RTABLE/R/C[.='PASSED']) div (count(//RTABLE/R/C[.='PASSED'])+count(//RTABLE/R/C[.='FAILED']))*1000) div 10"/> % ...
<xsl:value-of select="count(//RTABLE/R/C[.='PASSED'])"/>
</p>
<p>
FAILED:
<xsl:value-of select="round(count(//RTABLE/R/C[.='FAILED']) div (count(//RTABLE/R/C[.='PASSED'])+count(//RTABLE/R/C[.='FAILED']))*1000) div 10"/> % ...
<xsl:value-of select="count(//RTABLE/R/C[.='FAILED'])"/>
</p>
<xsl:if test="//TESTRESULT/@execution_time">
<p>
all execution time: <xsl:value-of select="round(sum(//TESTRESULT/@execution_time) div 60 div 60 *100) div 100"/> h
</p>
</xsl:if>
<p style="color:#0000FF">
<xsl:attribute name="onclick">switchStateAll('verdict:(?=true)|verdict:(?=none)'); return false;</xsl:attribute>
[Hide/Show verdict:(?=true)|verdict:(?=none)]
</p>
<p style="color:#0000FF">
<xsl:attribute name="onclick">switchStateAll('Command:(?!Eval_FailureData)'); return false;</xsl:attribute>
[Hide/Show: Command:(?!Eval_FailureData)]
</p>
<xsl:apply-templates />
</body>
</html>
</xsl:template>
<xsl:template match="TESTRESULT">
<h1>
<xsl:value-of select="@title" />
</h1>
<xsl:if test="@execution_time">
<p>
execution time: <xsl:value-of select="round((@execution_time) div 60 *100) div 100"/> min
</p>
</xsl:if>
<xsl:apply-templates />
</xsl:template>
<!-- Type is RTABLE /-->
<xsl:template match="RTABLE">
<!-- 1. Infotable, used as eventbutton /-->
<p>
</p>
<table bgcolor="white">
<tr style="color:#0000FF">
<td style="border:0px" width="25%">
<xsl:attribute name="onclick">switchState('<xsl:number level="multiple" count="TESTRESULT|RTABLE" format="1.1"/>', 'verdict:(?=true)|verdict:(?=none)'); return false;</xsl:attribute>
[Hide/Show:<br/> verdict:(?=true)|verdict:(?=none)]
</td>
<td style="border:0px" width="25%">
<xsl:attribute name="onclick">switchState('<xsl:number level="multiple" count="TESTRESULT|RTABLE" format="1.1"/>', 'verdict:(?=true)'); return false;</xsl:attribute>
[Hide/Show:<br/> verdict:(?=true)]
</td>
<td style="border:0px" width="25%">
<xsl:attribute name="onclick">setState('<xsl:number level="multiple" count="TESTRESULT|RTABLE" format="1.1"/>', 1); return false;</xsl:attribute>
[Show all]
</td>
<td style="border:0px" width="25%">
<xsl:attribute name="onclick">remove_hidden_row('<xsl:number level="multiple" count="TESTRESULT|RTABLE" format="1.1"/>'); return false;</xsl:attribute>
[Remove Hidden]
</td>
</tr>
</table>
<table bgcolor="white">
<tr>
<td style="border:0px; font-weight:bold"><xsl:value-of select="ancestor::TESTRESULT/@title"/></td>
<td style="border:0px; font-weight:bold"><xsl:value-of select="preceding::RTEXT[1]"/></td>
<td style="border:0px; font-weight:bold"><xsl:value-of select="@caption"/></td>
</tr>
</table>
<!-- 2. Testresult-Table /-->
<table cellpadding="3" bgcolor="white">
<xsl:attribute name="id"><xsl:number level="multiple" count="TESTRESULT|RTABLE" format="1.1"/></xsl:attribute>
<caption>
<xsl:value-of select="@caption"/>
</caption>
<xsl:apply-templates />
</table>
<p><br/></p>
</xsl:template>
<!-- Table Header /-->
<xsl:template match="HEADER">
<tr bgcolor="#ffd700" title="verdict:none; verdict:true; Command:none">
<xsl:for-each select="C">
<xsl:if test=".!='' or count(following-sibling::*)!=count(following-sibling::*[.=''])">
<th>
<xsl:attribute name="width"><xsl:value-of select="@width"/></xsl:attribute>
<xsl:if test="count(following-sibling::*)&gt;0 and count(following-sibling::*)=count(following-sibling::*[.=''])">
<xsl:attribute name="colspan"><xsl:value-of select="count(following-sibling::*)+1"/></xsl:attribute>
</xsl:if>
<xsl:value-of select="."/>
</th>
</xsl:if>
</xsl:for-each>
</tr>
</xsl:template>
<!-- ROWS and COLUMNS of Tables /-->
<xsl:template match="R">
<tr style="">
<xsl:attribute name="title">verdict:none; <xsl:value-of select="@title"/></xsl:attribute>
<xsl:if test="count(./C[.='FAILED']) &gt; 0">
<xsl:attribute name="bgcolor">#ffc0c0</xsl:attribute>
<xsl:attribute name="title">verdict:false; <xsl:value-of select="@title"/></xsl:attribute>
</xsl:if>
<xsl:if test="count(./C[.='PASSED']) &gt; 0">
<xsl:attribute name="bgcolor">#dfffdf</xsl:attribute>
<xsl:attribute name="title">verdict:true; <xsl:value-of select="@title"/></xsl:attribute>
</xsl:if>
<xsl:for-each select="C">
<xsl:if test=".!='' or count(following-sibling::*)!=count(following-sibling::*[.=''])">
<td>
<xsl:if test="count(following-sibling::*)&gt;0 and count(following-sibling::*)=count(following-sibling::*[.=''])">
<xsl:attribute name="colspan"><xsl:value-of select="count(following-sibling::*)+1"/></xsl:attribute>
</xsl:if>
<xsl:choose>
<xsl:when test=".='FAILED'">
<xsl:attribute name="bgcolor">red</xsl:attribute>
</xsl:when>
<xsl:when test=".='PASSED'">
<xsl:attribute name="bgcolor">green</xsl:attribute>
</xsl:when>
</xsl:choose>
<xsl:if test="@href!=''">
<a target="_blank">
<xsl:attribute name="href"><xsl:value-of select="@href"/></xsl:attribute>
<xsl:call-template name="replace">
<xsl:with-param name="string" select="."/>
</xsl:call-template>
</a>
</xsl:if>
<xsl:if test="not(@href!='')">
<xsl:call-template name="replace">
<xsl:with-param name="string" select="."/>
</xsl:call-template>
</xsl:if>
</td>
</xsl:if>
</xsl:for-each>
</tr>
</xsl:template>
<!-- Type is RTEXT /-->
<xsl:template match="RTEXT">
<xsl:choose>
<xsl:when test="@style='HEADING1'">
<h1>
<a>
<xsl:attribute name="name"><xsl:value-of select="@TreeID" /></xsl:attribute>
<xsl:attribute name="id"><xsl:value-of select="@TreeID" /></xsl:attribute>
</a>
<xsl:value-of select="." />
</h1>
</xsl:when>
<xsl:when test="@style='HEADING2'">
<h2>
<a>
<xsl:attribute name="name"><xsl:value-of select="@TreeID" /></xsl:attribute>
<xsl:attribute name="id"><xsl:value-of select="@TreeID" /></xsl:attribute>
</a>
<xsl:value-of select="." />
</h2>
</xsl:when>
<xsl:when test="@style='HEADING3'">
<h3>
<a>
<xsl:attribute name="name"><xsl:value-of select="@TreeID" /></xsl:attribute>
<xsl:attribute name="id"><xsl:value-of select="@TreeID" /></xsl:attribute>
</a>
<xsl:value-of select="." />
</h3>
</xsl:when>
<xsl:when test="@style='NORMAL'">
<p>
<xsl:value-of select="." />
</p>
</xsl:when>
<xsl:when test="@style='HREF'">
<a target="_self">
<xsl:attribute name="href"><xsl:value-of select="@document"/>#<xsl:value-of select="@TreeID" /></xsl:attribute>
<xsl:value-of select="."/>
</a>
</xsl:when>
<xsl:otherwise>
<p>
<xsl:value-of select="." />
</p>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- Type is RPLOT /-->
<xsl:template match="RPLOT">
<table border="0" width="100%">
<xsl:attribute name="id">RPLOT_<xsl:number level="multiple" count="TESTRESULT|RPLOT" format="1.1"/></xsl:attribute>
<tr style="">
<th align="left" border="0">
<font color="" ><xsl:value-of select="@caption"/></font>
</th>
</tr>
<tr style="" title="verdict:none; verdict:true; Command:none">
<td align="left" border="0">
<a target="_blank">
<xsl:attribute name="href"><xsl:value-of select="."/><xsl:value-of select="@type"/></xsl:attribute>
<img border="0" width="900" height="600" alt="Speed&amp;Acceleration">
<xsl:attribute name="src"><xsl:value-of select="."/><xsl:value-of select="@type"/></xsl:attribute>
</img>
</a>
</td>
</tr>
<tr style="">
<td align="left" border="0">
<a target="_blank">
<xsl:attribute name="href"><xsl:value-of select="."/><xsl:value-of select="@data"/></xsl:attribute>
Plotdata:
<xsl:value-of select="."/><xsl:value-of select="@data"/>
</a>
</td>
</tr>
<p></p>
</table>
</xsl:template>
<!-- functional templates/-->
<!-- functional templates/-->
<xsl:template name="replace">
<xsl:param name="string"/>
<xsl:choose>
<xsl:when test="contains($string,'&#10;')">
<xsl:value-of select="substring-before($string,'&#10;')"/>
<br/>
<xsl:call-template name="replace">
<xsl:with-param name="string" select="substring-after($string,'&#10;')"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$string"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>