简体   繁体   中英

XSL fo template Performance

unable to process the PDF conversion(XSLFO to PDF) for huge data because of Java Heap space memory error.

Using FOP1.1,xalan-2.7.1,xercesImpl-2.9.0,serializer-2.9.1 jars for this process. Windows OS is 32 bit. Allocated JVM space for this process is -Xmx1500M.

is there any alternative way to improve the performance of below xsl fo code are any better pdf rendering jars are available.. Please help.

<fo:table-body>
<xsl:for-each select="MSISDN/ITEM/CALLSUM">
<fo:table-row>
<fo:table-cell padding-bottom="0.0pt" start-indent="0.0pt" end-indent="0.0pt" padding-top="0.0pt" padding="0.0pt" display-align="before" width="264.33pt"  reference-orientation="0">

<fo:block-container  reference-orientation="0" >
<fo:block keep-together="auto" ><!-- GENERATE TABLE START-->
<xsl:message>before if</xsl:message>
<xsl:apply-templates match="CALLS[position() mod 2 != 0]"/>
</fo:block>
</fo:block-container>

</fo:table-cell>
<fo:table-cell>
<fo:block-container  reference-orientation="0" >
<fo:block keep-together="auto" >
<xsl:apply-templates match="CALLS[position() mod 2 =0]"/>
</fo:block>
</fo:block-container>
</fo:table-cell>

</fo:table-row>
</xsl:for-each>
</fo:table-body>



<xsl:template match="CALLS[position() mod 2 !=0 ]">
<fo:table table-layout="fixed" width="100%">

<fo:table-column column-width="56.05pt"/>
<fo:table-column column-width="18.0pt"/>
<fo:table-column column-width="71.0pt"/>
<fo:table-column column-width="45.52pt"/>
<fo:table-column column-width="48.37pt"/>
<fo:table-column column-width="25.47pt"/>
<fo:table-body>
<fo:table-row>
<fo:table-cell padding-bottom="0.0pt" start-indent="0.0pt" end-indent="0.0pt" padding-top="0.0pt" padding="0.0pt" display-align="before" width="56.05pt"  reference-orientation="0">
<fo:block-container>
<fo:block linefeed-treatment="preserve" white-space-treatment="ignore-if-surrounding-linefeed"  padding-bottom="0.0pt" start-indent="1.42pt" end-indent="0.0pt" padding-top="0.0pt" line-height="7.199999999999999pt" line-stacking-strategy="max-height" white-space-collapse="false"  hyphenate="true" language="en"  text-align="start" keep-together="auto"  color="#000000" font-family="Arial" font-size="6.0pt" letter-spacing="normal" word-spacing="normal">
<fo:inline color="#000000" font-family="Arial" font-size="6.0pt">
<xsl:value-of disable-output-escaping="no" select="@OPN"/>
</fo:inline>
</fo:block>
</fo:block-container>

</fo:table-cell>
<fo:table-cell padding-bottom="0.0pt" start-indent="0.0pt" end-indent="0.0pt" padding-top="0.0pt" padding="0.0pt" display-align="before" width="48.37pt"  reference-orientation="0">

<fo:block-container>
<fo:block linefeed-treatment="preserve" white-space-treatment="ignore-if-surrounding-linefeed"  padding-bottom="0.0pt" start-indent="0.0pt" end-indent="0.0pt" padding-top="0.0pt" padding="0.0pt" line-height="7.199999999999999pt" line-stacking-strategy="max-height" white-space-collapse="false"  hyphenate="true" language="en"  text-align="start" keep-together="auto"  color="#000000" font-family="Arial" font-size="6.0pt" letter-spacing="normal" word-spacing="normal">
<fo:inline color="#000000" font-family="Arial" font-size="6.0pt">
<xsl:value-of disable-output-escaping="no" select="@CALL_TYPE"/>
</fo:inline>
</fo:block>
</fo:block-container>

</fo:table-cell>
<fo:table-cell padding-bottom="0.0pt" start-indent="0.0pt" end-indent="0.0pt" padding-top="0.0pt" padding="0.0pt" display-align="before" width="57.0pt"  reference-orientation="0">

