我有一个这样的transcript.xml,想计算gpa
<?xml version="1.0" encoding="UTF-8"?>
<transcript>
<courses>
<course>
<code>IK2210</code>
<credits>3</credits>
<grade>A</grade>
</course>
<course>
<code>IB2210</code>
<credits>3</credits>
<grade>A</grade>
</course>
<course>
<code>IB2210</code>
<credits>1</credits>
<grade>C</grade>
</course>
<course>
<code>ID1234</code>
<credits>2</credits>
<grade>B</grade>
</course>
</courses>
</transcript>
我像这样导入了成绩单
<xsl:variable name="transcript" select="document('transcript2.xml')/transcript"/>
我试着这样做
<xsl:value-of select=" (4*(sum($transcript/courses/course/credits[$transcript/courses/course/grade='A'])) + 3*(sum($transcript/courses/course/credits[$transcript/courses/course/grade='B'])) + 2*(sum($transcript/courses/course/credits[$transcript/courses/course/grade='C'])) + 1*(sum($transcript/courses/course/credits[$transcript/courses/course/grade='D']))) div (sum($transcript/courses/course/credits))"/>
但零件
(sum($transcript/courses/course/credits[$transcript/courses/course/grade='A']))
总结所有学分
怎么查条件?谢谢