Menu

#8 Capture spanning cells in Word tables

Convenience
closed
5
2014-07-02
2012-07-17
No

Right now the Word2DITA transform does not preserve cells that span either columns or rows. It collapses them into non-spanning cells. Updating the <xsl:template match="w:tc"> template in wordml2simple.xsl to the attached will (as far as I can tell) capture the column spanning information from Word, but further work is needed to capture cells that span rows.</xsl:template>

To capture row spanning cells:
If a cell spans a row, then in its originating cell (<w:tc>), there will be this element: <w:vmerge w:val="restart">
In rows that the cell spans, there will be a <w:tc> tag that has this element: <w:vmerge>
If the cell also spans columns, there will be a repeat of the <w:gridspan> element. </w:gridspan></w:vmerge></w:tc></w:vmerge></w:tc>

Unfortunately, WordML does not explicitly report the number of rows a cell spans. So what needs to happen is that upon finding the starting <w:vmerge> element we need to count the number of subsequent rows that have <w:vmerge> elements until either a new <w:vmerge> element is encountered (which signifies the start of a new rowspanning cell) or a cell is encountered that does not have <w:vmerge>. We also need to keep track of which cell within the row we are working with (i.e., the column number).</w:vmerge></w:vmerge></w:vmerge></w:vmerge>

Then in simple2dita, we need to transform the colspan and rowspan information into DITA's namest, nameend, and morerows. The relevant template in simple2dita is <xsl:template match="rsiwp:td">. Since the simple2dita is an HTML-compliant table, I'm wondering if the best approach is to use the HTML-to-DITA table transform code from the h2d plugin that is in the demo directory of the Open Toolkit. (I'm assuming that would be allowable.) That seems to be a complete conversion from HTML-compliant tables to DITA, so it may save time in the future by not requiring edits to simple2dita transform code when wordml2simple table transform code is edited. We'd of course have to add in the specific code needed for capturing Word styles.</xsl:template>

Discussion

  • Steven Calderwood

     
  • W. Eliot Kimber

    W. Eliot Kimber - 2014-07-02
    • status: open --> closed
    • assigned_to: W. Eliot Kimber
    • Group: --> Convenience
     
  • W. Eliot Kimber

    W. Eliot Kimber - 2014-07-02

    Released in 0.9.19RC12

     

Anonymous
Anonymous

Add attachments
Cancel