xsl-list
[Top] [All Lists]

Re: [xsl] format negative numbers

2008-04-28 01:55:12
On 28/04/2008, Markus Gamperl <markus(_dot_)gamperl(_at_)gmx(_dot_)at> wrote:
Hi.

 I have a html report with lots of number columns. I want to highlight 
negative numbers in red color.

 I know I could add an if element in every column and check for negative 
numbers. If negative I could add a style attribut to the table cell. Another 
way could be calling a template with parameter which does the formatting task.

 But is there a more simple way to do this? Im also working with the 
format-number function but I didn't find a feature to implement my needs...

 What do you mean?


Using a particular class seems fine, eg in 2.0:

class="{if (. lt 0) then 'neg ' else ''}"

or in 1.0 it would be:

<xsl:attribute name="class">
  <xsl:if test=". &lt; 0">neg </xsl:if>
</xsl:attribute>

(possibly moving the if test outside the attribute if that's the only
class used)

-- 
Andrew Welch
http://andrewjwelch.com
Kernow: http://kernowforsaxon.sf.net/

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>