XSLT - if first element of splitting by empty space > 0, show empty cell



In my xml, the column where position()=3 can have these kind of values:



0.00 asg
0,34 dgfg
16.34 assfsf
334,77 sfsdf


So basicaly it has a float number with 2 decimals, an empty space and a string. WHat I need to do is this: if the number is 0 (so 0, 0.00 or 0,00) then show an empty cell. If it's larger than 0, don't change anything.


Here's what I tried:



<xsl:template match="cell[position()=3]" priority="7">
<xsl:param name="text" select="."/>
<xsl:variable name="newtext" select="concat(normalize-space($text), ' ')" />
<xsl:variable name="perValue" select="substring-before($newtext, ' ')" />
<xsl:variable name="perInt" select='format-number($perValue, "#")'/>
<id><xsl:value-of select="perInt" /></id>
<xsl:choose>
<xsl:when test="perInt='0'">
<td style="border:1px solid #d6d6d6;">
<div>
...
</div>
</td>
</xsl:when>
</xsl:choose>
</xsl:template>


But it doesnt work. The value of the column is 0.00 sdfdf and it is shown. When the value is >0 it works, the correct value is shown.


No comments:

Post a Comment