How do I show results one at a time using XSLT (e.g. XML included)
Tag : xml , By : Helpful Dude
Date : March 29 2020, 07:55 AM
I hope this helps you . A for-each changes the context node so inside of the for-each you should respectively want to use a relative expression e.g. <xsl:for-each select="/GSP/ENTOBRESULTS/OBRES/MODULE_RESULT">
<dt>
<strong><a href="#"><xsl:value-of select="Field[@name='fullname']"/></a></strong><br/>
<em><xsl:value-of select="Field[@name='title']"/></em>
</dt>
<dd><xsl:value-of select="Field[@name='telephonenumber']"/></dd>
</xsl:for-each>
|
XSLT: How to show count of pass fail test cases
Date : March 29 2020, 07:55 AM
Hope that helps I need to show count of pass fail test cases as well... please see the output.... any help ?? below logic is working fine. THANKS to all..... My stylesheet is attached below , I am mostly guessing here. Given an input of: <TESTSUITE>
<TESTSEQUENCE>
<TESTCASESTARTTIME>2014-05-02 16:02:38</TESTCASESTARTTIME>
<TESTCASENAME>A</TESTCASENAME>
<SCRIPTFILENAME>/proj/cpptemp/dt/network_repo/398/int/IEXS_CRX901185_1/iov/cbm1-3_mct/tc/Traffic.tcl</SCRIPTFILENAME>
<HTMLLOGFILENAME>TRAFFIC_MIXED_COLD_TP-A15.html</HTMLLOGFILENAME>
<RESULT>FAILED</RESULT>
<FINISHTIME>1399039672</FINISHTIME>
</TESTSEQUENCE>
<TESTSEQUENCE>
<TESTCASESTARTTIME>2014-05-02 16:02:39</TESTCASESTARTTIME>
<TESTCASENAME>B</TESTCASENAME>
<SCRIPTFILENAME>/proj/cpptemp/dt/network_repo/398/int/IEXS_CRX901185_1/iov/cbm1-3_mct/tc/Traffic.tcl</SCRIPTFILENAME>
<HTMLLOGFILENAME>TRAFFIC_MIXED_COLD_TP-A15.html</HTMLLOGFILENAME>
<RESULT>PASSED</RESULT>
<FINISHTIME>1399039682</FINISHTIME>
</TESTSEQUENCE>
<TESTSEQUENCE>
<TESTCASESTARTTIME>2014-05-02 16:02:40</TESTCASESTARTTIME>
<TESTCASENAME>C</TESTCASENAME>
<SCRIPTFILENAME>/proj/cpptemp/dt/network_repo/398/int/IEXS_CRX901185_1/iov/cbm1-3_mct/tc/Traffic.tcl</SCRIPTFILENAME>
<HTMLLOGFILENAME>TRAFFIC_MIXED_COLD_TP-A15.html</HTMLLOGFILENAME>
<RESULT>PASSED</RESULT>
<FINISHTIME>1399039692</FINISHTIME>
</TESTSEQUENCE>
<TESTSEQUENCE>
<TESTCASESTARTTIME>2014-05-02 16:02:41</TESTCASESTARTTIME>
<TESTCASENAME>D</TESTCASENAME>
<SCRIPTFILENAME>/proj/cpptemp/dt/network_repo/398/int/IEXS_CRX901185_1/iov/cbm1-3_mct/tc/Traffic.tcl</SCRIPTFILENAME>
<HTMLLOGFILENAME>TRAFFIC_MIXED_COLD_TP-A15.html</HTMLLOGFILENAME>
<RESULT>ABORTED</RESULT>
<FINISHTIME>1399039702</FINISHTIME>
</TESTSEQUENCE>
<TESTSEQUENCE>
<TESTCASESTARTTIME>2014-05-02 16:02:42</TESTCASESTARTTIME>
<TESTCASENAME>E</TESTCASENAME>
<SCRIPTFILENAME>/proj/cpptemp/dt/network_repo/398/int/IEXS_CRX901185_1/iov/cbm1-3_mct/tc/Traffic.tcl</SCRIPTFILENAME>
<HTMLLOGFILENAME>TRAFFIC_MIXED_COLD_TP-A15.html</HTMLLOGFILENAME>
<RESULT>PASSED</RESULT>
<FINISHTIME>1399039712</FINISHTIME>
</TESTSEQUENCE>
</TESTSUITE>
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/TESTSUITE">
<testsuite tests="{count(TESTSEQUENCE)}" passed="{count(TESTSEQUENCE[RESULT='PASSED'])}" failed="{count(TESTSEQUENCE[RESULT='FAILED'])}">
<xsl:for-each select="TESTSEQUENCE">
<testcase>
<xsl:for-each select="*[not (self::TESTCASESTARTTIME or self::TESTCASENAME or self::HTMLLOGFILENAME or self::RESULT)]">
<xsl:attribute name="{name()}">
<xsl:value-of select="."/>
</xsl:attribute>
</xsl:for-each>
<xsl:attribute name="time">
<xsl:value-of select="TESTCASESTARTTIME"/>
</xsl:attribute>
<xsl:attribute name="name">
<xsl:value-of select="TESTCASENAME"/>
</xsl:attribute>
<xsl:attribute name="url">
<xsl:value-of select="HTMLLOGFILENAME"/>
</xsl:attribute>
<xsl:attribute name="status">
<xsl:value-of select="RESULT"/>
</xsl:attribute>
</testcase>
</xsl:for-each>
</testsuite>
</xsl:template>
</xsl:stylesheet>
<?xml version="1.0" encoding="UTF-8"?>
<testsuite tests="5" passed="3" failed="1">
<testcase SCRIPTFILENAME="/proj/cpptemp/dt/network_repo/398/int/IEXS_CRX901185_1/iov/cbm1-3_mct/tc/Traffic.tcl" FINISHTIME="1399039672" time="2014-05-02 16:02:38" name="A" url="TRAFFIC_MIXED_COLD_TP-A15.html" status="FAILED"/>
<testcase SCRIPTFILENAME="/proj/cpptemp/dt/network_repo/398/int/IEXS_CRX901185_1/iov/cbm1-3_mct/tc/Traffic.tcl" FINISHTIME="1399039682" time="2014-05-02 16:02:39" name="B" url="TRAFFIC_MIXED_COLD_TP-A15.html" status="PASSED"/>
<testcase SCRIPTFILENAME="/proj/cpptemp/dt/network_repo/398/int/IEXS_CRX901185_1/iov/cbm1-3_mct/tc/Traffic.tcl" FINISHTIME="1399039692" time="2014-05-02 16:02:40" name="C" url="TRAFFIC_MIXED_COLD_TP-A15.html" status="PASSED"/>
<testcase SCRIPTFILENAME="/proj/cpptemp/dt/network_repo/398/int/IEXS_CRX901185_1/iov/cbm1-3_mct/tc/Traffic.tcl" FINISHTIME="1399039702" time="2014-05-02 16:02:41" name="D" url="TRAFFIC_MIXED_COLD_TP-A15.html" status="ABORTED"/>
<testcase SCRIPTFILENAME="/proj/cpptemp/dt/network_repo/398/int/IEXS_CRX901185_1/iov/cbm1-3_mct/tc/Traffic.tcl" FINISHTIME="1399039712" time="2014-05-02 16:02:42" name="E" url="TRAFFIC_MIXED_COLD_TP-A15.html" status="PASSED"/>
</testsuite>
|
How to calculate the test results pass percentage in XSLT
Tag : html , By : KaoFloppy
Date : March 29 2020, 07:55 AM
this will help The input is an XML file , Use the div operator instead of the / sign: <xsl:value-of select="$Pass div $totalNo * 100"/>
|
XSLT – Pass attributes to create parent elements, then order filtered results
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further Your distinct-values is selecting @n attributes, but I think you mean to select @nationality attributes <xsl:variable name="cou" select="distinct-values(//@nationality)"/>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:output method="xml" indent="yes" />
<xsl:template match="/*">
<OrderedIndex>
<xsl:for-each-group select="Person" group-by="@nationality">
<xsl:sort select="@nationality"/>
<Country key="{current-grouping-key()}">
<xsl:apply-templates select="current-group()">
<xsl:sort select="@age" />
</xsl:apply-templates>
</Country>
</xsl:for-each-group>
</OrderedIndex>
</xsl:template>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:output method="xml" indent="yes" />
<xsl:variable name="cou" select="distinct-values(//@nationality)"/>
<xsl:variable name="root" select="/"/>
<xsl:key name="people" match="Person" use="@nationality" />
<xsl:template match="/*">
<List>
<xsl:for-each select="$cou">
<xsl:sort select="." />
<country key="{.}">
<xsl:apply-templates select="apply-templates select="">
<xsl:sort select="@age" />
</xsl:apply-templates>
</country>
</xsl:for-each>
</List>
</xsl:template>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
|
MySQL/jQuery: fetch table results, pass into a jQuery array, show only 6 at a time and rotate results at random
Date : March 29 2020, 07:55 AM
this one helps. For your javascript tag, you really just need a shuffle function and an all-inclusive changeComponent function that does all the work each interval heartbeat. Also, you'll notice that jQuery has a more useful version of the each() function that provides the index of the current element: <?php $result = $conn->query("SELECT * FROM user_data WHERE advert_type = 'Deluxe'");
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
$p_id = $row['user_id'];
$new_array[] = $p_id;
}
}
echo '<script>';
echo 'var imagesArray = ' . json_encode($new_array) . ';';
echo '</script>';
?>
<script>
//Good shuffle algorithm: https://stackoverflow.com/questions/2450954/how-to-randomize-shuffle-a-javascript-array
function shuffle(array) {
var currentIndex = array.length, temporaryValue, randomIndex;
// While there remain elements to shuffle...
while (0 !== currentIndex) {
// Pick a remaining element...
randomIndex = Math.floor(Math.random() * currentIndex);
currentIndex -= 1;
// And swap it with the current element.
temporaryValue = array[currentIndex];
array[currentIndex] = array[randomIndex];
array[randomIndex] = temporaryValue;
}
return array;
}
function changeComponent() {
// store image query in a variable
var $allImages = $(".premium_ad_img");
// take X random IDs by shuffling the list and taking the first X
// (slice total dynamically, in case you ever need more or less than exactly 6)
var randomIDs = shuffle(imagesArray).slice(0, $allImages.length);
// iterate over each image, using the index of the iteration.
$allImages.each(function (idx) {
$(this).attr('src', 'data/profiles/users/profile_img/' + randomIDs[idx] + '/main.jpg');
$(this).parent(".premium_component_link").attr('href', 'profile.php?p_id=' + randomIDs[idx]);
});
}
$(document).ready(function () {
changeComponent();
setInterval(function() {
changeComponent();
}, 5000);
})
</script>
|