Subject: Re: [xsl] Grouping with XSLT From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx> Date: Fri, 2 Nov 2001 11:15:47 +0000 |
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 < 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 < endh]" use="starth + 1" /> <xsl:key name="dates" match="date[starth + 2 < 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 <= $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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: Re: [xsl] Grouping with XSLT, Michael Geiling | Thread | [xsl] How to program automatical re, stig . garberg |
Re: [xsl] dynamic # of columns and , Cristobal Galiano Fe | Date | [xsl] How to program automatical re, Mark Nahabedian |
Month |