我有以下XML:
<problem>
<problemID>1117</problemID>
<file>/Admin/moc_/test/src/test.cpp</file>
<code>XXXX</code>
<message>Example</message>
<citingStatus>Analyze</citingStatus>
<severity>Unexpected</severity>
</problem>
<problem>
<problemID>1118</problemID>
<file>/Admin/moc_/test/src/test.cpp</file>
<code>XXXX</code>
<message>Example</message>
<citingStatus>Analyze</citingStatus>
<severity>Unexpected</severity>
</problem>
<problem>
<problemID>1119</problemID>
<file>/Admin/test/src/test.cpp</file>
<code>XXXX</code>
<message>Example</message>
<citingStatus>Analyze</citingStatus>
<severity>Unexpected</severity>
</problem>
<problem>
<problemID>1120</problemID>
<file>/Admin/moc_/test/src/test.cpp</file>
<code>XXXX</code>
<message>Example</message>
<citingStatus>Analyze</citingStatus>
<severity>Critical</severity>
</problem>
<problem>
<problemID>1121</problemID>
<file>/Admin/XXX/test/src/test.cpp</file>
<code>XXXX</code>
<message>Example</message>
<citingStatus>Analyze</citingStatus>
<severity>Unexpected</severity>
</problem>
我想将不包含文件名的出现次数计为“moc_”,并将严重性标签计为“Unexpected”
使用的XSLT标记是:
<xsl:value-of select="count(problem[file[contains(.,'moc_')]] and [severity[.='Unexpected']])"/>
使用上述标记会引发错误。我可以个人计算计数但不计算和条件。
答案 0 :(得分:1)
尝试:
<xsl:value-of select="count(problem[file[contains(.,'moc_')]][severity='Unexpected'])"/>
或:
<xsl:value-of select="count(problem[file[contains(.,'moc_')] and severity='Unexpected'])"/>
请注意:
[severity[.='Unexpected']]
可以简单地说:
[severity='Unexpected']