Pau*_*ers 2 xslt variables select value-of
假设我有一些像这样的XML:
<section name="SampleSection">
<item name="ScoredItem1">
<attributes>
<scored data_type="boolean" value="true"/>
</attributes>
</item>
<item name="UnscoredItem1">
<attributes>
<scored data_type="boolean" value="false"/>
</attributes>
</item>
<item key="(3272fbb5:22)" name="ScoredItem2">
<attributes>
<scored data_type="boolean" value="true"/>
</attributes>
</item>
</section>
Run Code Online (Sandbox Code Playgroud)
现在,我知道,使用XSLT,我可以计算具有scored attribute这样的项目:
<xsl:variable name="scoredItems" select="item/attributes/scored"/>
<xsl:value-of select="count($scoredItems)"/>
Run Code Online (Sandbox Code Playgroud)
当然,这将给我一个值3.
假设我只想计算这些项目对于其scored是true.我如何使用XSLT做到这一点?(对于此示例,此值应返回值2.
像这样做:
<xsl:variable name="scoredItems"
select=
"item/attributes/scored[@value='true']"/>
Run Code Online (Sandbox Code Playgroud)