Subject: [xsl] Table Proportional Column Width From: siarom egrub <egrubs@xxxxxxxxx> Date: Sun, 22 Oct 2006 23:14:23 -0700 (PDT) |
Hi all, I am trying to get proportional column widths to work in XSL for table PDF output. The table cells are displaying with equal dimensions, even though the colwidth are not equal values and the text isn't wrapping. This causes text overflow into other cells. How can I get the colwidth attribute values in colspec convert/output as proportional-column-width in fo:table-column? Please see my sample XML and XSL below. I certainly hope my question is comprehensible. I will try to provide more details if needed. I really appreciate your help. Thanks in advance! Regards S. Egrub <table colsep="1" frame="all" rowsep="1"> <title>References</title> <tgroup cols="4" colsep="1" rowsep="1"> <colspec align="center" colname="col1" colnum="1" colwidth="1.5*"/> <colspec align="center" colname="col2" colnum="2" colwidth="3*"/> <colspec align="center" colname="col3" colnum="3" colwidth="4*"/> <colspec align="center" colname="col4" colnum="4" colwidth="3*"/> <thead> <row> <entry align="center"> <para>INTERVAL</para> </entry> <entry align="center"> <para>SAMPLE</para> </entry> <entry align="center"> <para>CONVENTIONAL</para> </entry> <entry align="center"> <para>UNITS</para> </entry> </row> </thead> <tbody> <row> <entry morerows="5" valign="middle"> <para>Literature</para> </entry> <entry> <para>Serum</para> </entry> <entry> <para>10 to 25</para> </entry> <entry> <para>17.5 to 44.8</para> </entry> </row> </tbody> </tgroup> </table> <xsl:template match="table"> <fo:block text-align="center" space-before="3mm" space-after="2.25mm" font-size="8pt" keep-together="always"> <fo:block text-align="left" space-after="1mm" font-weight="bold"> <xsl:apply-templates select="title"/> </fo:block> <xsl:apply-templates select="tgroup"/> </fo:block> <!--Display footnotes which are referenced in tables--> <fo:block space-before.optimum="0.75pt" space-after.optimum="6pt" font-size="6.5pt"> <xsl:if test="descendant::entry/para/footnote"> <xsl:value-of select="descendant::entry/para/footnote/@label"/>   <xsl:value-of select="descendant::entry/para/footnote"/> </xsl:if> </fo:block> </xsl:template> <xsl:template match="tgroup"> <xsl:choose> <xsl:when test="ancestor::table/@frame='all'"> <fo:table border="1pt solid black"> <fo:table-header> <fo:table-row line-height="12pt" font-size="8pt" font-weight="bold"> <fo:table-cell border-right-style="solid" border-bottom-style="solid" border-width="1pt" padding-start="4pt" padding-top="3pt" padding-bottom="3pt" display-align="before"> <xsl:apply-templates select="colspec"/></fo:table-cell> </fo:table-row> </fo:table-header> <xsl:apply-templates select="thead"/> <xsl:apply-templates select="tbody"/> </fo:table> </xsl:when> <xsl:when test="ancestor::table/@frame='none'"> <fo:table> <fo:table-header> <fo:table-row line-height="12pt" font-size="8pt" font-weight="bold"> <xsl:apply-templates select="colspec"/> </fo:table-row> </fo:table-header> <xsl:apply-templates select="thead"/> <xsl:apply-templates select="tbody"/> </fo:table> </xsl:when> </xsl:choose> </xsl:template> <xsl:template match="colspec"> <fo:table-column><!-- <fo:table-cell border-right-style="solid" border-bottom-style="solid" border-width="1pt" padding-start="4pt" padding-top="3pt" padding-bottom="3pt" display-align="before"></fo:table-cell>--> <xsl:attribute name="column-number"> <xsl:number count="colspec"/> </xsl:attribute> <xsl:attribute name="column-width"> <xsl:call-template name="calc.column.width"> <xsl:with-param name="colwidth"> <xsl:value-of select="@colwidth"/> </xsl:with-param> </xsl:call-template> </xsl:attribute> </fo:table-column> </xsl:template> <xsl:template match="thead"> <fo:table-body font-weight="bold"> <xsl:apply-templates select="row"/> </fo:table-body> </xsl:template> <xsl:template match="tbody"> <fo:table-body> <xsl:apply-templates select="row"/> </fo:table-body> </xsl:template> <xsl:template match="row"> <fo:table-row line-height="8pt"> <xsl:apply-templates select="entry"/> </fo:table-row> </xsl:template> <xsl:template match="entry"> <fo:table-cell> <xsl:call-template name="cell-span"/> </fo:table-cell> </xsl:template> <xsl:template name="calc.column.width"> <xsl:param name="colwidth">1*</xsl:param> <xsl:if test="contains($colwidth, '*')"> <xsl:text>proportional-column-width(</xsl:text> <xsl:value-of select="substring-before($colwidth, '*')"/> <xsl:text>)</xsl:text> </xsl:if> <!-- Now get the non-proportional part of the specification --> <xsl:variable name="width-units"> <xsl:choose> <xsl:when test="contains($colwidth, '*')"> <xsl:value-of select="normalize-space(substring-after($colwidth, '*'))"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="normalize-space($colwidth)"/> </xsl:otherwise> </xsl:choose> </xsl:variable> </xsl:template> __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] getting type information , David Carlisle | Thread | [xsl] Saxon 8B returns profile and , Jesper Tverskov |
Re: [xsl] Get Document File name, Frank Marent | Date | Re: [xsl] Get Document File name, Abel Braaksma |
Month |