以下是<Validation>
标签可以有 1....n 个<Failed>
标签的 XML。
<Header>
...
...
</Header>
<Validation>
<Type>Classic</Type>
<Percentage>10</sPercentage>
<Failed>
<ID>CS-20192018</ID>
<Department>MF404</Department>
<ErrorDescription>Failed at server</ErrorDescription>
</Failed>
<Failed>
<ID>CS-3233333</ID>
<Department>MF404</Department>
<ErrorDescription>Failed at webservice</ErrorDescription>
</Failed>
</Validation>
<Validation>
<Type>CheckMember</Type>
<Percentage>20</Percentage>
<Failed>
<ID>CS-4648902</ID>
<Department>MF404</Department>
<ErrorDescription>Data not available</ErrorDescription>
</Failed>
</Validation>
要求:
我只是想根据<Failed>
计数总结百分比。
第一个<Validation>
标签:
Percentage * no of <Failed> count = Result1
10 * 2 = 20
第二个<Validation>
标签:
Percentage * no of <Failed> count = Result2
20 * 1 = 20
Total = Result1 + Result2 = 20 + 20 = 40
因此,我想将总百分比输出设为 40,并且我尝试了xsl:call-template
方法,但它化为乌有。
你能分享我计算百分比总和的代码片段吗?