Situation:
Is there an easy way to convert a number that may have a trailing negative sign from my source to one in a standard format? For example, my source data shows 870.00- which must be converted to -870.00 in order to be inserted into a database.
Below is my resulting XSL, but this seems far more complicated than it should need to be.
<PAYMENT_AMOUNT>
<xsl:choose>
<xsl:when test="substring(column4 , string-length(column4 ) , string-length(column4 ) ) = '-'">
<xsl:value-of select="concat('-' , substring(column4 ,0 , string-length(column4 ) ) )"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="column4"/>
</xsl:otherwise>
</xsl:choose>
</PAYMENT_AMOUNT>
Solution:
Please use the XSL below to map a negative number :
<Amount>
<xsl:choose>
<xsl:when test="contains( Amount,'-' ) = 'true'">
<xsl:value-of select="normalize-space( concat('-' , translate(Amount ,'-' ,'' ) ) )"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="Amount"/>
</xsl:otherwise>
</xsl:choose>
</Amount>
Comments
0 comments
Article is closed for comments.