]> granicus.if.org Git - docbook-dsssl/commitdiff
Improve efficiency of make-verbatim; thanks to Paul Grosso, John Dreystadt, et. al.
authorNorman Walsh <ndw@nwalsh.com>
Wed, 13 Mar 2002 11:39:45 +0000 (11:39 +0000)
committerNorman Walsh <ndw@nwalsh.com>
Wed, 13 Mar 2002 11:39:45 +0000 (11:39 +0000)
xsl/html/verbatim.xsl

index 6bec5c29c2b7a7b82da5842469ab1037f6bcf586..9d3a2a4f05a335e2bf7f2a0df02cbdf68d2ee239 100644 (file)
 
 <xsl:template name="make-verbatim">
   <xsl:param name="text" select="''"/>
+
+  <xsl:call-template name="make-verbatim-recursive">
+    <xsl:with-param name="text" select="translate($text, ' ', '&#160;')"/>
+  </xsl:call-template>
+</xsl:template>
+
+<xsl:template name="make-verbatim-recursive">
+  <xsl:param name="text" select="''"/>
+
   <xsl:choose>
     <xsl:when test="not(contains($text, '&#xA;'))">
       <xsl:value-of select="$text"/>
     </xsl:when>
+
     <xsl:otherwise>
       <xsl:variable name="len" select="string-length($text)"/>
+
       <xsl:choose>
         <xsl:when test="$len = 1">
           <br/><xsl:text>&#xA;</xsl:text>
         </xsl:when>
+
         <xsl:otherwise>
-          <xsl:variable name="half" select="$len div 2"/>
-          <xsl:call-template name="make-verbatim">
-            <xsl:with-param name="text" select="substring($text, 1,
-$half)"/>
-          </xsl:call-template>
-          <xsl:call-template name="make-verbatim">
-            <xsl:with-param name="text"
-                            select="substring($text, ($half + 1), $len)"/>
-          </xsl:call-template>
-        </xsl:otherwise>
+         <xsl:variable name="half" select="$len div 2"/>
+         <xsl:call-template name="make-verbatim-recursive">
+           <xsl:with-param name="text" select="substring($text, 1, $half)"/>
+         </xsl:call-template>
+         <xsl:call-template name="make-verbatim-recursive">
+           <xsl:with-param name="text"
+                           select="substring($text, ($half + 1), $len)"/>
+         </xsl:call-template>
+       </xsl:otherwise>
       </xsl:choose>
     </xsl:otherwise>
   </xsl:choose>