OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

docbook-apps message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]


Subject: Re: [docbook-apps] Problem with tables and roundtrip to WordML


Incidentally, I did get tables working fairly well without too much work, though I can't vouch much for how I did it, due to my limited XSL knowledge.

In dbk2wp.xsl, my changes were:
- implement an 'align' parameter for <para> and <simpara> elements to be passed to make-paragraph
- changed the <entry> template to recognize the align= attribute and pass it through the call to apply-templates for the cell contents
- changed the <table> template to pass a role= attribute to make-table as the 'style' parameter

In dbk2wordml.xsl, my changes were:
- in make-paragraph, use 'align' to generate a paragraph alignment element
- in make-table, use 'style' parameter to select a table style

As straight bug fixes, there are several spots where <simpara> elements are not handled properly (i.e., in <entry> and <listitem>), so I made trivial fixes to those templates.  There also seem to be a couple spots in dbk2wp.xsl where apply-templates is missing a mode='doc.body' attribute (in the templates for admonitions and for varlistentry).  Without that, I get errors like "simpara encountered in note, but no template matches", or "varlistentry encountered in variablelist, but no template matches". 

I'm actually working with stylesheets that were modified to generate Word 2007 OOXML, that I found here:

http://www.brians-brain.org/projects/org-to-docx.html

There seems to be little development activity on these stylesheets, so I'm not sure how to proceed from here.  Some of my changes would apply easily to the official distribution, though I have not tried to implement the reverse transformations since I don't have a need for those.  Are patches welcome?

-- Dave



On Mon, Feb 28, 2011 at 12:56 PM, Steve Ball <Steve.Ball@explain.com.au> wrote:
Hi David,

Although I have not yet checked, I believe the problem is that the content of the cells is not in a <para>. That is, your DocBook should look like:

<thead><row><entry><para>a1</para></entry><entry><para>a2</para></entry></row></thead>
    <tbody><row><entry><para>b1</para></entry><entry><para>b2</para></entry></row></tbody>

As for being able to produce professional looking tables, there is some work to do in setting up table column widths and borders properly. However, YMMV.

Cheers,
Steve Ball

On 01/03/2011, at 7:16 AM, David Hinds wrote:

I'm trying to convert a very simple docbook file to WordML using the roundtrip XSL stylesheets.  I'm having trouble with tables: all cell contents are missing after the conversion.

Here is my input document:

<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/doc\
book/xml/4.5/docbookx.dtd">
<article lang="en">
<table frame='all'><title>Sample Table</title>
  <tgroup cols="2">
    <colspec colname='c1'/><colspec colname='c2'/>
    <thead><row><entry>a1</entry><entry>a2</entry></row></thead>
    <tbody><row><entry>b1</entry><entry>b2</entry></row></tbody>
  </tgroup>
</table>
</article>

This renders ok in HTML with:

xsltproc --path .../docbook-xsl/html -o test.html \
  docbook.xsl test.xml

but with this:

xsltproc --path .../docbook-xsl/roundtrip -o test.wml \
  --stringparam wordml.template template.xml \
  dbk2wordml.xsl test2.xml

the cells in the resulting table are all empty, i.e. the resulting WordML looks like:

            <w:tc>
              <w:tcPr>
                <w:tcW w:w="" w:type="dxa"/>
              </w:tcPr>
              <w:p/>
            </w:tc>

I get the same result with either xsltproc or saxon.  I am using docbook-xsl-1.76.1.

My long term goal is to be able to programmatically generate reports as templated, styled Word documents from asciidoc source files, with docbook as an intermediate format, in a linux environment.  I need relatively few features: headers, body text, simple bullet lists, PNG images, and reasonably professional-looking tables (where that means I need control over column alignment and borders). 

-- Dave






[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]