xsl-list
[Top] [All Lists]

Re: [xsl] Help With Homework: HTML Tables to CALS

2020-01-23 11:44:20
I did not consider accumulators, although it makes sense that an iterator 
approach would work since that naturally provides for updating a variable.

Interestingly, I went over my failing code and simply added explicit types to 
all the parameters and variables (it reflected the best of XSLT 1 practice) and 
the bug went away, so there's that.

Cheers,

E.

--
Eliot Kimber
http://contrext.com
 

On 1/23/20, 11:10 AM, "John Lumley john(_at_)saxonica(_dot_)com" 
<xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com> wrote:

    Eliot,
    
    I can’t answer with specifics as I’m far from my codebase and will be for a 
couple of weeks, but I did some investigation on checking CALS row/column span 
interferences with XSLT3 a couple of years ago. One promising technique IIRC 
was to use one or more array-valued accumulators to track the ‘wave front’ of 
cell occupancies across the definitional tree. Try thinking along those lines.
    
    John
    
    Sent from my iPad
    
    > On 23 Jan 2020, at 15:30, Eliot Kimber ekimber(_at_)contrext(_dot_)com 
<xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com> wrote:
    > 
    > I have XSLT 1-style code that converts HTML tables to CALS tables. I 
discovered that this code fails for certain patterns of HTML tables in that it 
miscalculates column spans in the face of row spans earlier in the table. It 
doesn't fail for all tables, just specific ones (which is why we didn't notice 
this bug earlier). I haven't been able to determine the cause of the bug in the 
short time I've had to debug it (found the bug in the course of trying to 
prepare a rush publishing job that has about 50 complex tables in it, of 
course).
    > 
    > Rather than try to debug and fix the XSLT 1 solution it seemed easier and 
better to re-implement the processing using XSLT 3 and I took a stab at doing 
it using arrays last night, but quickly got bogged down in my own lack of 
facility with such things. The procedural solution in i.e., Java, would be 
easy: just populate the 2x2 matrix that represents the table grid to reflect 
row and column spans as you process the table cells left-to-right and top to 
bottom, using cells projected from earlier rows to determine the starting 
column of cells in subsequent rows that get pushed over by row-spanning cells.
    > 
    > However, I couldn't quickly see how to do this using arrays or maps in 
XSLT 3--the immutability of arrays and thus the coding patterns that take 
existing arrays or maps and return new ones threw me and my feeble brain just 
wasn't landing on the right algorithmic pattern.
    > 
    > I know there must be a general pattern for this type of processing but 
none of the examples I could find were helpful.
    > 
    > So my request: can someone help me with this challenge and outline how to 
solve this kind of problem where you take as input an HTML table where any cell 
may span two or more columns and two or more rows and produce a 2x2 array 
representing the table's grid, where every grid cell reflects the HTML table 
cell that covers it.
    > 
    > From that array it's then easy to determine what the CALS result should 
be (where CALS represents column spans by naming the start and end columns the 
cell spans).
    > 
    > Thanks,
    > 
    > Eliot
    > --
    > Eliot Kimber
    > http://contrext.com
    > 
    > 
    
    
    
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--

<Prev in Thread] Current Thread [Next in Thread>