I have the following XML (simplification):
<?xml version="1.0" encoding="utf-8"?>
<TestCases>
<TestCase>
<Name>Test1</Name>
<Result>Failed</Result>
<Properties>
<Type>Type1</Type>
</Properties>
</TestCase>
<TestCase>
<Name>Test1</Name>
<Result>Failed</Result>
<Properties>
<Type>Type2</Type>
</Properties>
</TestCase>
<TestCase>
<Name>Test1</Name>
<Result>Passed</Result>
<Properties>
<Type>Type1</Type>
</Properties>
</TestCase>
</TestCases>
I am interested in creating a table that counts the number of passed / failed test cases according to their type, for example:
Transmitted (Type1): 1 Error (Type1): 1 Skipped (Other types): 0 Failure (other types): 1
To do this, I write the following query:
<xsl:value-of select="count(//TestCase[Result = 'Passed' and count(Properties/TestType='Type1')>0])"/>
<xsl:value-of select="count(//TestCase[Result = 'Failed' and count(Properties/TestType='Type1')>0])"/>
<xsl:value-of select="count(//TestCase[Result = 'Passed' and count(Properties/TestType='Type1')=0])"/>
<xsl:value-of select="count(//TestCase[Result = 'Failed' and count(Properties/TestType='Type1')=0])"/>
As you can see, there are many repetitions of the code, and it would be great if I could save some of them. I understand that in XSL 2.0 I could use custom functions for it, but what should I do in XSL 1.0? Do you see any options that you can see to optimize duplicate expressions?
P.S , , , , .
!