开发者

XSL checking integer

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>


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]


TO check if a value nameofint is an int... (you are obviously going to want to change the inside of the if condition.

<xsl:template match="CheckInt">
   <xsl:if test="not(string(.) castable as xs:integer)">
    <xsl:text>NOT AN INT: </xsl:text>
    <xsl:value-of select="."/>
  </xsl:if>
 </xsl:template>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