You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-users@xmlgraphics.apache.org by Lim Huat Heng <li...@bizsol.com.my> on 2003/08/27 18:05:11 UTC

Seek Help

Anyone who may help:
    I have read the article on HTML to Formatting Objects(FO) conversion guide by Doug Tidwell (IBM), in fact, it helps a lot in my understanding to prepare for the task to produce a PDF report from an existing HTML report. 
    However I would like to consult anyone who may help to clear my doubt on a few things and hope that you can advice. When using a table, based on the XSLT, it requires the attribute cols, in which it will specify the total columns and width for each column. If  the table is generated dynamically (the total is unknown in advance), will I be able to pass the total no of columns to the XSLT during runtime and will it auto allocate each column equal width? Currently I get ArrayIndexOutOfBound error when the column is more than 2 and cols is not specified.

  I try to add a 'dummy' attribute noOfCols to the HTML's table tag, as in <table width="100%" border="0" cellspacing="5" cellpadding="1" noOfCols="<%=noOfCols%>">. Then I try to edit your XSL such that if there's noOfCols, then I will calculate the table column width as 795 divided by the total no of columns. Otherwise, if cols exist, then the original process is unchanged.Is the XsL correct? I guess the division is wrong, how can I solve it?
  
  <xsl:template match="table">
    <fo:table table-layout="fixed">
      <xsl:choose>        
        <xsl:when test="@cols">
          <xsl:call-template name="build-columns">
            <xsl:with-param name="cols" 
             select="concat(@cols, ' ')"/>
          </xsl:call-template>
        </xsl:when>
        <xsl:otherwise>
          <xsl:variable name="colWidth">
          <xsl:choose>
            <xsl:when test="@noOfCols">
              <xsl:number value="@noOfCols"/>   
            </xsl:when>
            <xsl:otherwise>
              <xsl:number value="55"/>
            </xsl:otherwise>  
          </xsl:choose>
          <fo:table-column column-width="$colWidth"/> <!-- LHH Modified 200 -->  
          </xsl:variable>
        </xsl:otherwise>
      </xsl:choose>     
      <fo:table-body>
        <xsl:apply-templates select="*"/>
      </fo:table-body>
    </fo:table>
  </xsl:template>

    Besides, when I try to generate a report that is 100 pages long, it took almost 5 minutes to get the report rendered and my web server consume about 150MB of RAM. Is there a way I could improve this? Lastly, when I have some punctuations in the data, in particularly '&' (so far that's what I found), I get the following error: 

    HTML2PDFServlet.doGet: javax.servlet.ServletException: org.xml.sax.SAXParseException: Illegal character or                      entity reference syntax.
    Is it due to Java or XML? Please advice. Thanks.


  

Re: Seek Help

Posted by "J.Pietschmann" <j3...@yahoo.de>.
Lim Huat Heng wrote:
>   I guess the division is wrong, how can I solve it?

There is no division in your code snippet at all. One probelm is here:

>           <xsl:variable name="colWidth">
...
>           <fo:table-column column-width="$colWidth"/> <!-- LHH Modified 200 -->  
>           </xsl:variable>

You reference the variable from within its definition, which
wont give the expected value.

>     Besides, when I try to generate a report that is 100 pages long, it
 > took almost 5 minutes to get the report rendered and my web server
 > consume about 150MB of RAM. Is there a way I could improve this?

a) Read http://xml.apache.org/fop/running.html#memory
b) Don't use tables. They consume a lot of memory.

> Lastly, when I have some punctuations in the data, in particularly '&' (so
 > far that's what I found), I get the following error:
>     HTML2PDFServlet.doGet: javax.servlet.ServletException:
 > org.xml.sax.SAXParseException: Illegal character or entity reference syntax.
>     Is it due to Java or XML? Please advice. Thanks.

XML. This is a VFAQ. See for example
  http://xml.apache.org/fop/fo.html#xml-entity-chars
and check the XML spec (actually, this shold come quite
early in beginner's classes).

J.Pietschmann


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-user-help@xml.apache.org