Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XSL checking integer

Tags:

xslt

How to check the integer value in XSL? I'm using version 1.0

This is what I've tried, but it's not working:

<xsl:variable name="ShowEmailEventId"
     select="com.zoniac.emailevent.NewEmailEventBean/emailEventIdString"/>
<xsl:if test="$ShowEmailEventId !=48">
    <table align="center"
           width="96%"
           border="1"
           style="border-color:#2E73AD;border-collapse:collapse"
           cellspacing="0"
           cellpadding="10">
        <tr>
            <td width="10%"
                style="border-color:#2E73AD;color: black; font: 11px verdana;padding:2px"
                align="left"
                valign="top">
                <b>S.No</b>
            </td>
        </tr>
    </table>
</xsl:if>
like image 280
Adalarasan Sachithanantham Avatar asked Aug 08 '26 23:08

Adalarasan Sachithanantham


1 Answers

This is probably the shortest expression, returning true() iff $x can be used as an integer:

Just use:

floor($x) = $x

The full test will be:

<xsl:if test="floor($x) = $x">
 <!-- $x is an integer -->
</xsl:if>

or

<xsl:when test="floor($x) = $x">
 <!-- $x is an integer -->
</xsl:when>

or

someXPathExpression[floor($x) = $x]
like image 172
Dimitre Novatchev Avatar answered Aug 11 '26 00:08

Dimitre Novatchev