java - XSL fo模板性能

  显示原文与译文双语对照的内容

由于Java堆空间内存错误,无法处理大型数据的( 。XSLFO到 PDF ) 转换。

使用 FOP1.1, xalan-2.7.1.xercesimpl-2.9.serializer-2.9.1 jars 用于这里过程。 Windows 操作系统为 32位。 为此进程分配的JVM空间为 -Xmx1500M 。

有没有什么可以改善下面的。代码的方法是任何更好的pdf呈现 jars 是可以用的。 请帮助。


<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>

时间: 作者:

我不能想象一下代码优化可以节省足够的内存,问题似乎是数据量。 也许另一个渲染器会把你带出来。 你可以从alt软件试用 Xml2PDF,它是免费的,它是 Windows 。 请参见 http://www.alt-soft.com/index/products/xml2pdf-workstation/

作者:
  1. 不显示外部表是否使用固定宽度或者自动宽度
  2. 如果不包括所有属于默认值或者继承值的属性,则可以能会更好地进行内存更改。
  3. 看起来你的子系统每六列宽一行。 为什么不只使用六列( 实际上,对于当前列,12 )? 如果调用数量可以能是奇数的话,你将得到更多的逻辑,但是你更可以能使表工作。
  4. 你可以能需要使用商业处理器,比如,天线房,但是它们通常让你看到它们是否可以执行软件。

为了提高XSL的性能,请避免使用 xsl:for-each 并将它的替换为应用模板。


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


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

...