Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html XSLT中测试结果通过率的计算_Html_Xml_Xslt 1.0 - Fatal编程技术网

Html XSLT中测试结果通过率的计算

Html XSLT中测试结果通过率的计算,html,xml,xslt-1.0,Html,Xml,Xslt 1.0,输入是一个XML文件 <test-results name="project name" total="73" errors="0" failures="43" not-run="0" inconclusive="0" ignored="0" skipped="0" invalid="0" date="2016-01-05" time="20:32:22"> ....... </test-results> ....... 我想计算“通过结果数”和“通过百分比”。我已

输入是一个XML文件

<test-results name="project name" total="73" errors="0" failures="43" not-run="0" inconclusive="0" ignored="0" skipped="0" invalid="0" date="2016-01-05" time="20:32:22">
.......
</test-results>

.......
我想计算“通过结果数”和“通过百分比”。我已经做了没有通过的结果。它工作得很好

               <tr>
                <td>Number of Passes</td>
                <td>
                  <xsl:variable name="failures" select="@failures"/>
                  <xsl:variable name="total" select="@total"/>
                  <xsl:choose>
                    <xsl:when test="$failures != ''">
                      <xsl:value-of select="($total - $failures)"/>
                    </xsl:when>
                    <xsl:otherwise>
                      <xsl:value-of select="@total"/>
                    </xsl:otherwise>
                  </xsl:choose>
                </td>
              </tr>

通过次数
现在我想计算通过率(例如:-87.45%)。我尝试了下面的逻辑。但它抛出了一个例外

<tr>
        <td>Success Rate</td>
        <td>
          <xsl:variable name="Pass" select="@total - @failures"/>
          <xsl:variable name="totalNo" select="@total"/>
          <xsl:value-of select="($Pass/$totalNo)*100"/>
        </td>
      </tr>

成功率
有人能帮我计算一下通过率吗?
提前感谢。

使用
div
操作符而不是
/
符号:

<xsl:value-of select="$Pass div $totalNo * 100"/>


它会引发哪种异常?@Tomalak--XSL转换异常(运行时错误)-未接受的令牌-编译时错误您的代码运行良好,但我需要添加2个小数点并附加%的输出(例如:-87.45%)@Vishnu使用
format-number()
函数