Re: [xsl] Table formatting challenge

Subject: Re: [xsl] Table formatting challenge
From: David Carlisle <davidc@xxxxxxxxx>
Date: Mon, 16 Jul 2001 13:21:28 +0100
> By "single figures", do you mean row spans less than 10 or something
> else?

yes that (because I store the list of pending spans in a string, and
pull of each one using substring, if you need more, you could use
a delimiter and substring-before to pull apart the string, that's easy
to change once the rest of the logic is right.

Also there's a xsl:message that terminates if the column count gets
above 10, that isn't a real restriction it's just there as your examples
only had four columns, but some versions of the code didn't terminate
the recursion without that trap.

> Anyway, this code doesn't quite seem to work.
details details...

I just posted this to Oliver who also pointed out that it didn't work off
the list (I suspect not because he's scared of correcting me in public,
having done that often enough, but that it would be his turn next if it
transpired my attempt didn't work)




> Hi David,
> 
> have you noticed that the '(***)'-marked lines shouldn't have been
> generated?
> 
> second table:
> > <table border="1">
> >    <tr>
> >       <td>A</td>
> >       <td>B</td>
> >       <td rowspan="3">C</td>
> >       <td rowspan="3">D</td>
> >    </tr>
> >    <tr>
> >       <td rowspan="3">E</td>
> >       <td>F</td>
> >       <td class="auto-generated">.</td>      (***)
> >       <td class="auto-generated">.</td>      (***)
> >    </tr>
> >    <tr>
> >       <td>G</td>
> >       <td class="auto-generated">.</td>      (***)
> >       <td class="auto-generated">.</td>      (***)
> >    </tr>
> >    <tr>
> >       <td>H</td>
> >       <td class="auto-generated">.</td>
> >       <td>I</td>
> >    </tr>
> > </table>
> 

yes that's due to a last minute addition:-)


I noticed that in Norm's last example he didn't want his rows to end early

<table border="1">
<tr>
<td rowspan="3">A</td>
<td class="auto-generated"></td><<<<<<<
<td class="auto-generated"></td>
<td class="auto-generated"></td>

so I added the bit at the end marked

   <xsl:for-each select="/descendant::*[position() &lt; string-length($spans)]">
<xsl:message>
  extra cell
</xsl:message>
<td class="auto-generated">.</td>

but that's wrong, it shouldn't just generate those, it should force the
loop to continue until $spans is empty, so it correctly catches cells
hanging down from above.

(something for Norm to do, he's probably up by now:-)


> Do you still think that functional programming is more natural than 
> procedural programming?

You don't deflect a true believer that easily:-)


David



_____________________________________________________________________
This message has been checked for all known viruses by Star Internet
delivered through the MessageLabs Virus Scanning Service. For further
information visit http://www.star.net.uk/stats.asp or alternatively call
Star Internet for details on the Virus Scanning Service.

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


Current Thread