mercredi 7 août 2019

XSL "when" test less-than

A "choose when test" construct in XSL is not behaving the way I think it should. Actually, it doesn't appear to be doing anything.

The environment is Workday Studio. I'm making a change to a program that has been running every night for months. The constructs in this code are very similar to other parts of the code, which is partly why this is baffling.

<xsl:variable name="CC_Fee_Calc">
    <xsl:value-of select="number($value_from_salesforce) * number($CreditCard_RecoveryFee_Percent) * 0.01"/>
</xsl:variable>
<xsl:variable name="CC_Fee_IsZero">
    <xsl:choose>
        <xsl:when test="number($CC_Fee_Calc) &lt; 0.0">
            <xsl:value-of select="Y"/> 
        </xsl:when>
        <xsl:otherwise>
            <xsl:value-of select="N"/> 
        </xsl:otherwise>
    </xsl:choose>
</xsl:variable> 

<CC_Fee_Calc><xsl:value-of select="$CC_Fee_Calc"/></CC_Fee_Calc>
<CC_Fee_Zero><xsl:value-of select="$CC_Fee_IsZero"/></CC_Fee_Zero>

Note that the html version of the less-than sign '<' (in line 6) is necessary due to the XML nature of the XSL. The same thing works fine elsewhere in the code.

The last two lines exist only for displaying the contents of the variables. They create this output in the log (for differing input data):

<CC_Fee_Calc>150.432</CC_Fee_Calc>
<CC_Fee_Zero/>

<CC_Fee_Calc>-0.632</CC_Fee_Calc>
<CC_Fee_Zero/>

<CC_Fee_Calc>-1</CC_Fee_Calc>
<CC_Fee_Zero/>

The values in the CC_Fee_Calc field are correct. But for CC_Fee_Zero, it is as if the variable is merely getting defined, and not populated. I'm expecting N for the first example, and Y for the other two.

I've obviously got some bone-head error in my code that I can't see. XSL in this environment is quite unforgiving. Thanks in advance.

Aucun commentaire:

Enregistrer un commentaire