aboutsummaryrefslogtreecommitdiffstats
path: root/test/xsl
diff options
context:
space:
mode:
authorJeremias Maerki <jeremias@apache.org>2006-08-03 16:53:41 +0000
committerJeremias Maerki <jeremias@apache.org>2006-08-03 16:53:41 +0000
commitde718914ca7a6f6655d227f5ed55b3d32bb6026a (patch)
treec5f65e6c5e3d704892326d558862f1ed8d999419 /test/xsl
parent42471a761cf78619b02aa588c38d0aa85dfa0051 (diff)
downloadxmlgraphics-fop-de718914ca7a6f6655d227f5ed55b3d32bb6026a.tar.gz
xmlgraphics-fop-de718914ca7a6f6655d227f5ed55b3d32bb6026a.zip
Fixed a memory-leak: The FO tree part of a page-sequence was not released when a page-sequence was finished.
Added a "MemoryEater" debug helper which can replicate page-sequences of a regular FO file using the fo-replicator.xsl. Without the fix a JVM set to the normal 64MB heap size throws an OutOfMemoryError when replicating readme.fo 150 times. With the fix the memory consumption doesn't go above 10MB for the 1350 pages. Note that about one third of the time goes into garbage collection. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@428450 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'test/xsl')
-rw-r--r--test/xsl/fo-replicator.xsl72
1 files changed, 72 insertions, 0 deletions
diff --git a/test/xsl/fo-replicator.xsl b/test/xsl/fo-replicator.xsl
new file mode 100644
index 000000000..0f2736cd0
--- /dev/null
+++ b/test/xsl/fo-replicator.xsl
@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<!-- $Id$ -->
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
+ <xsl:param name="repeats" select="2"/>
+ <xsl:template match="@*|node()">
+ <xsl:param name="run"/>
+ <xsl:copy>
+ <xsl:apply-templates select="@*|node()">
+ <xsl:with-param name="run" select="$run"/>
+ </xsl:apply-templates>
+ </xsl:copy>
+ </xsl:template>
+ <xsl:template match="fo:root">
+ <fo:root>
+ <xsl:apply-templates select="@*|fo:layout-master-set|fo:declarations">
+ <xsl:with-param name="run" select="0"/>
+ </xsl:apply-templates>
+ <xsl:call-template name="repeat">
+ <xsl:with-param name="n" select="$repeats"/>
+ <xsl:with-param name="what" select="fo:page-sequence"/>
+ </xsl:call-template>
+ </fo:root>
+ </xsl:template>
+ <xsl:template name="repeat">
+ <xsl:param name="n"/>
+ <xsl:param name="what"/>
+ <xsl:if test="number($n) > 0">
+ <xsl:apply-templates select="$what">
+ <xsl:with-param name="run" select="$n"/>
+ </xsl:apply-templates>
+ <xsl:call-template name="repeat">
+ <xsl:with-param name="n" select="number($n) - 1"/>
+ <xsl:with-param name="what" select="$what"/>
+ </xsl:call-template>
+ </xsl:if>
+ </xsl:template>
+ <xsl:template match="@id">
+ <xsl:param name="run"/>
+ <xsl:attribute name="id"><xsl:value-of select="."/>-<xsl:value-of select="$run"/></xsl:attribute>
+ </xsl:template>
+ <xsl:template match="@ref-id">
+ <xsl:param name="run"/>
+ <xsl:attribute name="ref-id"><xsl:value-of select="."/>-<xsl:value-of select="$run"/></xsl:attribute>
+ </xsl:template>
+ <xsl:template match="@internal-destination">
+ <xsl:param name="run"/>
+ <xsl:attribute name="internal-destination"><xsl:value-of select="."/>-<xsl:value-of select="$run"/></xsl:attribute>
+ </xsl:template>
+ <xsl:template match="fo:page-number-citation">
+ <xsl:param name="run"/>
+ <fo:inline><xsl:value-of select="@ref-id"/></fo:inline>
+ </xsl:template>
+ <xsl:template match="fo:retrieve-marker|fo:marker">
+ <xsl:param name="run"/>
+ </xsl:template>
+</xsl:stylesheet>