Table import in DITA format?.

Post here questions and problems related to editing and publishing DITA content.
Radu
Posts: 8992
Joined: Fri Jul 09, 2004 5:18 pm

Re: Table import in DITA format?.

Post by Radu »

Hi,

We have an add-on for Oxygen which can convert Excel to DITA tables:

https://github.com/oxygenxml/oxygen-resources-converter

We plan to improve it to also support import from CSV files but we have not yet managed to find the time for this. If you can export all your files to Excel then you could use our add-on.
Otherwise, indeed a custom XSLT stylesheet could be created to convert between the exported XML format and DITA. The XSLT would probably need to look something like:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    exclude-result-prefixes="xs"
    version="2.0">
    
    <xsl:output indent="yes"/>
    
    <xsl:template match="node() | @*">
        <xsl:copy>
            <xsl:apply-templates select="node() | @*"/>
        </xsl:copy>
    </xsl:template>
    
    <xsl:template match="row/*">
        <entry>
            <xsl:apply-templates/>åß
        </entry>
    </xsl:template>
    
    <xsl:template match="row">
        <row>
            <xsl:apply-templates/>
        </row>
    </xsl:template>
    
    <xsl:template match="root">
        <table>
            <tgroup>
               <xsl:attribute name="cols">
                   <xsl:value-of select="(//row)[1]/count(*)"/>
               </xsl:attribute>
                <thead>
                    <xsl:apply-templates select="(//row)[1]"/>
                </thead>
                <tbody>
                    <xsl:apply-templates select="(//row)[not(position() = 1)]"/>
                </tbody>
            </tgroup>
        </table>
    </xsl:template>
</xsl:stylesheet>
Another more hidden workaround would be to open the exported XML document and switch to the "Grid" editing mode, expand in the Grid mode until you see the table-like representation of the rows, from that table select all cells but without selecting the row numbers, copy and then paste in a DITA topic opened in the Author visual mode. Oxygen should convert the table to a DITA table but it will not properly mark the first row as a header row. You can do that later using the "Table Properties" action.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com