• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 307
  • Last Modified:

How to parse minutes from time in XSL & compare values?

I'm using XSL to generate a web page with formatted data.  my XML response retuns a field with a value of HH:MM:SS.  I want to check to see if the minute value is >2 and change a table background color based on the result of this test.

Let's say the xml loks like this:
<STATS>
<WAITTIME>00:03:29</WAITTIME>
</STATS>

How can I format XSL to read minute value, compare to see if >2  ( I can take care of setting class attribute to change background color once I get minute value)
0
juliemcnichols
Asked:
juliemcnichols
1 Solution
 
Gurvinder Pal SinghCommented:
0
 
Geert BormansCommented:
I think you need a construct like this
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="STATS">
    <table>
        <xsl:attribute name="bgcolor">
            <xsl:choose>
                <xsl:when test="number(substring-before(substring-after(WAITTIME, ':'), ':')) > 2">
                    <xsl:text>red</xsl:text>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:text>blue</xsl:text>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:attribute>
    </table>
    
</xsl:template>
</xsl:stylesheet>

Open in new window

0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now