我試圖找到一種方法來計算父節點中相同節點的總和。XSL如何計算相同的節點名稱?
我有這樣的XML代碼:
<course>
<user name="Jack">
<ExerciceNote note="50" />
<Information>The second exercice</Information>
<ExerciceNote note="90" />
</user>
<user name="Peter">
<ExerciceNote note="60" />
<ExerciceNote note="80" />
<Information>The last exercice</Information>
<ExerciceNote note="75" />
</user>
</course>
我想calcultate每個Exercice的總和:
<xsl:template match="course">
<html>
<body>
<p>Student name: <xsl:apply-templates select="user" />
<xsl:value-of select="@name" /> </p>
</body>
</html>
</xsl:template>
<xsl:template match="user">
<xsl:value-of select="@name" />
<xsl:apply-templates select="ExerciceNote" />
</xsl:template>
<xsl:template match="ExerciceNote">
<xsl:value-of select="sum(???)" />
</xsl:template>
我嘗試了很多東西來代替???
我想這樣的結果:
Jack
total = 140
Peter
total = 215
由於採取了幫助,我理解,我只需要留在節點上,並獲得總和!,太棒了! – baronming