Binoop
Binoop

Reputation: 171

Remove values after point

I want to Remove the zeros or any other values after point(eg 12.000000000000). I am using xslt code .my code is like

<xsl:if test="value!= ''">
 <tr>
 <td>
 value
 </td>
 <td>
 <xsl:value-of select="value"/>
  </td>
 </tr>
 </xsl:if>

how can I achive this?

Upvotes: 3

Views: 1129

Answers (3)

Peter
Peter

Reputation: 1796

You can use the format-number function:

<xsl:value-of select="format-number(value,'#')"/>

Refer to: http://www.w3.org/TR/xslt/#format-number

Upvotes: 1

Dimitre Novatchev
Dimitre Novatchev

Reputation: 243479

Just use:

substring-before(concat(value, '.'), '.')

This works for any value -- not just a number. The result is correct even if value doesn't contain any dot character.

Upvotes: 0

Gurmeet
Gurmeet

Reputation: 3314

Use Number formatting as:
<xsl:if test="value!= ''">
 <tr>
  <td>
    value
  </td>
  <td>
   <xsl:value-of select="format-number(value,'0')"/>
  </td>
 </tr>
</xsl:if>

Upvotes: 3

Related Questions