2013-06-05 120 views
0

我想計算一些節點的總和。學習者將有1或更多的學習目標,並且我需要知道學習者學習目標的GLH節點的總數。XSL節點之和

這是一些示例XML。

<Learner> 
<LearnRefNumber>422</LearnRefNumber>   
<FamilyName>John</FamilyName> 
<GivenNames>Smith</GivenNames> 
<LearningDelivery> 
    <LearnAimRef>zilsk14a</LearnAimRef> 
    <AimType>4</AimType> 
    <AimSeqNumber>1</AimSeqNumber> 
    <GLH>2775</GLH> 
</LearningDelivery> 
<LearningDelivery> 
    <LearnAimRef>zilsk14b</LearnAimRef> 
    <AimType>4</AimType> 
    <AimSeqNumber>2</AimSeqNumber> 
    <GLH>2500</GLH> 
</LearningDelivery> 
</Learner> 

這是我的XSL。學習目標的數量工作正常,但我正在努力整理GLH。

<xsl:for-each select="t:Learner"> 
<div class="learner">    
    <xsl:variable name="LearningAims" select="count(t:LearningDelivery)" /> 
    <xsl:variable name="LearnerGLH" select="sum(t:LearningDelivery/GLH)" /> 

    <table> 
     <tr> 
      <th>Learner Ref</th> 
      <th>Learning Aims</th> 
      <th>Total GLH</th> 
     </tr> 

     <tr> 
      <td> 
      <xsl:value-of select="t:LearnRefNumber" /> 
      </td> 

      <td> 
      <xsl:value-of select="$LearningAims" /> 
      </td> 

      <td> 
      <xsl:value-of select="$LearnerGLH" /> 
      </td> 
     </tr> 
    </table> 
</div> 

請幫助。非常感謝

回答

0

您正在編寫sum(t:LearningDelivery/GLH),但在輸入XML中,LearningDelivery和GLH元素位於相同的命名空間中。你想要sum(t:LearningDelivery/t:GLH)