我有几个这样的 XML 元素:
<testcase starttime="2012-09-03 10:41:29" timestamp=" 622.922000">
<testlogfile file="" />
<teststep timestamp=" 622.944000" level="0" type="user" ident="1" result="pass">Do something</teststep>
<teststep timestamp=" 622.965000" level="0" type="user" ident="2" result="pass">Do something</teststep>
<teststep timestamp=" 622.986000" level="0" type="user" ident="3" result="pass">Do something</teststep>
<verdict time="2012-09-03 10:41:30" timestamp=" 623.428000" endtime="2012-09-03 10:41:30" endtimestamp=" 623.428000" result="pass" />
<title>Title goes here</title>
<ident>TC100_06</ident>
<description>description goes here</description>
<extendedinfo type="test case status">Approved</extendedinfo>
<extendedinfo type="traceability">some requirement</extendedinfo>
<extendedinfo type="vehicle mode">Hibernate, Parked, Living, Accessory</extendedinfo>
<extendedinfo type="environment">Station with ATB</extendedinfo>
<extendedinfo type="variants">veh variants</extendedinfo>
</testcase>
我想做一个 xsl:variable 选择查询来按“身份”和“测试用例状态”计算测试用例。我能够实现 2 个单独的查询,但我不知道如何将它们都加入:
<xsl:variable name="totalTc" select="count(//testcase[./ident!='text' and ./ident!='obsolete' and ./ident!='rtm' and ./ident!='status overview' and ./ident!='statistics'])"/>
<xsl:variable name="approvedTc" select="count(//extendedinfo[@type='test case status' and text()='Approved'])"/>
我希望加入的查询看起来像这样,但我无法查询属性:
<xsl:variable name="totalTc" select="count(//testcase[./ident!='text' and ./ident!='obsolete' and ./ident!='rtm' and ./ident!='status overview' and ./ident!='statistics' and ./extendedinfo=='Approved'])"/>