[libvirt] [test-API PATCH] log_output: Fix whitespace in log output XSL

The XSL file that converts the log xml into a html file contains some strange whitespace characters that output in the HTML as squares. This patch fixes the whitespace and reformats the indetation to two spaces as used in libvirt XML files. *log.css: -make test name field wider *log.xsl: -fix whitespace and indentation -remove '@' from test headers --- log.css | 2 +- log.xsl | 341 +++++++++++++++++++++++++++++++-------------------------------- 2 files changed, 170 insertions(+), 173 deletions(-) diff --git a/log.css b/log.css index d5fe3e6..84f3ea6 100644 --- a/log.css +++ b/log.css @@ -75,7 +75,7 @@ table td{ } .li-tit{ - width:150px; + width:250px; } .statu-list{ diff --git a/log.xsl b/log.xsl index 4ebf030..84ad5fa 100644 --- a/log.xsl +++ b/log.xsl @@ -1,179 +1,176 @@ <?xml version='1.0'?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> -<xsl:output method="html" indent="yes" /> +<xsl:output method="html" indent="yes" /> <xsl:template match="/"> <html> - <head> - <title>Libvirt testing log</title> - <link rel="stylesheet" href="log.css" type="text/css" media="screen" /> - <script language="javascript"> - <![CDATA[ - var xmlDOc; - var xslDoc; - var active_result; - var active_div_id; - - - function init(logname) { - var xmlDoc; - var xslDoc; - - active_result = "TOTAL"; - expand_last_div(); - } - - function expand_last_div() { - divs = document.getElementsByTagName('div'); - last_div = divs[divs.length - 1]; - last_div.style.display = "block"; - active_div_id = last_div.attributes['id'].value; - } - - function on_result_clicked(div_id, result){ - if (result == active_result && active_div_id == div_id) - return; - - active_result = result; - active_div_id = div_id; - - var table = document.getElementById(div_id + "tb"); - var trs = table.childNodes[1].childNodes; - - if (result == "TOTAL") { - for (var i = 0; i < trs.length; i++) { - trs[i].style.display = "table-row"; - } - - return; - } - - for (var i = 0; i < trs.length; i++) { - var cels = trs[i].childNodes; - var is_result = false; - - for (var j = 0; j < cels.length; j++) { - - if(cels[j].innerHTML == result) { - is_result = true; - trs[i].style.display = "table-row"; - break; - } - } - - if (!is_result) { - trs[i].style.display = "none"; - } - } - } - - function fold_unfold(id) { - div = document.getElementById(id); - - if (div.style.display == "block") { - div.style.display = "none"; - } else { - div.style.display = "block"; - } - - /* fold all other divs */ - /* - divs = document.getElementsByTagName('div'); - for (var i = 0; i < divs.length; i++) { - if (divs[i].attributes['id'].value == id) { - continue; - } else { - divs[i].style.display = "none"; - } - } - */ - } - ]]> - </script> - </head> - <body onload="init()"> - <!--<H1>Libvirt testing report</H1>--> - <center><img src="icon.png" alt=""/></center> - <xsl:for-each select="log/testrun"> - <xsl:variable name="div_id" select="@name"/> - <h2><b><a href="#{$div_id}" onclick="fold_unfold({$div_id})">Testrun@<xsl:value-of select="@name"/></a></b></h2> - <DIV id="{$div_id}" style="display: none;"> - <table border="0" class="statu-list" cellspan="0" cellspacing="0"> - <tr> - <th><a href="#{$div_id}" onclick="on_result_clicked({$div_id}, 'TOTAL')">Total</a></th> - <th><a href="#{$div_id}" onclick="on_result_clicked({$div_id}, 'PASS')">PASS</a></th> - <th><a href="#{$div_id}" onclick="on_result_clicked({$div_id}, 'FAIL')">FAIL</a></th> - <!--<th><a href="#{$div_id}" onclick="on_result_clicked({$div_id}, 'SKIP')">SKIP</a></th>--> - <th>Start</th> - <th>End</th> - </tr> - <tr> - <td><xsl:value-of select="total"/></td> - <td><xsl:value-of select="pass"/></td> - <td><xsl:value-of select="fail"/></td> - <!--<td><xsl:value-of select="skip"/></td>--> - <td><xsl:value-of select="start_time"/></td> - <td><xsl:value-of select="end_time"/></td> - </tr> - </table> - - <table id="{$div_id}tb" class="list" cellspan="0" cellspacing="0"> - <thead> - <tr> - <th width="5%">No.</th> - <th width="5%">Result</th> - <th width="12%">Start</th> - <th width="12%">End</th> - <th width="66%">Test Procedure</th> - </tr> - </thead> - - <tbody> - <xsl:for-each select="test"> - <tr> - <td> - <xsl:variable name="link" select="path"/> - <a href="{$link}"><xsl:value-of select="@id"/> </a> - </td> - <xsl:choose> - <xsl:when test="result = 'PASS'"> - <td class="pass"><xsl:value-of select="result"/></td> - </xsl:when> - <xsl:when test="result = 'FAIL'"> - <td class="fail"><xsl:value-of select="result"/></td> - </xsl:when> - <xsl:otherwise> - <td></td> - </xsl:otherwise> - </xsl:choose> - <td><xsl:value-of select="start_time"/></td> - <td><xsl:value-of select="end_time"/></td> - <td> - <table class="pro" cellspacing="1" cellspan="0" > - <xsl:for-each select="test_procedure"> - <tr> - <td class="li-tit"> - <xsl:value-of select="action/@name"/><br/> - </td> - <td> - <xsl:for-each select="action/arg"> - <span> - <xsl:value-of select="@name"/> - <xsl:text>=</xsl:text> - <xsl:value-of select="."/> - </span> - </xsl:for-each> - </td> - </tr> - </xsl:for-each> - </table> - </td> - </tr> - </xsl:for-each> - </tbody> - </table> - </DIV> - </xsl:for-each> - </body> + <head> + <title>Libvirt testing log</title> + <link rel="stylesheet" href="log.css" type="text/css" media="screen" /> + <script language="javascript"> + <![CDATA[ + var xmlDOc; + var xslDoc; + var active_result; + var active_div_id; + + function init(logname) { + var xmlDoc; + var xslDoc; + + active_result = "TOTAL"; + expand_last_div(); + } + + function expand_last_div() { + divs = document.getElementsByTagName('div'); + last_div = divs[divs.length - 1]; + last_div.style.display = "block"; + active_div_id = last_div.attributes['id'].value; + } + + function on_result_clicked(div_id, result){ + if (result== active_result && active_div_id == div_id) + return; + + active_result = result; + active_div_id = div_id; + + var table = document.getElementById(div_id + "tb"); + var trs = table.childNodes[1].childNodes; + + if (result == "TOTAL") { + for (var i = 0; i < trs.length; i++) { + trs[i].style.display = "table-row"; + } + + return; + } + + for (var i = 0; i < trs.length; i++) { + var cels = trs[i].childNodes; + var is_result = false; + + for (var j = 0; j < cels.length; j++) { + if(cels[j].innerHTML == result) { + is_result = true; + trs[i].style.display = "table-row"; + break; + } + } + + if (!is_result) { + trs[i].style.display = "none"; + } + } + } + + function fold_unfold(id) { + div = document.getElementById(id); + + if (div.style.display == "block") { + div.style.display = "none"; + } else { + div.style.display = "block"; + } + + /* fold all other divs */ + /* + divs = document.getElementsByTagName('div'); + for (var i = 0; i < divs.length; i++) { + if (divs[i].attributes['id'].value == id) { + continue; + } else { + divs[i].style.display = "none"; + } + } + */ + } + ]]> + </script> + </head> + <body onload="init()"> + <!--<H1>Libvirt testing report</H1>--> + <center><img src="icon.png" alt=""/></center> + <xsl:for-each select="log/testrun"> + <xsl:variable name="div_id" select="@name"/> + <h2><b><a href="#{$div_id}" onclick="fold_unfold({$div_id})">Testrun <xsl:value-of select="@name"/></a></b></h2> + <DIV id="{$div_id}" style="display: none;"> + <table border="0" class="statu-list" cellspan="0" cellspacing="0"> + <tr> + <th><a href="#{$div_id}" onclick="on_result_clicked({$div_id}, 'TOTAL')">Total</a></th> + <th><a href="#{$div_id}" onclick="on_result_clicked({$div_id}, 'PASS')">PASS</a></th> + <th><a href="#{$div_id}" onclick="on_result_clicked({$div_id}, 'FAIL')">FAIL</a></th> + <!--<th><a href="#{$div_id}" onclick="on_result_clicked({$div_id}, 'SKIP')">SKIP</a></th>--> + <th>Start</th> + <th>End</th> + </tr> + <tr> + <td><xsl:value-of select="total"/></td> + <td><xsl:value-of select="pass"/></td> + <td><xsl:value-of select="fail"/></td> + <!--<td><xsl:value-of select="skip"/></td>--> + <td><xsl:value-of select="start_time"/></td> + <td><xsl:value-of select="end_time"/></td> + </tr> + </table> + + <table id="{$div_id}tb" class="list" cellspan="0" cellspacing="0"> + <thead> + <tr> + <th width="5%">No.</th> + <th width="5%">Result</th> + <th width="12%">Start</th> + <th width="12%">End</th> + <th width="66%">Test Procedure</th> + </tr> + </thead> + <tbody> + <xsl:for-each select="test"> + <tr> + <td> + <xsl:variable name="link" select="path"/> + <a href="{$link}"><xsl:value-of select="@id"/> </a> + </td> + <xsl:choose> + <xsl:when test="result = 'PASS'"> + <td class="pass"><xsl:value-of select="result"/></td> + </xsl:when> + <xsl:when test="result = 'FAIL'"> + <td class="fail"><xsl:value-of select="result"/></td> + </xsl:when> + <xsl:otherwise> + <td></td> + </xsl:otherwise> + </xsl:choose> + <td><xsl:value-of select="start_time"/></td> + <td><xsl:value-of select="end_time"/></td> + <td> + <table class="pro" cellspacing="1" cellspan="0" > + <xsl:for-each select="test_procedure"> + <tr> + <td class="li-tit"> + <xsl:value-of select="action/@name"/> + </td> + <td> + <xsl:for-each select="action/arg"> + <span> + <xsl:value-of select="@name"/> + <xsl:text>=</xsl:text> + <xsl:value-of select="."/> + </span> + </xsl:for-each> + </td> + </tr> + </xsl:for-each> + </table> + </td> + </tr> + </xsl:for-each> + </tbody> + </table> + </DIV> + </xsl:for-each> + </body> </html> </xsl:template> </xsl:stylesheet> -- 1.7.3.4

On 03/29/2012 02:04 PM, Peter Krempa wrote:
The XSL file that converts the log xml into a html file contains some strange whitespace characters that output in the HTML as squares.
This patch fixes the whitespace and reformats the indetation to two spaces as used in libvirt XML files.
*log.css: -make test name field wider *log.xsl: -fix whitespace and indentation -remove '@' from test headers --- log.css | 2 +- log.xsl | 341 +++++++++++++++++++++++++++++++-------------------------------- 2 files changed, 170 insertions(+), 173 deletions(-)
diff --git a/log.css b/log.css index d5fe3e6..84f3ea6 100644 --- a/log.css +++ b/log.css @@ -75,7 +75,7 @@ table td{ }
.li-tit{ - width:150px; + width:250px; }
.statu-list{ diff --git a/log.xsl b/log.xsl index 4ebf030..84ad5fa 100644 --- a/log.xsl +++ b/log.xsl @@ -1,179 +1,176 @@ <?xml version='1.0'?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> -<xsl:output method="html" indent="yes" /> +<xsl:output method="html" indent="yes" /> <xsl:template match="/"> <html> - <head> - <title>Libvirt testing log</title> - <link rel="stylesheet" href="log.css" type="text/css" media="screen" /> - <script language="javascript"> - <![CDATA[ - var xmlDOc; - var xslDoc; - var active_result; - var active_div_id; - - - function init(logname) { - var xmlDoc; - var xslDoc; - - active_result = "TOTAL"; - expand_last_div(); - } - - function expand_last_div() { - divs = document.getElementsByTagName('div'); - last_div = divs[divs.length - 1]; - last_div.style.display = "block"; - active_div_id = last_div.attributes['id'].value; - } - - function on_result_clicked(div_id, result){ - if (result == active_result && active_div_id == div_id) - return; - - active_result = result; - active_div_id = div_id; - - var table = document.getElementById(div_id + "tb"); - var trs = table.childNodes[1].childNodes; - - if (result == "TOTAL") { - for (var i = 0; i < trs.length; i++) { - trs[i].style.display = "table-row"; - } - - return; - } - - for (var i = 0; i < trs.length; i++) { - var cels = trs[i].childNodes; - var is_result = false; - - for (var j = 0; j < cels.length; j++) { - - if(cels[j].innerHTML == result) { - is_result = true; - trs[i].style.display = "table-row"; - break; - } - } - - if (!is_result) { - trs[i].style.display = "none"; - } - } - } - - function fold_unfold(id) { - div = document.getElementById(id); - - if (div.style.display == "block") { - div.style.display = "none"; - } else { - div.style.display = "block"; - } - - /* fold all other divs */ - /* - divs = document.getElementsByTagName('div'); - for (var i = 0; i < divs.length; i++) { - if (divs[i].attributes['id'].value == id) { - continue; - } else { - divs[i].style.display = "none"; - } - } - */ - } - ]]> - </script> - </head> - <body onload="init()"> - <!--<H1>Libvirt testing report</H1>--> - <center><img src="icon.png" alt=""/></center> - <xsl:for-each select="log/testrun"> - <xsl:variable name="div_id" select="@name"/> - <h2><b><a href="#{$div_id}" onclick="fold_unfold({$div_id})">Testrun@<xsl:value-of select="@name"/></a></b></h2> - <DIV id="{$div_id}" style="display: none;"> - <table border="0" class="statu-list" cellspan="0" cellspacing="0"> - <tr> - <th><a href="#{$div_id}" onclick="on_result_clicked({$div_id}, 'TOTAL')">Total</a></th> - <th><a href="#{$div_id}" onclick="on_result_clicked({$div_id}, 'PASS')">PASS</a></th> - <th><a href="#{$div_id}" onclick="on_result_clicked({$div_id}, 'FAIL')">FAIL</a></th> - <!--<th><a href="#{$div_id}" onclick="on_result_clicked({$div_id}, 'SKIP')">SKIP</a></th>--> - <th>Start</th> - <th>End</th> - </tr> - <tr> - <td><xsl:value-of select="total"/></td> - <td><xsl:value-of select="pass"/></td> - <td><xsl:value-of select="fail"/></td> - <!--<td><xsl:value-of select="skip"/></td>--> - <td><xsl:value-of select="start_time"/></td> - <td><xsl:value-of select="end_time"/></td> - </tr> - </table> - - <table id="{$div_id}tb" class="list" cellspan="0" cellspacing="0"> - <thead> - <tr> - <th width="5%">No.</th> - <th width="5%">Result</th> - <th width="12%">Start</th> - <th width="12%">End</th> - <th width="66%">Test Procedure</th> - </tr> - </thead> - - <tbody> - <xsl:for-each select="test"> - <tr> - <td> - <xsl:variable name="link" select="path"/> - <a href="{$link}"><xsl:value-of select="@id"/> </a> - </td> - <xsl:choose> - <xsl:when test="result = 'PASS'"> - <td class="pass"><xsl:value-of select="result"/></td> - </xsl:when> - <xsl:when test="result = 'FAIL'"> - <td class="fail"><xsl:value-of select="result"/></td> - </xsl:when> - <xsl:otherwise> - <td></td> - </xsl:otherwise> - </xsl:choose> - <td><xsl:value-of select="start_time"/></td> - <td><xsl:value-of select="end_time"/></td> - <td> - <table class="pro" cellspacing="1" cellspan="0" > - <xsl:for-each select="test_procedure"> - <tr> - <td class="li-tit"> - <xsl:value-of select="action/@name"/><br/> - </td> - <td> - <xsl:for-each select="action/arg"> - <span> - <xsl:value-of select="@name"/> - <xsl:text>=</xsl:text> - <xsl:value-of select="."/> - </span> - </xsl:for-each> - </td> - </tr> - </xsl:for-each> - </table> - </td> - </tr> - </xsl:for-each> - </tbody> - </table> - </DIV> - </xsl:for-each> - </body> + <head> + <title>Libvirt testing log</title> + <link rel="stylesheet" href="log.css" type="text/css" media="screen" /> + <script language="javascript"> + <![CDATA[ + var xmlDOc; + var xslDoc; + var active_result; + var active_div_id; + + function init(logname) { + var xmlDoc; + var xslDoc; + + active_result = "TOTAL"; + expand_last_div(); + } + + function expand_last_div() { + divs = document.getElementsByTagName('div'); + last_div = divs[divs.length - 1]; + last_div.style.display = "block"; + active_div_id = last_div.attributes['id'].value; + } + + function on_result_clicked(div_id, result){ + if (result== active_result && active_div_id == div_id) + return; + + active_result = result; + active_div_id = div_id; + + var table = document.getElementById(div_id + "tb"); + var trs = table.childNodes[1].childNodes; + + if (result == "TOTAL") { + for (var i = 0; i < trs.length; i++) { + trs[i].style.display = "table-row"; + } + + return; + } + + for (var i = 0; i < trs.length; i++) { + var cels = trs[i].childNodes; + var is_result = false; + + for (var j = 0; j < cels.length; j++) { + if(cels[j].innerHTML == result) { + is_result = true; + trs[i].style.display = "table-row"; + break; + } + } + + if (!is_result) { + trs[i].style.display = "none"; + } + } + } + + function fold_unfold(id) { + div = document.getElementById(id); + + if (div.style.display == "block") { + div.style.display = "none"; + } else { + div.style.display = "block"; + } + + /* fold all other divs */ + /* + divs = document.getElementsByTagName('div'); + for (var i = 0; i < divs.length; i++) { + if (divs[i].attributes['id'].value == id) { + continue; + } else { + divs[i].style.display = "none"; + } + } + */ + } + ]]> + </script> + </head> + <body onload="init()"> + <!--<H1>Libvirt testing report</H1>--> + <center><img src="icon.png" alt=""/></center> + <xsl:for-each select="log/testrun"> + <xsl:variable name="div_id" select="@name"/> + <h2><b><a href="#{$div_id}" onclick="fold_unfold({$div_id})">Testrun <xsl:value-of select="@name"/></a></b></h2> + <DIV id="{$div_id}" style="display: none;"> + <table border="0" class="statu-list" cellspan="0" cellspacing="0"> + <tr> + <th><a href="#{$div_id}" onclick="on_result_clicked({$div_id}, 'TOTAL')">Total</a></th> + <th><a href="#{$div_id}" onclick="on_result_clicked({$div_id}, 'PASS')">PASS</a></th> + <th><a href="#{$div_id}" onclick="on_result_clicked({$div_id}, 'FAIL')">FAIL</a></th> + <!--<th><a href="#{$div_id}" onclick="on_result_clicked({$div_id}, 'SKIP')">SKIP</a></th>--> + <th>Start</th> + <th>End</th> + </tr> + <tr> + <td><xsl:value-of select="total"/></td> + <td><xsl:value-of select="pass"/></td> + <td><xsl:value-of select="fail"/></td> + <!--<td><xsl:value-of select="skip"/></td>--> + <td><xsl:value-of select="start_time"/></td> + <td><xsl:value-of select="end_time"/></td> + </tr> + </table> + + <table id="{$div_id}tb" class="list" cellspan="0" cellspacing="0"> + <thead> + <tr> + <th width="5%">No.</th> + <th width="5%">Result</th> + <th width="12%">Start</th> + <th width="12%">End</th> + <th width="66%">Test Procedure</th> + </tr> + </thead> + <tbody> + <xsl:for-each select="test"> + <tr> + <td> + <xsl:variable name="link" select="path"/> + <a href="{$link}"><xsl:value-of select="@id"/> </a> + </td> + <xsl:choose> + <xsl:when test="result = 'PASS'"> + <td class="pass"><xsl:value-of select="result"/></td> + </xsl:when> + <xsl:when test="result = 'FAIL'"> + <td class="fail"><xsl:value-of select="result"/></td> + </xsl:when> + <xsl:otherwise> + <td></td> + </xsl:otherwise> + </xsl:choose> + <td><xsl:value-of select="start_time"/></td> + <td><xsl:value-of select="end_time"/></td> + <td> + <table class="pro" cellspacing="1" cellspan="0" > + <xsl:for-each select="test_procedure"> + <tr> + <td class="li-tit"> + <xsl:value-of select="action/@name"/> + </td> + <td> + <xsl:for-each select="action/arg"> + <span> + <xsl:value-of select="@name"/> + <xsl:text>=</xsl:text> + <xsl:value-of select="."/> + </span> + </xsl:for-each> + </td> + </tr> + </xsl:for-each> + </table> + </td> + </tr> + </xsl:for-each> + </tbody> + </table> + </DIV> + </xsl:for-each> + </body> </html> </xsl:template> </xsl:stylesheet>
ACK, looks way better this way. Martin

On 03/29/2012 08:26 PM, Martin Kletzander wrote:
On 03/29/2012 02:04 PM, Peter Krempa wrote:
The XSL file that converts the log xml into a html file contains some strange whitespace characters that output in the HTML as squares.
This patch fixes the whitespace and reformats the indetation to two spaces as used in libvirt XML files.
*log.css: -make test name field wider *log.xsl: -fix whitespace and indentation -remove '@' from test headers --- log.css | 2 +- log.xsl | 341 +++++++++++++++++++++++++++++++-------------------------------- 2 files changed, 170 insertions(+), 173 deletions(-)
ACK, looks way better this way.
Martin
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Thanks and pushed. Guannan Ren
participants (3)
-
Guannan Ren
-
Martin Kletzander
-
Peter Krempa