Hi all,
I'm creating a number of fragments to calculate various presence numbers. I'm creating variables from the results of these fragments then doing simple math to give the results.
I'm having an error when trying to add two variables (from the result-tree-fragment) when one variable has no value at all. In the source XML, the criteria returns no matches, so when the two variables are added, it returns NaN. I'm Trying to make a xsl:choose to determine the presence of a null fragment return, but can't seem to get the correct test attribute working.
Here's the XSLT 1.0code:
- <xsl:variable name="SophFemalePTNexusTC">
-
<xsl:for-each-group select="Census/Student
-
[(
-
(Gender='Female') and
-
(Classification='nexus') and
-
(@AdmitTerm='Fall Semester 2008') and
-
(TotCredits/@Load<8) and
-
(TotCredits/@TransferCredits>29.99) and
-
(TotCredits/@TransferCredits<60)
-
)]"
-
group-by="/">
-
<xsl:value-of select="count(current-group())"/>
-
</xsl:for-each-group>
-
</xsl:variable>
-
-
<xsl:variable name="SophFemalePTNexusUG">
-
<xsl:for-each-group select="Census/Student
-
[(
-
(Gender='Female') and
-
(Classification='nexus') and
-
(TotCredits/@Load<8) and
-
(TotCredits/@UG>29.99) and
-
(TotCredits/@UG<60)
-
)]"
-
group-by="/">
-
<xsl:value-of select="count(current-group())"/>
-
</xsl:for-each-group>
-
</xsl:variable>
-
-
<xsl:choose>
- <xsl:when test="boolean($SophFemalePTNexusTC)='1'">
-
<xsl:value-of select="$SophFemalePTNexusUG + 0"/>
-
</xsl:when>
-
<xsl:otherwise>
-
<xsl:value-of select="$SophFemalePTNexusUG + $SophFemalePTNexusTC"/>
-
</xsl:otherwise>
-
</xsl:choose>
-
I highlighted where the error is. In This example, there is no RTF for the variables $SophFemalePTNexusTC. For example, if I do a <Value-of select:$SophFemalePTNexusTC, it will return nothing.
The result of the above code picks the xsl:when, and not the xsl:otherwise as it should if properly testing the presence of a null RTF.
The boolean is the wrong process - as the RTF is not a number or a string (right?) it is not subject to a boolean, count, or number attribute? Any help would be greatly appreciated.