[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]
Subject: Re: [docbook-apps] Setting HTML Colwidths
You can thank Norm Walsh for writing the stylesheets with enough subroutine facilities that you can do what you want pretty easily. There is a template named "colspec.colwidth" that takes a column name as a parameter and returns the width specification from the colspec element for that column. You will need to customize the match="entry|entrytbl" template in xhtml/table.xsl (it is a big one). The line <xsl:element name="{$cellgi}"> starts the <td> or <th> element, and that is followed by several <xsl:attribute> steps. You can add one like this: <xsl:variable name="colwidth"> <xsl:call-template name="colspec.colwidth"> <xsl:with-param name="colname" select="@colname"/> </xsl:call-template> </xsl:variable> <xsl:if test="$colwidth != ''"> <xsl:attribute name="style"> <xsl:text>width: </xsl:text> <xsl:value-of select="$colwidth"/> <xsl:text>;</xsl:text> </xsl:attribute> </xsl:if> This assumes your entry elements all have the correct colname attribute on them. That's a lot of trouble, but that's what your example showed. If you don't have that attribute, then you can use the $entry.colnum variable that is computed earlier in the template to derive the column name. Bob Stayton Sagehill Enterprises bobs@sagehill.net ----- Original Message ----- From: "Phil Weston" <phil700@xmsg.com> To: <docbook-apps@lists.oasis-open.org> Sent: Tuesday, February 03, 2004 12:52 PM Subject: [docbook-apps] Setting HTML Colwidths > Hiya > > I'm working on a method of importing HTML into a Word document and have come across a problem with importing a table. > > Given a Docbook table of the form: > > <table> > <tgroup> > <colspec colnum="1" colname="col1" colwidth="30pt"/> > <colspec colnum="2" colname="col2" colwidth="150pt"/> > <tbody> > <row> > <entry colname="col1"><para>MyFirstCol</para></entry> > <entry colname="col2"><para>My2ndCol</para></entry> > </row> > </tbody> > </tgroup> > </table> > > Using the XHTML Stylesheets with my own customisation layers (with no table customisations yet) gives: > > <table> > <colgroup> > <col width="30pt" align="left"> > <col width="150pt" align="left"> > </colgroup> > <tbody> > <tr valign="top"> > <td valign="top"><p>MyFirstCol</p></td> > <td valign="top"><p>My2ndCol</p></td> > </tr> > </tbody> > </table> > > Viewing with a Browser works fine as you'd expect and even opening in Word gives the impression that it's fine too. However the problem is that Word doesn't fix the Column widths - adding more text to "col1" for example, stretches the column width to suite the new text. > > It seems I can force Word to harden the column widths by setting a style attribute on every <td> and <th> (eg: <td valign="top" style="width:30.0pt;">). > > Can anyone help with the XSLT required to do this? I'm having difficulty understanding how I can track which <entry> I'm processing and therefore which colspec.colwidth I need... > > Cheers > > Phil > > To unsubscribe from this list, send a post to docbook-apps-unsubscribe@lists.oasis-open.org, or visit http://www.oasis-open.org/mlmanage/. > > >
[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]