[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Grouping with XSLT

Subject: Re: Grouping with XSLT
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Fri, 2 Nov 2001 11:15:47 +0000
Re:  Grouping with XSLT
Hi Michael,

> I get the table header after generating the diary. Do I
> misunderstand something in calling the template ?

I don't think so, although you're probably misunderstanding what it's
providing. Assuming that you haven't changed the template, you'll get
something like:

  <table>
    <tr>...heading...</tr>
    <h2>09:00</h2>
    ...
    <h2>10:00</h2>
    ...
  </table>

When you put HTML in a table element by outside a row or cell, then it
appears before the table.

> - I also want to have the actual time and activity in a table; is
> there a trick in how to put some table row generation into a
> recursive function ?

It's not particularly tricky. Rather than creating h2 elements,
generate tr elements with:

<xsl:template name="createDiary">
  <xsl:param name="hour" select="9" />
  <tr>
    <th><xsl:value-of select="format-number($hour, '00')" />:00</th>
    ...
  </tr>
  <xsl:if test="$hour &lt; 18">
    <xsl:call-template name="createDiary">
      <xsl:with-param name="hour" select="$hour + 1" />
    </xsl:call-template>
  </xsl:if>
</xsl:template>

> - for each hour I need to check if there is an activity ongoing
> where the start time is < than the actual hour; i.e. if an activity
> start at 9:15 and runs for 3 hours it should be listed in the 10:00
> and 11:00 row. Is it at all possible to use the 'key' to get the
> values of preceeding nodes for comparison ?

Well, a key can only get hold of an activity if there is a way of
assigning creating a key value for every possible value it could take.
You *could* do this with a series of keys that went:

<xsl:key name="dates" match="date" use="number(starth)" />
<xsl:key name="dates" match="date[starth + 1 &lt; endh]"
         use="starth + 1" />
<xsl:key name="dates" match="date[starth + 2 &lt; endh]"
         use="starth + 2" />
...

but it's likely to be a bit tedious unless the maximum gap between the
start and end hour is small. (This would be easier with user-defined
functions that would allow you to generate a node set of the possible
hours that you could use for the key value.)

Otherwise, you can get all the activities that are ongoing in a
particular hour with:

  /dates/date[starth &lt;= $hour and
              (endh > $hour or
               (endh = $hour and endm = 0))]

I hope that helps,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.