したがって、基本的にXMLノードをループする関数が必要であり、条件がtrueの場合、その値を変数に追加します。ソーシャル投稿を集計しているので、フィードに含まれる各ソーシャル投稿の数を数える必要があります。これが私のXMLです:
<feed>
<channel>
<sources>
<source>
<name>Facebook</name>
<count>3</count>
</source>
<source>
<name>Twitter</name>
<count>2</count>
</source>
<source>
<name>Twitter</name>
<count>8</count>
</source>
</sources>
</channel>
</feed>
キャッチは同じソースが複数回表示される可能性があるため、それらを合計する必要があります。したがって、上記のXMLのTwitterカウントは10が必要になります。これが私が今のところいるところです:
<xsl:variable name="num_tw">
<xsl:for-each select="feed/channel/sources/source">
<xsl:choose>
<xsl:when test="name, 'twitter')">
<xsl:value-of select="count"/>
</xsl:when>
<xsl:otherwise></xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:variable>
<xsl:variable name="num_fb">
<xsl:for-each select="feed/channel/sources/source">
<xsl:choose>
<xsl:when test="name, 'facebook')">
<xsl:value-of select="count"/>
</xsl:when>
<xsl:otherwise></xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:variable>
Twitterフィードが2つある場合、数字を並べて「10」ではなく「28」を出力するため、これは機能しません。どんな助けでも大歓迎です!