现有XML:
"<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="summary1.xslt"?>
<SYSTEM>
<XMLfile name="Filename of current XML file">sample1.xml</XMLfile>
<TestInstance0>
<LogFile>summary1.log</LogFile>
<TSVFile/>
<TesterID>Me</TesterID>
<Station>DEV01</Station>
<ReleaseVersion>Rel_I02</ReleaseVersion>
<StartTime name="Test Execution Start Date and Time YYYYMMDD:HHmmss">20161221:163642</StartTime>
<EndTime name="Test Execution End Date and Time YYYYMMDD:HHmmss">20161221:174409</EndTime>
<TotalTime name="Test Execution Total Time HH:mm:ss">1:07:27</TotalTime>
<AutoTime name="Test Automation Total Time HH:mm:ss">1:07:27</AutoTime>
<IdleTime name="Test Idle/Wait Total Time HH:mm:ss">0:00:00</IdleTime>
<Status name="Test Execution Status. Use IMCOMPLETE,PASS,FAIL">FAIL</Status>
<TestList>
<Test1>
<StartTime name="Start date and time YYYYMMDD:HHmmss.">20161221:163643</StartTime>
<TotalTime name="Total test time in seconds">0</TotalTime>
<AutoTime name="Total automation time in seconds">0</AutoTime>
<IdleTime name="Total idle/wait time in seconds">0</IdleTime>
<TestResult name="Use INCOMPLETE PASS FAIL SKIP.">PASS</TestResult>
<FailDesc name="Description of failure">COMPLETE</FailDesc>
</Test1>
<Test2>
<StartTime name="Start date and time YYYYMMDD:HHmmss.">20161221:163643</StartTime>
<TotalTime name="Total test time in seconds">940</TotalTime>
<AutoTime name="Total automation time in seconds">940</AutoTime>
<IdleTime name="Total idle/wait time in seconds">0</IdleTime>
<TestResult name="Use INCOMPLETE PASS FAIL SKIP.">PASS</TestResult>
<FailDesc name="Description of failure">COMPLETE</FailDesc>
</Test2>
<Test3>
<StartTime name="Start date and time YYYYMMDD:HHmmss.">20161221:165223</StartTime>
<TotalTime name="Total test time in seconds">488</TotalTime>
<AutoTime name="Total automation time in seconds">488</AutoTime>
<IdleTime name="Total idle/wait time in seconds">0</IdleTime>
<TestResult name="Use INCOMPLETE PASS FAIL SKIP.">PASS</TestResult>
<FailDesc name="Description of failure">COMPLETE</FailDesc>
</Test3>
<Test4>
<StartTime name="Start date and time YYYYMMDD:HHmmss.">20161221:170031</StartTime>
<TotalTime name="Total test time in seconds">1067</TotalTime>
<AutoTime name="Total automation time in seconds">47</AutoTime>
<IdleTime name="Total idle/wait time in seconds">1020</IdleTime>
<TestResult name="Use INCOMPLETE PASS FAIL SKIP.">PASS</TestResult>
<FailDesc name="Description of failure">COMPLETE</FailDesc>
</Test4>
<Test5>
<StartTime name="Start date and time YYYYMMDD:HHmmss.">20161221:171818</StartTime>
<TotalTime name="Total test time in seconds">1551</TotalTime>
<AutoTime name="Total automation time in seconds">1551</AutoTime>
<IdleTime name="Total idle/wait time in seconds">0</IdleTime>
<TestResult name="Use INCOMPLETE PASS FAIL SKIP.">FAIL</TestResult>
<FailDesc name="Description of failure">Failed Test5</FailDesc>
</Test5>
<Test6>
<StartTime name="Start date and time YYYYMMDD:HHmmss."/>
<TotalTime name="Total test time in seconds"/>
<AutoTime name="Total automation time in seconds"/>
<IdleTime name="Total idle/wait time in seconds"/>
<TestResult name="Use INCOMPLETE PASS FAIL SKIP.">NOT RUN</TestResult>
<FailDesc name="Description of failure"/>
</Test6>
<Test7>
<StartTime name="Start date and time YYYYMMDD:HHmmss."/>
<TotalTime name="Total test time in seconds"/>
<AutoTime name="Total automation time in seconds"/>
<IdleTime name="Total idle/wait time in seconds"/>
<TestResult name="Use INCOMPLETE PASS FAIL SKIP.">NOT RUN</TestResult>
<FailDesc name="Description of failure"/>
</Test7>
<Test8>
<StartTime name="Start date and time YYYYMMDD:HHmmss."/>
<TotalTime name="Total test time in seconds"/>
<AutoTime name="Total automation time in seconds"/>
<IdleTime name="Total idle/wait time in seconds"/>
<TestResult name="Use INCOMPLETE PASS FAIL SKIP.">NOT RUN</TestResult>
<FailDesc name="Description of failure"/>
</Test8>
<Test9>
<StartTime name="Start date and time YYYYMMDD:HHmmss."/>
<TotalTime name="Total test time in seconds"/>
<AutoTime name="Total automation time in seconds"/>
<IdleTime name="Total idle/wait time in seconds"/>
<TestResult name="Use INCOMPLETE PASS FAIL SKIP.">NOT RUN</TestResult>
<FailDesc name="Description of failure"/>
</Test9>
<Test10>
<StartTime name="Start date and time YYYYMMDD:HHmmss."/>
<TotalTime name="Total test time in seconds"/>
<AutoTime name="Total automation time in seconds"/>
<IdleTime name="Total idle/wait time in seconds"/>
<TestResult name="Use INCOMPLETE PASS FAIL SKIP.">NOT RUN</TestResult>
<FailDesc name="Description of failure"/>
</Test10>
</TestList>
</TestInstance0>
<TestInstance1>
<LogFile>sample1.log</LogFile>
<TSVFile/>
<TesterID>Me</TesterID>
<Station>DEV01</Station>
<ReleaseVersion>Rel_I02</ReleaseVersion>
<StartTime name="Test Execution Start Date and Time YYYYMMDD:HHmmss">20161221:192226</StartTime>
<EndTime name="Test Execution End Date and Time YYYYMMDD:HHmmss">20161221:194931</EndTime>
<TotalTime name="Test Execution Total Time HH:mm:ss">0:27:06</TotalTime>
<AutoTime name="Test Automation Total Time HH:mm:ss">0:27:06</AutoTime>
<IdleTime name="Test Idle/Wait Total Time HH:mm:ss">0:00:00</IdleTime>
<Status name="Test Execution Status. Use IMCOMPLETE,PASS,FAIL">FAIL</Status>
<TestList>
<Test1>
<StartTime name="Start date and time YYYYMMDD:HHmmss.">20161221:192226</StartTime>
<TotalTime name="Total test time in seconds">0</TotalTime>
<AutoTime name="Total automation time in seconds">0</AutoTime>
<IdleTime name="Total idle/wait time in seconds">0</IdleTime>
<TestResult name="Use INCOMPLETE PASS FAIL SKIP.">PASS</TestResult>
<FailDesc name="Description of failure">COMPLETE</FailDesc>
</Test1>
<Test2>
<StartTime name="Start date and time YYYYMMDD:HHmmss.">20161221:192227</StartTime>
<TotalTime name="Total test time in seconds">0</TotalTime>
<AutoTime name="Total automation time in seconds">0</AutoTime>
<IdleTime name="Total idle/wait time in seconds">0</IdleTime>
<TestResult name="Use INCOMPLETE PASS FAIL SKIP.">PASS</TestResult>
<FailDesc name="Description of failure">COMPLETE</FailDesc>
</Test2>
<Test3>
<StartTime name="Start date and time YYYYMMDD:HHmmss.">20161221:192227</StartTime>
<TotalTime name="Total test time in seconds">73</TotalTime>
<AutoTime name="Total automation time in seconds">73</AutoTime>
<IdleTime name="Total idle/wait time in seconds">0</IdleTime>
<TestResult name="Use INCOMPLETE PASS FAIL SKIP.">PASS</TestResult>
<FailDesc name="Description of failure">COMPLETE</FailDesc>
</Test3>
<Test4>
<StartTime name="Start date and time YYYYMMDD:HHmmss.">20161221:192340</StartTime>
<TotalTime name="Total test time in seconds">1</TotalTime>
<AutoTime name="Total automation time in seconds">1</AutoTime>
<IdleTime name="Total idle/wait time in seconds">0</IdleTime>
<TestResult name="Use INCOMPLETE PASS FAIL SKIP.">PASS</TestResult>
<FailDesc name="Description of failure">COMPLETE</FailDesc>
</Test4>
<Test5>
<StartTime name="Start date and time YYYYMMDD:HHmmss.">20161221:192341</StartTime>
<TotalTime name="Total test time in seconds">1550</TotalTime>
<AutoTime name="Total automation time in seconds">1550</AutoTime>
<IdleTime name="Total idle/wait time in seconds">0</IdleTime>
<TestResult name="Use INCOMPLETE PASS FAIL SKIP.">FAIL</TestResult>
<FailDesc name="Description of failure">Failed Test5</FailDesc>
</Test5>
<Test6>
<StartTime name="Start date and time YYYYMMDD:HHmmss."/>
<TotalTime name="Total test time in seconds"/>
<AutoTime name="Total automation time in seconds"/>
<IdleTime name="Total idle/wait time in seconds"/>
<TestResult name="Use INCOMPLETE PASS FAIL SKIP.">NOT RUN</TestResult>
<FailDesc name="Description of failure"/>
</Test6>
<Test7>
<StartTime name="Start date and time YYYYMMDD:HHmmss."/>
<TotalTime name="Total test time in seconds"/>
<AutoTime name="Total automation time in seconds"/>
<IdleTime name="Total idle/wait time in seconds"/>
<TestResult name="Use INCOMPLETE PASS FAIL SKIP.">NOT RUN</TestResult>
<FailDesc name="Description of failure"/>
</Test7>
<Test8>
<StartTime name="Start date and time YYYYMMDD:HHmmss."/>
<TotalTime name="Total test time in seconds"/>
<AutoTime name="Total automation time in seconds"/>
<IdleTime name="Total idle/wait time in seconds"/>
<TestResult name="Use INCOMPLETE PASS FAIL SKIP.">NOT RUN</TestResult>
<FailDesc name="Description of failure"/>
</Test8>
<Test9>
<StartTime name="Start date and time YYYYMMDD:HHmmss."/>
<TotalTime name="Total test time in seconds"/>
<AutoTime name="Total automation time in seconds"/>
<IdleTime name="Total idle/wait time in seconds"/>
<TestResult name="Use INCOMPLETE PASS FAIL SKIP.">NOT RUN</TestResult>
<FailDesc name="Description of failure"/>
</Test9>
<Test10>
<StartTime name="Start date and time YYYYMMDD:HHmmss."/>
<TotalTime name="Total test time in seconds"/>
<AutoTime name="Total automation time in seconds"/>
<IdleTime name="Total idle/wait time in seconds"/>
<TestResult name="Use INCOMPLETE PASS FAIL SKIP.">NOT RUN</TestResult>
<FailDesc name="Description of failure"/>
</Test10>
</TestList>
</TestInstance1>
<TestInstance2>
<LogFile>sample1.log</LogFile>
<TSVFile>sample1.tsv</TSVFile>
<TesterID>Me</TesterID>
<Station>DEV01</Station>
<ReleaseVersion>Rel_I02</ReleaseVersion>
<StartTime name="Test Execution Start Date and Time YYYYMMDD:HHmmss">20161227:003807</StartTime>
<EndTime name="Test Execution End Date and Time YYYYMMDD:HHmmss">20161227:035645</EndTime>
<TotalTime name="Test Execution Total Time HH:mm:ss">3:18:38</TotalTime>
<AutoTime name="Test Automation Total Time HH:mm:ss">3:18:38</AutoTime>
<IdleTime name="Test Idle/Wait Total Time HH:mm:ss">0:00:00</IdleTime>
<Status name="Test Execution Status. Use IMCOMPLETE,PASS,FAIL">PASS</Status>
<TestList>
<Test1>
<StartTime name="Start date and time YYYYMMDD:HHmmss.">20161227:003808</StartTime>
<TotalTime name="Total test time in seconds">0</TotalTime>
<AutoTime name="Total automation time in seconds">0</AutoTime>
<IdleTime name="Total idle/wait time in seconds">0</IdleTime>
<TestResult name="Use INCOMPLETE PASS FAIL SKIP.">PASS</TestResult>
<FailDesc name="Description of failure">COMPLETE</FailDesc>
</Test1>
<Test2>
<StartTime name="Start date and time YYYYMMDD:HHmmss.">20161227:003809</StartTime>
<TotalTime name="Total test time in seconds">0</TotalTime>
<AutoTime name="Total automation time in seconds">0</AutoTime>
<IdleTime name="Total idle/wait time in seconds">0</IdleTime>
<TestResult name="Use INCOMPLETE PASS FAIL SKIP.">PASS</TestResult>
<FailDesc name="Description of failure">COMPLETE</FailDesc>
</Test2>
<Test3>
<StartTime name="Start date and time YYYYMMDD:HHmmss.">20161227:003809</StartTime>
<TotalTime name="Total test time in seconds">89</TotalTime>
<AutoTime name="Total automation time in seconds">89</AutoTime>
<IdleTime name="Total idle/wait time in seconds">0</IdleTime>
<TestResult name="Use INCOMPLETE PASS FAIL SKIP.">PASS</TestResult>
<FailDesc name="Description of failure">COMPLETE</FailDesc>
</Test3>
<Test4>
<StartTime name="Start date and time YYYYMMDD:HHmmss.">20161227:003938</StartTime>
<TotalTime name="Total test time in seconds">496</TotalTime>
<AutoTime name="Total automation time in seconds">16</AutoTime>
<IdleTime name="Total idle/wait time in seconds">480</IdleTime>
<TestResult name="Use INCOMPLETE PASS FAIL SKIP.">PASS</TestResult>
<FailDesc name="Description of failure">COMPLETE</FailDesc>
</Test4>
<Test5>
<StartTime name="Start date and time YYYYMMDD:HHmmss.">20161227:004754</StartTime>
<TotalTime name="Total test time in seconds">144</TotalTime>
<AutoTime name="Total automation time in seconds">144</AutoTime>
<IdleTime name="Total idle/wait time in seconds">0</IdleTime>
<TestResult name="Use INCOMPLETE PASS FAIL SKIP.">PASS</TestResult>
<FailDesc name="Description of failure">COMPLETE</FailDesc>
</Test5>
<Test6>
<StartTime name="Start date and time YYYYMMDD:HHmmss.">20161227:005018</StartTime>
<TotalTime name="Total test time in seconds">1</TotalTime>
<AutoTime name="Total automation time in seconds">1</AutoTime>
<IdleTime name="Total idle/wait time in seconds">0</IdleTime>
<TestResult name="Use INCOMPLETE PASS FAIL SKIP.">PASS</TestResult>
<FailDesc name="Description of failure">COMPLETE</FailDesc>
</Test6>
<Test7>
<StartTime name="Start date and time YYYYMMDD:HHmmss.">20161227:005019</StartTime>
<TotalTime name="Total test time in seconds">40</TotalTime>
<AutoTime name="Total automation time in seconds">40</AutoTime>
<IdleTime name="Total idle/wait time in seconds">0</IdleTime>
<TestResult name="Use INCOMPLETE PASS FAIL SKIP.">PASS</TestResult>
<FailDesc name="Description of failure">COMPLETE</FailDesc>
</Test7>
<Test8>
<StartTime name="Start date and time YYYYMMDD:HHmmss.">20161227:005059</StartTime>
<TotalTime name="Total test time in seconds">719</TotalTime>
<AutoTime name="Total automation time in seconds">599</AutoTime>
<IdleTime name="Total idle/wait time in seconds">120</IdleTime>
<TestResult name="Use INCOMPLETE PASS FAIL SKIP.">PASS</TestResult>
<FailDesc name="Description of failure">COMPLETE</FailDesc>
</Test8>
<Test9>
<StartTime name="Start date and time YYYYMMDD:HHmmss.">20161227:010258</StartTime>
<TotalTime name="Total test time in seconds">531</TotalTime>
<AutoTime name="Total automation time in seconds">111</AutoTime>
<IdleTime name="Total idle/wait time in seconds">420</IdleTime>
<TestResult name="Use INCOMPLETE PASS FAIL SKIP.">PASS</TestResult>
<FailDesc name="Description of failure">COMPLETE</FailDesc>
</Test9>
<Test10>
<StartTime name="Start date and time YYYYMMDD:HHmmss.">20161227:011149</StartTime>
<TotalTime name="Total test time in seconds">396</TotalTime>
<AutoTime name="Total automation time in seconds">396</AutoTime>
<IdleTime name="Total idle/wait time in seconds">0</IdleTime>
<TestResult name="Use INCOMPLETE PASS FAIL SKIP.">PASS</TestResult>
<FailDesc name="Description of failure">COMPLETE</FailDesc>
</Test10>
</TestList>
</TestInstance2>
</SYSTEM>"
现有XSL:
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:key name="keyTestInstanceID" match="*[(contains(name(), 'TestInstance'))]" use="." />
<xsl:key name="instances" match="TotalTime" use="@name"/>
<xsl:key name="testinstances" match="TotalTime" use="@name"/>
<xsl:key name="timeStamps" match="EndTime" use="@name"/>
<xsl:template match="SYSTEM">
<HTML>
<HEAD>
<TITLE></TITLE>
</HEAD>
<!-- BODY tag variables used to save the page scroll position -->
<BODY onScroll="document.cookie='ypos=' + window.pageYOffset" onLoad="window.scrollTo(0,readCookie('ypos'))">
<H1><xsl:value-of select="XMLfile"/></H1>
<div class="hr"><hr></hr></div>
<div class="hr2"><span>New Test History</span></div>
<xsl:for-each select="./*">
<xsl:if test="starts-with(local-name(), 'TestInstance')">
<xsl:value-of select="[generate-id(.) = generate-id(key('keyTestInstanceID', substring(.,13))[1])]"/>
<p><b><xsl:value-of select="local-name()" /></b></p>
<p><xsl:value-of select="substring(local-name(),13)" /></p>
</xsl:if>
</xsl:for-each>
<div class="hr"><hr></hr></div>
<div class="hr2"><span>Old Test History</span></div>
<xsl:for-each select="./*">
<xsl:if test="starts-with(local-name(), 'TestInstance')">
<p><b><xsl:value-of select="local-name()" /></b></p>
<div id="tit">
<xsl:apply-templates select="."/>
</div>
</xsl:if>
</xsl:for-each>
</BODY>
</HTML>
</xsl:template>
<!-- Test Instance Template -->
<xsl:template match="*[(contains(name(), 'TestInstance'))]">
<!-- Using "instances" key previously defined, store the total test time (seconds) in a variable named "pSum" -->
<xsl:variable name="pSum"><xsl:value-of select="sum(key('instances', 'Total test time in seconds')[text()])" /></xsl:variable>
<div id="tirh">
<div id="ticl1">
Test Name
</div>
<div id="ticl2">
Total (sec)
</div>
<div id="ticl3">
Auto (sec)
</div>
<div id="ticl4">
Idle (sec)
</div>
<div id="ticl5">
Result
</div>
</div>
<xsl:for-each select="*">
<!-- Test Instance Statistics -->
<xsl:if test="starts-with(local-name(), 'TestList')">
<!-- Using "testinstances" key previously defined, store the total test time (seconds) in a variable named "tSum" -->
<xsl:variable name="tSum"><xsl:value-of select="sum(key('testinstances', 'Total test time in seconds')[text()])" /></xsl:variable>
<xsl:for-each select="*">
<div id="tir">
<div id="ticl1">
<xsl:value-of select="local-name()" />
</div>
<div id="ticl2">
<xsl:value-of select="./TotalTime" />
</div>
<div id="ticl3">
<xsl:value-of select="./AutoTime" />
</div>
<div id="ticl4">
<xsl:value-of select="./IdleTime" />
</div>
<div id="ticl5">
<xsl:value-of select="./TestResult" />
</div>
</div>
</xsl:for-each>
<!-- Test Instance Time -->
<div id="tir">
<div id="ticl1">
<b>Sub Total Test Time </b>(HH:MM:SS)
</div>
<div id="ticl2">
<xsl:if test="not(string-length(../TotalTime))=0">
<b><xsl:value-of select="../TotalTime" /></b>
</xsl:if>
<xsl:if test="(string-length(../TotalTime))=0">
<b><xsl:value-of select="concat(format-number(floor($tSum div 3600),'00'), ':', format-number(floor($tSum mod 3600 div 60),'00'), ':', format-number($tSum mod 60,'00'))"/></b>
</xsl:if>
</div>
<div id="ticl3">
</div>
<div id="ticl4">
</div>
<div id="ticl5">
</div>
</div>
<!-- Total Test Time (reformated from variable $pSum) -->
<div id="tir">
<div id="ticl1">
<b>Total Test Time </b>(HH:MM:SS)
</div>
<div id="ticl2">
<b><xsl:value-of select="concat(format-number(floor($pSum div 3600),'00'), ':', format-number(floor($pSum mod 3600 div 60),'00'), ':', format-number($pSum mod 60,'00'))"/></b>
</div>
<div id="ticl3">
</div>
<div id="ticl4">
</div>
<div id="ticl5">
</div>
</div>
</xsl:if>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>"
目标:对于每个TestInstance [#]:在行中显示所有总时间值和测试值。将所有总时间值和显示为子总测试时间(HH:MM:SS)。每个TestInstance [#]还显示一个总测试时间(HH:MM:SS),其中TestInstance0总数等于子总测试时间。将每个附加的测试固定[#]与上述相同,但是每个新的总测试时间(HH:MM:SS)显示(((sub testInstance [n])的总测试时间[n]) (测试的总测试时间[n-1]))。
示例:
Old Test History
TestInstance0
...
Sub Total Test Time (HH:MM:SS) 1:07:27
Total Test Time (HH:MM:SS) 1:07:27
TestInstance1
...
Sub Total Test Time (HH:MM:SS) 0:27:06
Total Test Time (HH:MM:SS) 1:34:33
TestInstance2
...
Sub Total Test Time (HH:MM:SS) 3:18:38
Total Test Time (HH:MM:SS) 4:53:11
我正在为如何为子总考试时间和总考试时间分配变量,然后获得单独的子总数和运行的总考试时间。我试图使用类似的示例而没有成功。特别是https://www.codeproject.com/articles/1849/grouping-xml-using-sus-xslt
也许这对您有帮助。它通过运行总计创建查找数据。使用它查找运行总计。您可以使用此查找数据,而不是代码中其他位置的键。
<!-- Create some meta data. Use this to look up the running total based on the
node-id(.) of a TestInstance
-->
<xsl:variable name="test">
<xsl:apply-templates select="//Test1|//Test2|//Test3|//Test4|//Test5|//Test6|//Test7|//Test8|//Test9|//Test10" mode="metadata"/>
</xsl:variable>
<!-- Only use node-set for version 1.0. -->
<xsl:variable name="testList" select="msxml:node-set($test)"/>
<!-- Mode to create elements that contain the metadata. -->
<xsl:template match="//Test1|//Test2|//Test3|//Test4|//Test5|//Test6|//Test7|//Test8|//Test9|//Test10" mode="metadata">
<xsl:element name="element">
<xsl:element name="id">
<xsl:value-of select="generate-id(.)"/>
</xsl:element>
<xsl:element name="TestInstanceID">
<!-- Get the TestInstance. -->
<xsl:value-of select="generate-id(../..)"/>
</xsl:element>
<xsl:element name="TestListID">
<!-- Get the TestInstance. -->
<xsl:value-of select="generate-id(..)"/>
</xsl:element>
<xsl:element name="TotalTime">
<xsl:call-template name="getCleanNumber">
<xsl:with-param name="inNumStr" select="TotalTime"/>
</xsl:call-template>
</xsl:element>
</xsl:element>
</xsl:template>
<!-- Get a distinct list of TestInstanceID's. -->
<xsl:variable name="distinctTestInstanceIDs">
<xsl:copy-of select="$testList/element[not(TestInstanceID=preceding-sibling::element/TestInstanceID)]"/>
</xsl:variable>
<!-- Only use node-set for version 1.0. -->
<xsl:variable name="distinctTestInstanceIDsList" select="msxml:node-set($distinctTestInstanceIDs)"/>
<!-- Group the metadata based on distinctTestInstanceIDs. -->
<xsl:variable name="groupedTestInstance">
<xsl:for-each select="$distinctTestInstanceIDsList/element/TestInstanceID">
<xsl:variable name="TestInstanceID" select="."/>
<xsl:element name="element">
<xsl:element name="TestInstanceID">
<!-- Get the TestInstance. -->
<xsl:value-of select="."/>
</xsl:element>
<xsl:element name="TotalTime">
<xsl:value-of select="sum($testList/element[TestInstanceID=$TestInstanceID]/TotalTime)"/>
</xsl:element>
</xsl:element>
</xsl:for-each>
</xsl:variable>
<!-- Only use node-set for version 1.0. -->
<xsl:variable name="groupedTestInstanceList" select="msxml:node-set($groupedTestInstance)"/>
<!-- Now create the rolling totals. -->
<xsl:variable name="rollingTotals">
<xsl:call-template name="generateRollingTotals">
<xsl:with-param name="index" select="1"/>
<xsl:with-param name="rollingTotal" select="0"/>
</xsl:call-template>
</xsl:variable>
<!-- Only use node-set for version 1.0. -->
<xsl:variable name="rollingTotalsList" select="msxml:node-set($rollingTotals)"/>
<!-- Use the rollingTotalsList to lookup the rolling total for a TestInstance.
Create a variable the contains the node-id of the TextIntance for which you
want the rolling total.
<xsl:variable name="TestInstanceID" select="generate-id(.)"/> etc.
Use this variable for the lookup.
-->
<!-- Recursive template to create rolling totals. -->
<xsl:template name="generateRollingTotals">
<xsl:param name="index"/>
<xsl:param name="rollingTotal"/>
<xsl:if test="$index <= count($groupedTestInstanceList/element)">
<xsl:element name="element">
<xsl:element name="TestInstanceID">
<!-- Get the TestInstance. -->
<xsl:value-of select="$groupedTestInstanceList/element[$index]/TestInstanceID"/>
</xsl:element>
<xsl:element name="rollingTotalTime">
<xsl:value-of select="$groupedTestInstanceList/element[$index]/TotalTime + $rollingTotal"/>
</xsl:element>
</xsl:element>
<xsl:call-template name="generateRollingTotals">
<xsl:with-param name="index" select="$index + 1"/>
<xsl:with-param name="rollingTotal" select="$groupedTestInstanceList/element[$index]/TotalTime + $rollingTotal"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
<xsl:template name="getCleanNumber">
<xsl:param name="inNumStr"/>
<!-- Clean up the number. Get the digits and decimal point only. -->
<xsl:variable name="rawNum" select="translate($inNumStr,translate($inNumStr,'0123456789.',''),'')"/>
<!-- Get the number. -->
<xsl:variable name="num">
<xsl:choose>
<xsl:when test="$rawNum='' or $rawNum=0">
<xsl:value-of select="0"/>
</xsl:when>
<xsl:when test="contains($inNumStr,'-') or contains($inNumStr,'(')">
<xsl:value-of select="concat('-',$rawNum)"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$rawNum"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:value-of select="$num"/>
</xsl:template>