<fo:block-container>
<fo:block linefeed-treatment="preserve" white-space-treatment="ignore-if-surrounding-linefeed"  padding-bottom="0.0pt" start-indent="0.0pt" end-indent="0.0pt" padding-top="0.0pt" padding="0.0pt" line-height="7.199999999999999pt" line-stacking-strategy="max-height" white-space-collapse="false"  hyphenate="true" language="en"  text-align="center" keep-together="auto"  color="#000000" font-family="Arial" font-size="6.0pt" letter-spacing="normal" word-spacing="normal">
<fo:inline color="#000000" font-family="Arial" font-size="6.0pt">
<xsl:value-of disable-output-escaping="no" select="@DT"/>
</fo:inline>
</fo:block>
</fo:block-container>
</fo:table-cell>
<fo:table-cell padding-bottom="0.0pt" start-indent="0.0pt" end-indent="0.0pt" padding-top="0.0pt" padding="0.0pt" display-align="before" width="51.21pt"  reference-orientation="0">
<fo:block-container>
<fo:block linefeed-treatment="preserve" white-space-treatment="ignore-if-surrounding-linefeed"  padding-bottom="0.0pt" start-indent="0.0pt" end-indent="0.0pt" padding-top="0.0pt" padding="0.0pt" line-height="7.199999999999999pt" line-stacking-strategy="max-height" white-space-collapse="false"  hyphenate="true" language="en"  text-align="center" keep-together="auto"  color="#000000" font-family="Arial" font-size="6.0pt" letter-spacing="normal" word-spacing="normal">
<fo:inline color="#000000" font-family="Arial" font-size="6.0pt">
<xsl:value-of disable-output-escaping="no" select="@BILLDUR"/>
</fo:inline>
</fo:block>
</fo:block-container>
</fo:table-cell>
<fo:table-cell border-right-style="solid" border-right-width="0.57pt" border-right-color="#000000" padding-bottom="0.0pt" start-indent="0.0pt" end-indent="0.0pt" padding-top="0.0pt" padding="0.0pt" display-align="before" width="31.3pt"  reference-orientation="0">
<fo:block-container>
<fo:block linefeed-treatment="preserve" white-space-treatment="ignore-if-surrounding-linefeed"  padding-bottom="0.0pt" start-indent="0.0pt" end-indent="0.0pt" padding-top="0.0pt" padding="0.0pt" line-height="7.199999999999999pt" line-stacking-strategy="max-height" white-space-collapse="false"  hyphenate="true" language="en"  text-align="start" keep-together="auto"  color="#000000" font-family="Arial" font-size="6.0pt" letter-spacing="normal" word-spacing="normal">
<fo:inline color="#000000" font-family="Arial" font-size="6.0pt">
<xsl:value-of disable-output-escaping="no" select="@AMT"/>
</fo:inline>
</fo:block>
</fo:block-container>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
</xsl:template>

I can't imagine a xsl-fo code optimation could save enough memory, the problem seems to be the amount of data. Maybe another renderer could drive you out of this. You can try Xml2PDF from alt-soft, it's free and it's for Windows. See http://www.alt-soft.com/index/products/xml2pdf-workstation/

  1. You don't show whether the outer table uses fixed or automatic widths
  2. You may do better memory-wise if you don't include all the properties that are at their default or inherited value anyway
  3. It looks like your subtables are each six columns wide and one row deep. Why not just use six columns (actually, 12 for both current columns) instead? You will have to add some more logic if the number of CALLS can ever be odd but you're more likely to get your table to work.
  4. You may have to use a commercial FO processor, eg, Antenna House, but they usually let you have a trial license so you can see if they can do what you need before you pay for the software

In order to improve the performance of the XSL, avoid to use a xsl:for-each and replace it by an apply-templates.

<table-body>
   <xsl:apply-templates select="MSISDN/ITEM/CALLSUM"/>
</table-body>


<xsl:template match="CALLSUM">
    <!-- The content of the template -->
</xsl:template>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM