</xsl:if>
</xsl:template>
+<!-- ==================================================================== -->
+<!-- make.verbatim.mode replaces spaces and newlines -->
+
+<xsl:template match="/" mode="make.verbatim.mode">
+ <xsl:apply-templates mode="make.verbatim.mode"/>
+</xsl:template>
+
+<xsl:template match="*" mode="make.verbatim.mode">
+ <xsl:copy>
+ <xsl:copy-of select="@*"/>
+ <xsl:apply-templates mode="make.verbatim.mode"/>
+ </xsl:copy>
+</xsl:template>
+
+<xsl:template match="processing-instruction()|comment()" mode="make.verbatim.mode">
+ <xsl:copy/>
+</xsl:template>
+
+<xsl:template match="text()" mode="make.verbatim.mode">
+ <xsl:variable name="text" select="translate(., ' ', ' ')"/>
+
+ <xsl:choose>
+ <xsl:when test="not(contains($text, '
'))">
+ <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>
</xsl:text>
+ </xsl:when>
+
+ <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>
+</xsl:template>
+
+<xsl:template name="make-verbatim-recursive">
+ <xsl:param name="text" select="''"/>
+
+ <xsl:choose>
+ <xsl:when test="not(contains($text, '
'))">
+ <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>
</xsl:text>
+ </xsl:when>
+
+ <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>
+</xsl:template>
+
<!-- ==================================================================== -->
</xsl:stylesheet>
xmlns:sverb="http://nwalsh.com/xslt/ext/com.nwalsh.saxon.Verbatim"
xmlns:xverb="com.nwalsh.xalan.Verbatim"
xmlns:lxslt="http://xml.apache.org/xslt"
- exclude-result-prefixes="sverb xverb lxslt"
+ xmlns:exsl="http://exslt.org/common"
+ exclude-result-prefixes="sverb xverb lxslt exsl"
version='1.0'>
<!-- ********************************************************************
<div class="{name(.)}">
<p>
<xsl:call-template name="number.rtf.lines">
- <xsl:with-param name="rtf">
- <xsl:call-template name="make-verbatim">
- <xsl:with-param name="text" select="translate($rtf,' ',' ')"/>
- </xsl:call-template>
- </xsl:with-param>
+ <xsl:with-param name="rtf" select="$rtf"/>
</xsl:call-template>
</p>
</div>
<div class="{name(.)}">
<p>
<xsl:call-template name="make-verbatim">
- <xsl:with-param name="text" select="translate($rtf,' ',' ')"/>
+ <xsl:with-param name="rtf" select="$rtf"/>
</xsl:call-template>
</p>
</div>
</xsl:choose>
</xsl:template>
-<xsl:template match="literallayout[not(@class)
- or @class != 'monospaced']//text()">
- <xsl:call-template name="make-verbatim">
- <xsl:with-param name="text" select="translate(.,' ',' ')"/>
- </xsl:call-template>
-</xsl:template>
-
<xsl:template match="address">
<xsl:param name="suppress-numbers" select="'0'"/>
<xsl:otherwise>
<div class="{name(.)}">
<p>
- <xsl:apply-templates/>
+ <xsl:call-template name="make-verbatim">
+ <xsl:with-param name="rtf" select="$rtf"/>
+ </xsl:call-template>
</p>
</div>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
-<xsl:template match="address//text()">
- <xsl:call-template name="make-verbatim">
- <xsl:with-param name="text" select="translate(.,' ',' ')"/>
- </xsl:call-template>
-</xsl:template>
-
<xsl:template name="make-verbatim">
- <xsl:param name="text" select="''"/>
+ <xsl:param name="rtf"/>
- <xsl:call-template name="make-verbatim-recursive">
- <xsl:with-param name="text" select="translate($text, ' ', ' ')"/>
- </xsl:call-template>
-</xsl:template>
-
-<xsl:template name="make-verbatim-recursive">
- <xsl:param name="text" select="''"/>
+ <!-- I want to make this RTF verbatim. There are two possibilities: either
+ I have access to the exsl:node-set extension function and I can "do it right"
+ or I have to rely on CSS. -->
<xsl:choose>
- <xsl:when test="not(contains($text, '
'))">
- <xsl:value-of select="$text"/>
+ <xsl:when test="function-available('exsl:node-set')">
+ <xsl:apply-templates select="exsl:node-set($rtf)" mode="make.verbatim.mode"/>
</xsl:when>
-
<xsl:otherwise>
- <xsl:variable name="len" select="string-length($text)"/>
-
- <xsl:choose>
- <xsl:when test="$len = 1">
- <br/><xsl:text>
</xsl:text>
- </xsl:when>
-
- <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>
+ <span style="white-space: pre;">
+ <xsl:copy-of select="$rtf"/>
+ </span>
</xsl:otherwise>
</xsl:choose>
</xsl:template>