私はxsltを初めて使用し、次の動作をします。パターン条件のあるノードセットを使用してアイテムをカウントしようとすると、異なる結果が得られます。条件の値を文字列にキャストするかどうかによって、結果は次のように変わります。一部の専門家は、この動作の原因を説明するのに役立ちますか?
<xsl:for-each ....
//there is two area that why we need the position()=1
<xsl:variable name="checkLocation" select="area[position()=1]" />
シナリオA-間違った結果
<xsl:value-of select="count(msxsl:node-set($allItems)//item[area[position()=1] = $checkLocation])"/> will show 10
シナリオB-左側の条件を文字列にキャストした後の正しい結果
<xsl:value-of select="count(msxsl:node-set($allItems)//item[string(area[position()=1]) = $checkLocation])"/> will show show 1