]> granicus.if.org Git - docbook-dsssl/commitdiff
Add two-stage recursion for hyphenate.verbatim to fix recursion depth bug for long...
authorBob Stayton <bobs@sagehill.net>
Sun, 10 Sep 2006 07:22:08 +0000 (07:22 +0000)
committerBob Stayton <bobs@sagehill.net>
Sun, 10 Sep 2006 07:22:08 +0000 (07:22 +0000)
xsl/fo/verbatim.xsl

index d90f80b84cb95f92f684d7eb99845cb7a8cbeb4a..71ffd95904b6481f1509ca3f7e8dec8395ca8415 100644 (file)
 </xsl:template>
 
 <xsl:template match="text()" mode="hyphenate.verbatim" priority="2">
-  <xsl:call-template name="hyphenate.verbatim">
+  <xsl:call-template name="hyphenate.verbatim.block">
     <xsl:with-param name="content" select="."/>
   </xsl:call-template>
 </xsl:template>
 
+<xsl:template name="hyphenate.verbatim.block">
+  <xsl:param name="content" select="''"/>
+  <xsl:param name="count" select="1"/>
+
+  <!-- recurse on lines first to keep recursion depth reasonable -->
+  <xsl:choose>
+    <xsl:when test="contains($content, '&#xA;')">
+      <xsl:variable name="line" select="substring-before($content, '&#xA;')"/>
+      <xsl:variable name="rest" select="substring-after($content, '&#xA;')"/>
+      <xsl:call-template name="hyphenate.verbatim">
+        <xsl:with-param name="content" select="concat($line, '&#xA;')"/>
+      </xsl:call-template>
+      <xsl:call-template name="hyphenate.verbatim.block">
+        <xsl:with-param name="content" select="$rest"/>
+        <xsl:with-param name="count" select="$count + 1"/>
+      </xsl:call-template>
+    </xsl:when>
+    <xsl:otherwise>
+      <xsl:call-template name="hyphenate.verbatim">
+        <xsl:with-param name="content" select="$content"/>
+      </xsl:call-template>
+    </xsl:otherwise>
+  </xsl:choose>
+  
+</xsl:template>
+
 <xsl:template name="hyphenate.verbatim">
   <xsl:param name="content"/>
   <xsl:variable name="head" select="substring($content, 1, 1)"/>