xslt - XSL FO Table row header content is smashed -


i creating xsl fo table have varying number of columns. application uses apache fop display transformed document. when there low number of columns, displays fine (i.e. content of cells centered , displayed in full although columns end taking 2 lines because text wraps). however, tables have on 12 columns, , problem occurs: in column header cells, name of column way right of cell taking multiple lines. looks words wrapping, last 2 characters seemingly cut off. text not leaking neighboring cells.

here input xml file in case it's row table header , 1 row body brevity's sake. didn't include chart elements referenced in xsl document part displays properly:

<exports>    <export>      <table>         <tblrow>             <hdrcell>month</hdrcell>             <hdrcell>allow amt pepm med</hdrcell>             <hdrcell>allow amt pepm rx</hdrcell>             <hdrcell>allow amt pepm med , rx</hdrcell>             <hdrcell>allow amt pmpm med</hdrcell>             <hdrcell>allow amt pmpm rx</hdrcell>             <hdrcell>allow amt pmpm med , rx</hdrcell>             <hdrcell>employees avg med or rx</hdrcell>             <hdrcell>members avg med or rx</hdrcell>             <hdrcell>net pay pepm med</hdrcell>             <hdrcell>net pay pepm rx</hdrcell>             <hdrcell>net pay pepm med , rx</hdrcell>             <hdrcell>net pay pmpm med</hdrcell>             <hdrcell>net pay pmpm rx</hdrcell>             <hdrcell>net pay pmpm med , rx</hdrcell>         </tblrow>         <tblrow>             <tblcell>jan 2010</tblcell>             <tblcell>11</tblcell>             <tblcell>202</tblcell>             <tblcell>213</tblcell>             <tblcell>26</tblcell>             <tblcell>30</tblcell>             <tblcell>56</tblcell>             <tblcell>56</tblcell>             <tblcell>44</tblcell>             <tblcell>11</tblcell>             <tblcell>22</tblcell>             <tblcell>33</tblcell>             <tblcell>12</tblcell>             <tblcell>12</tblcell>             <tblcell>24</tblcell>             <tblcell>1</tblcell>         </tblrow>      </table> </export> 

and here xsl file transforms input file xsl fo. new xsl.

<xsl:stylesheet version="1.0"    xmlns:xsl="http://www.w3.org/1999/xsl/transform"    xmlns:fo="http://www.w3.org/1999/xsl/format">    <xsl:output method="xml" indent="yes"/>    <xsl:template match="/">    <fo:root>          <fo:layout-master-set>              <fo:simple-page-master master-name="exportpage">                  <fo:region-body />              </fo:simple-page-master>          </fo:layout-master-set>          <fo:page-sequence master-reference="exportpage">              <fo:flow flow-name="xsl-region-body">                   <fo:block id="chartblock">                           <!-- part works fine -->                   </fo:block>                  <!-- problem part -->                  <fo:block id="tableblock" margin="0.25in">                         <xsl:apply-templates select="exports/export/table"/>                  </fo:block>              </fo:flow>         </fo:page-sequence>     </fo:root>  </xsl:template>     <!-- creates table -->     <xsl:template match="table">         <fo:table table-layout="fixed" width="100%" >             <fo:table-header>                 <fo:table-row>                     <xsl:apply-templates select="tblrow[position() = 1]"/>                 </fo:table-row>             </fo:table-header>             <fo:table-body>                 <xsl:apply-templates select="tblrow[position() > 1]"/>             </fo:table-body>         </fo:table>     </xsl:template>      <xsl:template match="hdrcell">         <fo:table-cell background-color="#666" border-right-style="solid" border-right-width="1px" border-right-color="white" empty-cells="show">             <fo:block color="white" font-family="arial, helvetica, sans-serif" font-size="xx-small"><xsl:value-of select="."/></fo:block>         </fo:table-cell>     </xsl:template>      <xsl:template match="tblcell">    <fo:table-cell border-bottom-style="solid" border-bottom-width="1px"    border-bottom-color="#e3e3e3">    <fo:block color="#7e7e7e" font-family="arial, helvetica, sans-serif" font-                                                size="xx-small"><xsl:value-of select="."/></fo:block>         </fo:table-cell>     </xsl:template >      <xsl:template match="tblrow[position() > 1]">         <fo:table-row>             <xsl:apply-templates />         </fo:table-row>     </xsl:template>   </xsl:stylesheet> 

i have tried setting padding right property each table-cell's block element hoping shift text left no avail. have tried adjusting 'width' property of each block element child of table-cell. new xsl in general, i'm not sure how proceed. helpful specify elements specific width? can ensure full width of table displayed in pdf , without jumbled, truncated cell content? also, units in 'px' not specified.

thanks in advance,

brandt

answer: removing margin="0.25in" surrounding block yields result think expect (except of course margin on block). clear, change this:

<fo:block id="tableblock" margin="0.25in">       <xsl:apply-templates select="exports/export/table"/> </fo:block> 

and remove margin="0.25in".

note: not result different formatter. used renderx on original file , expect , correct result. used fop , incorrect result remove indent (which being inherited someway improperly 1 dimension of table cells).

one additional note: have 15 header cells , 16 cells in sample.


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -