I have the following sums that are conditional to Employee_ID being present in my xml
Aside from CF_INT2007_LFP_Pay_Results_TFSA and CF_INT2007_LFP_Pay_Results_Optional_RRSP, the two templates (modeS RRSP and RFSA) are identical.
Does anyone have an idea how to use only one template, but feeding from either CF_INT2007_LFP_Pay_Results_TFSA or CF_INT2007_LFP_Pay_Results_Optional_RRSP within the recursive call to itself?
Code:
<xsl:variable name="sumTFSA">
<xsl:apply-templates select="Report_Entry[1]" mode="TFSA"/>
</xsl:variable>
<xsl:variable name="sumRRSP">
<xsl:apply-templates select="Report_Entry[1]" mode="RRSP"/>
</xsl:variable>
Code:
<xsl:template match="Report_Entry" mode="TFSA">
<xsl:param name="runningTotal" select="number('0')"/>
<xsl:variable name="contributionTFSA">
<xsl:choose>
<xsl:when test="not(Employee_ID)"><xsl:value-of select="number('0')"/>
</xsl:when>
<xsl:otherwise><xsl:value-of select="CF_INT2007_LFP_Pay_Results_TFSA"/></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:choose>
<xsl:when test="following-sibling::Report_Entry[1]">
<xsl:apply-templates select="following-sibling::Report_Entry[1]" mode='TFSA'>
<xsl:with-param name="runningTotal" select="$runningTotal + $contributionTFSA"/>
</xsl:apply-templates>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$runningTotal + $contributionTFSA"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="Report_Entry" mode="RRSP">
<xsl:param name="runningTotal" select="number('0')"/>
<xsl:variable name="contribution">
<xsl:choose>
<xsl:when test="not(Employee_ID)"><xsl:value-of select="number('0')"/>
</xsl:when>
<xsl:otherwise><xsl:value-of select="CF_INT2007_LFP_Pay_Results_Optional_RRSP"/></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:choose>
<xsl:when test="following-sibling::Report_Entry[1]">
<xsl:apply-templates select="following-sibling::Report_Entry[1]" mode='RRSP'>
<xsl:with-param name="runningTotal" select="$runningTotal + $contribution"/>
</xsl:apply-templates>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$runningTotal + $contribution"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
Aside from CF_INT2007_LFP_Pay_Results_TFSA and CF_INT2007_LFP_Pay_Results_Optional_RRSP, the two templates (modeS RRSP and RFSA) are identical.
Does anyone have an idea how to use only one template, but feeding from either CF_INT2007_LFP_Pay_Results_TFSA or CF_INT2007_LFP_Pay_Results_Optional_RRSP within the recursive call to itself?