[thelist] xml transformation question
John.Bedard at ngc.com
John.Bedard at ngc.com
Wed Nov 26 16:02:34 CST 2003
You can do it with a transformation. There's probably a better way to do this with a "real" scripting language...
<img>
<xsl:variable name="currtemp" select="/city/tempuratures/fahrenheit" />
<xsl:choose>
<xsl:when test="$currtemp > 0 and $currtemp <= 10">
<xsl:attribute name="src">/pathtoimage/singledigits.gif</xsl:attribute>
</xsl:when>
<xsl:when test="$currtemp > 10 and $currtemp <= 20">
<xsl:attribute name="src">/pathtoimage/teens.gif</xsl:attribute>
</xsl:when>
<xsl:when test="$currtemp > 20 and $currtemp <= 30">
<xsl:attribute name="src">/pathtoimage/twenties.gif</xsl:attribute>
</xsl:when>
[...etc. through the tempurature range...]
<xsl:otherwise>
<xsl:attribute name="src">/pathtoimage/notavailable.gif</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
</img>
Disclaimer: Untested, but I've been working with this stuff for a few months.
John
-----Original Message-----
From: Tom Dell'Aringa [mailto:pixelmech at yahoo.com]
Sent: Wednesday, November 26, 2003 1:01 PM
To: thelist at lists.evolt.org
Subject: [thelist] xml transformation question
Hi,
I have an XML file I want to parse, and based on some data in that
file (weather info) display an appropriate image. This idea was
stolen from a friend of mine (you know who you are) who is doing
something like this only in much more detail. I want mine fairly
simple.
Anyway, the XML file is here:
http://weather.boygenius.com/illinois-ohare.xml
Basically, before my page loads, I want to look at the XML file, then
decide (I suppose with PHP) based on temperature, etc which of maybe
10 pictures to show.
I know the basics of XML and the concepts of XSLT but that's it. Not
sure where to start.
Thanks
Tom
=====
http://www.pixelmech.com/ :: Web Development Services
http://www.DMXzone.com/ :: JavaScript Author / Every Friday!
http://www.thywordistruth.net/ :: Eternal Life
[Those who say that I am finished, and am through, will have to run over my dead body to beat me...]
--
* * Please support the community that supports you. * *
http://evolt.org/help_support_evolt/
For unsubscribe and other options, including the Tip Harvester
and archives of thelist go to: http://lists.evolt.org
Workers of the Web, evolt !
More information about the thelist
mailing list