On 01/11/2007, Glen Mazza <glen(_dot_)mazza(_at_)gmail(_dot_)com> wrote:
Hello, the XML below is a sharply simplified version of Memphis weather
data available from the National Weather Service's SOAP web service[1].
<dwml version="1.0">
<data>
<time-layout time-coordinate="local" summarization="none">
<layout-key>k-p24h-n7-1</layout-key>
<start-valid-time period-name="Tomorrow"/> <!-- Thursday -->
<start-valid-time period-name="Friday"/>
<start-valid-time period-name="Saturday"/>
<start-valid-time period-name="Sunday"/>
<start-valid-time period-name="Monday"/>
<start-valid-time period-name="Tuesday"/>
<start-valid-time period-name="Wednesday"/>
</time-layout>
<time-layout time-coordinate="local" summarization="none">
<layout-key>k-p24h-n7-2</layout-key>
<start-valid-time period-name="Tonight"/> <--- Wed. night -->
<start-valid-time period-name="Tomorrow Night/>
<start-valid-time period-name="Friday Night"/>
<start-valid-time period-name="Saturday Night"/>
<start-valid-time period-name="Sunday Night"/>
<start-valid-time period-name="Monday Night"/>
<start-valid-time period-name="Tuesday Night"/>
</time-layout>
<parameters applicable-location="point1">
<temperature type="maximum" units="Fahrenheit"
time-layout="k-p24h-n7-1">
<name>Daily Maximum Temperature</name>
<value>65</value>
<value>66</value>
<value>68</value>
<value>71</value>
<value>72</value>
<value>63</value>
<value>60</value>
</temperature>
<temperature type="minimum" units="Fahrenheit"
time-layout="k-p24h-n7-2">
<name>Daily Minimum Temperature</name>
<value>55</value>
<value>44</value>
<value>44</value>
<value>46</value>
<value>50</value>
<value>49</value>
<value>41</value>
</temperature>
</parameters>
</data>
</dwml>
With this data, I would like to create a simple listing as follows:
Daily Maximum Temperatures:
-----------------------
Tomorrow: 65
Friday: 66
Saturday: 68
...
Daily Minimum Temperatures:
------------------------
Tonight: 55
Tomorrow Night: 44
Friday Night: 44
...
Note that, in the XML data, the blocks of time-layouts are tied to the
Max. and Min. temps below via the layout-key element / time-layout
attribute combination.
I guess my questions are
(1) how can I tie the time-layout elements and temperature elements
together using XSLT 1.0 using the layout-key
Either do it using =, or just use a key:
<xsl:key name="temperature-by-time-layout" match="temperature"
use="@time-layout"/>
with:
key('temperature-by-time-layout", layout-key)
(when the context node is <time-layout>)
(2) how can I tie each period-name to its corresponding position with
the temperatures that it is associated with
use position()
In other words, how can I create my table above?
It's poor quality XML really to rely on position of elements to match
them up, but it's perfectly possible and straightforward to do what
you need with XSLT 1.0.
cheers
--
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>
--~--