XSLTの表示がややこしい
グループごとの集計のメモ
<root> <node category="A"> <counter>3</counter> </node> <node category="A"> <counter>1</counter> </node> <node category="B"> <counter>5</counter> </node> </root>
<xsl:template name="groupsum"> <xsl:param name="group" /> <xsl:value-of select="$group" /> : <xsl:value-of select="sum(/path/node/counter[parent::node/@group = $group])" /> <br /> </xsl:template> <xsl:template match="sum"> <xsl:for-each select="node"> <xsl:variable name="category" select="@category" /> <xsl:if test="not(preceding-sibling::node[@category = $category])"> <xsl:call-template name="groupsum"> <xsl:with-param name="group" select="$category" /> </xsl:call-template> </xsl:if> <xsl:for-each> </xsl:template>
例えば雑誌の価格の合計はsum()を使った例が色々載ってるけれど、あるグループに分けたものはなかなか例題が無い。
そもそもこういう処理はしない方がいいのかな。