Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Midnight sun issue

Status
Not open for further replies.

graemetic

Programmer
Joined
Oct 27, 2009
Messages
3
Location
GB
Hi - I am having problems with the weather page (XML/XSL/ASP) on a website I manage. The issue is that during daylight saving time, the XSL file does not recognise 00:00 as midnight, so often the forecast will show the sun shining at midnight - which here in the UK it does not.

The relevent bit of XSL is at the bottom of this post. It makes sure that the nighttime graphics show between 17:00 and 07:00. I added "or format-number(@time,'#')&eq;0" to try and resolve the issue, but all that did was cause an error "Error loading XSL file: Reference to undefined entity 'eq'."

Has anyone any idea how I can resolve this please?

Thanks

Graeme
---------------------
<td><img><xsl:attribute name="src">images/<xsl:if test="forecastTime[format-number(@time,'#')&gt;17 or format-number(@time,'#')&lt;7 or format-number(@time,'#')&eq;0]">N</xsl:if><xsl:value-of select="weather"/>.gif</xsl:attribute></img></td>
---------------------
 
[1] I don't think &eq; is recognized entity without some kind of dtd making it defined. In xslt 2.0 there is a value comparison operator 'eq'. But I think, for the moment, xml/xsl/asp, xslt 1.0 is still prevailing.

[1.1] In xslt 1.0, comparison to equal is simply "=".

[2] I am not sure the whole business of format-number() make much sense for xs:time value. I would guess, even no midnight issue, the format-number() use should have failed already, no?
 
Hi tsuji - Thanks for your response. In answer to your points:
1.1 - I tried using "=" before I tried "&eq;". It didn't resolve the issue, but it didn't cause an error either.
2.0 - The format-number() coding concept works perfectly. It successfully adds the prefix "N" to the gif file names pulled into the site after 17:00 and before 07:00 to reflect the fact that it is nighttime and the moon is in the sky rather than the sun.
Any other thoughts would be appreciated.

Graeme
 
[1.1.1] If you have doubt the "standard" you are working with, it is not a "standard".

[2.1] format-number() works perfectly? Only if you have some bizarrie of @time other than the xs:time data-type. It is not shown: I cannot comment.

[2.2] format-number('12:00:00','#') is NaN. If NaN is compared with 17 or 7 or whatever, it results in false. So in one period or another which relies on the false of all comparison, it would give the apparent of working.

[2.3] Suppose you really mean it work, then try format-number() with the format '0':
[tt] format-number(@time,'0')[/tt]
[2.3.1] Format '#' results empty for @time being '0', and format '0' results in 0. That may then have a bearing on midnight '00:00:00'.
 
Thanks again, but format-number(@time,'0') does not work either.

You can see the "midnight sun" effect at:
In case it helps, I've pasted a larger section of the XSL file below. This may help explain where @time comes from (it is a field read from an xml file).
---------------------
<xsl:stylesheet xmlns:xsl=" version="1.0">

<xsl:output method="html" indent="yes" omit-xml-declaration="yes"/>

<xsl:template match="forecastData"><tr>
<td><xsl:attribute name="class"><xsl:choose><xsl:when test="forecastTime/@date">date</xsl:when><xsl:otherwise>noborder</xsl:otherwise></xsl:choose></xsl:attribute>
<xsl:value-of select="forecastTime/@date"/></td>

<td class="time"><xsl:value-of select="translate(format-number(forecastTime/@time,'00.00'),'.',':')"/></td>

<td><img><xsl:attribute name="src">images/<xsl:if test="forecastTime[format-number(@time,'#')&gt;17 or format-number(@time,'#')&lt;7 or format-number(@time,'0')]">N</xsl:if><xsl:value-of select="weather"/>.gif</xsl:attribute></img></td>
--------------------------
 
What then is @time? How does it look like? I am not saying format '0' will work. I just point out it is different from the format '#' if by chance '0' string is passed to it. I am not convinced format-number() perform correctly on xs:time data-type. So what is @time?

Also I see forecastTime. One time, it is forecastTime/@time. So time is an attribute of forecastTime node. Then at the other place, it appears to be evaluated to be forecastTime[true] or forecastTime[false]. It does not look right.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top