Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 27th, 2008, 02:14 AM
Registered User
 
Join Date: Aug 2008
Posts: 8
Thanks: 2
Thanked 0 Times in 0 Posts
Send a message via AIM to maikm
Default Filling the gaps of rowspan/colspan sources

Hi again,

consider the following simplified source example, using Saxon B9 for transformation:

Code:
<table>
  <tr>  <td>11</td>    <td>12</td>                    <td>13</td>  </tr>
  <tr>  <td colspan="2">21+22</td>                    <td>23</td>  </tr>
  <tr>  <td>31</td>    <td rowspan="2">32+42</td>     <td>33</td>  </tr>
  <tr>  <td>41</td>                                   <td>43</td>  </tr>
  <tr>  <td colspan="2" rowspan="2">51+52+61+62</td>  <td>53</td>  </tr>
  <tr>                                                <td>63</td>  </tr>
</table>
For my target application, I need to output something for every table cell, including those that are omitted in HTML because of the rowspan/colspan args. Just adding empty <td/> tags in the places where 22, 42, 52, 61 and 62 would be (violating HTML semantics) would be fine for that purpose, so that all rows would have a constant number of td tags.

The colspan part alone was easy, but rowspan is trickier, and the combination of both even more. I tried XPath expressions like
Code:
parent::node()/preceding-sibling::node()/td[position()=$mypos]
to access td tags in previous rows, but I'm somehow stuck thinking further (not that much experience with functional programming).

How would you do that?

Thanks in advance
Maik
 
Old August 27th, 2008, 03:15 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

I'm afraid this one isn't easy - it will take a lot longer than the minute or two I allow myself for giving unpaid help to people.

I think my first approach would be to try to build an unsorted collection of table cells each of the form <cell row="6" col="2"/>, and then sort them by row and then column. When you encounter a rowspan, generate all the relevant cells with their row and column number, and don't bother that they are out of order; they will be sorted into the right place in the second phase.

Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer's Reference
 
Old August 27th, 2008, 03:28 AM
Registered User
 
Join Date: Aug 2008
Posts: 8
Thanks: 2
Thanked 0 Times in 0 Posts
Send a message via AIM to maikm
Default

Hello Michael,

that sounds like a good approach, I'll try that.

Would it be possible for you to do this as paid work if I fail? :)

Maik
 
Old August 27th, 2008, 03:36 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

>Would it be possible for you to do this as paid work if I fail? :)

Sure. Contact me off-list. [email protected]

Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer's Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
Using Rowspan in datagrid bala24 General .NET 2 February 15th, 2008 03:21 AM
Algorithmic problem transformin table with colspan fmilano XSLT 1 June 18th, 2007 02:29 PM
RowSpan tgopal Javascript 6 September 28th, 2004 03:35 AM
ROWSPAN PROBLEM saravananedu HTML Code Clinic 3 July 27th, 2004 03:58 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.