crossley 2003/11/07 23:59:39
Modified: src/webapp/samples samples.xml
Added: src/webapp/samples/text-wrap sitemap.xmap welcome.html
src/webapp/samples/text-wrap/data ascii-art.xml
cdata-model-2.xml cdata-model.xml
with-word-boundaries.xml
without-word-boundaries.xml
src/webapp/samples/text-wrap/xslt docraw.xsl docsplit.xsl
docwrap.xsl split.xsl wrap2para.xsl
Log:
Addresses the problem of wrapping long lines of text in source elements.
Revision Changes Path
1.27 +4 -1 cocoon-2.1/src/webapp/samples/samples.xml
Index: samples.xml
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/webapp/samples/samples.xml,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- samples.xml 7 Sep 2003 06:16:41 -0000 1.26
+++ samples.xml 8 Nov 2003 07:59:39 -0000 1.27
@@ -81,6 +81,9 @@
lines of XML markup using SOAP XSP Logicsheet. See also axis block that
integrates Axis into Cocoon.
</sample>
+ <sample href="text-wrap/" name="Text wrap">
+ Addresses the problem of wrapping long lines of text in source
elements.
+ </sample>
</group>
<group name="Block Samples">
1.1 cocoon-2.1/src/webapp/samples/text-wrap/sitemap.xmap
Index: sitemap.xmap
===================================================================
<?xml version="1.0"?>
<!-- CVS $Id: sitemap.xmap,v 1.1 2003/11/08 07:59:39 crossley Exp $ -->
<map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
<map:pipelines>
<map:pipeline>
<map:match pattern="">
<map:redirect-to uri="welcome"/>
</map:match>
<map:match pattern="index.html">
<map:redirect-to uri="welcome"/>
</map:match>
<map:match pattern="welcome">
<map:read src="welcome.html"/>
<map:serialize/>
</map:match>
<map:match pattern="raw/*">
<map:generate src="data/{1}.xml"/>
<map:transform src="xslt/docraw.xsl"/>
<map:serialize type="html"/>
</map:match>
<map:match pattern="split/*">
<map:generate src="data/{1}.xml"/>
<map:transform src="xslt/docsplit.xsl"/>
<map:serialize type="html"/>
</map:match>
<map:match pattern="wrap2para/*">
<map:generate src="data/{1}.xml"/>
<map:transform src="xslt/docwrap.xsl"/>
<map:serialize type="html"/>
</map:match>
</map:pipeline>
</map:pipelines>
</map:sitemap>
1.1 cocoon-2.1/src/webapp/samples/text-wrap/welcome.html
Index: welcome.html
===================================================================
<html>
<head>
<title>Various methods to handle long lines of text</title>
</head>
<body>
<h1>Various methods to handle long lines of text</h1>
<p>
Sometimes the lines inside <source> elements are too wide,
which can make the resulting pages too wide to view on screen or to print.
The width of the long source line causes the whole page layout to be that
same width. A web page that is wider than the screen is a complete bastard to
read - you have to scroll right and left all the time. And printing in
landscape orientation is not very nice either.
(See Bugzilla report
<a href="http://nagoya.apache.org/bugzilla/show_bug.cgi?id=23796">23796</a>.)
</p>
<p>
We need to find a way to consistently split lines that are too wide.
Here are demonstrations of various solutions. Each one has pros and cons.
Please help to enhance these solutions so that one can soon be implemented.
(See <a href="#notes">Notes</a> below.)
</p>
<h2>Using no special handling</h2>
<p>No special handling was done for the
<source> elements. The content is wrapped with a <pre> element.
Note the long right-left scrollbar.
</p>
<ul>
<li>
<a href="raw/with-word-boundaries">Long Line With Word Boundaries</a>
</li>
<li>
<a href="raw/without-word-boundaries">Long Line Without Word Boundaries</a>
</li>
<li>
<a href="raw/cdata-model">CDATA and deeply emebedded xml content model</a>
</li>
<li>
<a href="raw/cdata-model-2">CDATA and deeply emebedded xml content model with
long names</a>
</li>
<li>
<a href="raw/ascii-art">Ascii Art</a>
</li>
</ul>
<h2>Using the "split.xsl" stylesheet</h2>
<p>All <source> elements had their long
lines split by the included split.xsl stylesheet.
The content is wrapped with a <pre> element.
</p>
<p>Note: In past Cocoons this stylesheet has been reported to be a memory hog
on certain Java JDKs. How does it go for you?
</p>
<ul>
<li>
<a href="split/with-word-boundaries">Long Line With Word Boundaries</a>
</li>
<li>
<a href="split/without-word-boundaries">Long Line Without Word Boundaries</a>
</li>
<li>
<a href="split/cdata-model">CDATA and deeply emebedded xml content model</a>
</li>
<li>
<a href="split/cdata-model-2">CDATA and deeply emebedded xml content model
with long names</a>
</li>
<li>
<a href="split/ascii-art">Ascii Art</a>
</li>
</ul>
<h2>Using the "wrap2para.xsl" stylesheet</h2>
<p>Only <source> elements that did not
contain an xml content model, had their long
lines handled by the included wrap2para.xsl stylesheet.
Such lines are each wrapped with a styled <p> element.
</p>
<ul>
<li>
<a href="wrap2para/with-word-boundaries">Long Line With Word Boundaries</a>
</li>
<li>
<a href="wrap2para/without-word-boundaries">Long Line Without Word
Boundaries</a>
</li>
<li>
<a href="wrap2para/cdata-model">CDATA and deeply emebedded xml content
model</a>
</li>
<li>
<a href="wrap2para/cdata-model-2">CDATA and deeply emebedded xml content
model with long names</a>
</li>
<li>
<a href="wrap2para/ascii-art">Ascii Art</a>
</li>
</ul>
<a name="notes" />
<h2>Other notes</h2>
<p>
There may be some other solutions. Suggestions include the Chaperon Block
and maybe the Slop Block.
</p>
</body>
</html>
1.1
cocoon-2.1/src/webapp/samples/text-wrap/data/ascii-art.xml
Index: ascii-art.xml
===================================================================
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE document PUBLIC "-//APACHE//DTD Documentation V1.2//EN"
"document-v12.dtd">
<document>
<header>
<title>Ascii Art</title>
<authors>
<person name="David Crossley" email="[EMAIL PROTECTED]"/>
</authors>
</header>
<body>
<section>
<title>Source element with specific ascii art</title>
<source>
_________1_________2_________3_________4_________5_________6_________7
12345678901234567890123456789012345678901234567890123456789012345678901234567890
[localhost:~/apache/xml-mysite]$ tree
.
|-- forrest-targets.ent
|-- forrest.properties
|-- src
| `-- documentation
| |-- README.txt
| |-- content
| | |-- hello.pdf
| | |-- test1.html
| | |-- test2.html
| | `-- xdocs
| | |-- index.xml
| | |-- samples
| | | |-- faq.xml
| | | |-- index.xml
| | | |-- subdir
| | | | `-- index.xml
| | | `--
silly-long-filename-that-demonstrates-text-wrapping-of-long-lines-silly-long-filename-that-demonstrates-text-wrapping-of-long-lines-silly-long-filename-that-demonstrates-text-wrapping-of-long-lines.xml
| | |-- site.xml
| | `-- tabs.xml
| |-- resources
| | `-- images
| | |-- group-logo.gif
| | |-- group.svg
| | |-- icon.png
| | |-- project-logo.gif
| | `-- project.svg
| `-- skinconf.xml
`-- status.xml
</source>
</section>
</body>
</document>
1.1
cocoon-2.1/src/webapp/samples/text-wrap/data/cdata-model-2.xml
Index: cdata-model-2.xml
===================================================================
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE document PUBLIC "-//APACHE//DTD Documentation V1.2//EN"
"document-v12.dtd">
<document>
<header>
<title>Deeply emebedded content model with long names</title>
<authors>
<person name="David Crossley" email="[EMAIL PROTECTED]"/>
</authors>
</header>
<body>
<section>
<title>Source element with CDATA</title>
<source><![CDATA[
_________1_________2_________3_________4_________5_________6_________7
12345678901234567890123456789012345678901234567890123456789012345678901234567890
<deeeeeeeeeeppppppppppllllllllllyyyyyyyyyy-embedded-xml-elements-with-very-loooooooooonnnnnnnnnngggggggggg-names>
<deeeeeeeeeeppppppppppllllllllllyyyyyyyyyy-embedded-xml-elements-with-very-loooooooooonnnnnnnnnngggggggggg-names>
<deeeeeeeeeeppppppppppllllllllllyyyyyyyyyy-embedded-xml-elements-with-very-loooooooooonnnnnnnnnngggggggggg-names>
<deeeeeeeeeeppppppppppllllllllllyyyyyyyyyy-embedded-xml-elements-with-very-loooooooooonnnnnnnnnngggggggggg-names>
<deeeeeeeeeeppppppppppllllllllllyyyyyyyyyy-embedded-xml-elements-with-very-loooooooooonnnnnnnnnngggggggggg-names>
<deeeeeeeeeeppppppppppllllllllllyyyyyyyyyy-embedded-xml-elements-with-very-loooooooooonnnnnnnnnngggggggggg-names>
<deeeeeeeeeeppppppppppllllllllllyyyyyyyyyy-embedded-xml-elements-with-very-loooooooooonnnnnnnnnngggggggggg-names>
<deeeeeeeeeeppppppppppllllllllllyyyyyyyyyy-embedded-xml-elements-with-very-loooooooooonnnnnnnnnngggggggggg-names>
<deeeeeeeeeeppppppppppllllllllllyyyyyyyyyy-embedded-xml-elements-with-very-loooooooooonnnnnnnnnngggggggggg-names>
</deeeeeeeeeeppppppppppllllllllllyyyyyyyyyy-embedded-xml-elements-with-very-loooooooooonnnnnnnnnngggggggggg-names>
</deeeeeeeeeeppppppppppllllllllllyyyyyyyyyy-embedded-xml-elements-with-very-loooooooooonnnnnnnnnngggggggggg-names>
</deeeeeeeeeeppppppppppllllllllllyyyyyyyyyy-embedded-xml-elements-with-very-loooooooooonnnnnnnnnngggggggggg-names>
</deeeeeeeeeeppppppppppllllllllllyyyyyyyyyy-embedded-xml-elements-with-very-loooooooooonnnnnnnnnngggggggggg-names>
</deeeeeeeeeeppppppppppllllllllllyyyyyyyyyy-embedded-xml-elements-with-very-loooooooooonnnnnnnnnngggggggggg-names>
</deeeeeeeeeeppppppppppllllllllllyyyyyyyyyy-embedded-xml-elements-with-very-loooooooooonnnnnnnnnngggggggggg-names>
</deeeeeeeeeeppppppppppllllllllllyyyyyyyyyy-embedded-xml-elements-with-very-loooooooooonnnnnnnnnngggggggggg-names>
</deeeeeeeeeeppppppppppllllllllllyyyyyyyyyy-embedded-xml-elements-with-very-loooooooooonnnnnnnnnngggggggggg-names>
</deeeeeeeeeeppppppppppllllllllllyyyyyyyyyy-embedded-xml-elements-with-very-loooooooooonnnnnnnnnngggggggggg-names>
]]></source>
</section>
</body>
</document>
1.1
cocoon-2.1/src/webapp/samples/text-wrap/data/cdata-model.xml
Index: cdata-model.xml
===================================================================
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE document PUBLIC "-//APACHE//DTD Documentation V1.2//EN"
"document-v12.dtd">
<document>
<header>
<title>Deeply emebedded content model</title>
<authors>
<person name="David Crossley" email="[EMAIL PROTECTED]"/>
</authors>
</header>
<body>
<section>
<title>Source element with CDATA</title>
<source><![CDATA[
_________1_________2_________3_________4_________5_________6_________7
12345678901234567890123456789012345678901234567890123456789012345678901234567890
<deeply>
<embedded>
<xml>
<elements>
<deeply>
<embedded>
<xml>
<elements>
<deeply>
<embedded>
<xml>
<elements>
<deeply>
<embedded>
<xml>
<elements>
<deeply>
<embedded>
<xml>
<elements>
</elements>
</xml>
</embedded>
</deeply>
</elements>
</xml>
</embedded>
</deeply>
</elements>
</xml>
</embedded>
</deeply>
</elements>
</xml>
</embedded>
</deeply>
</elements>
</xml>
</embedded>
</deeply>
]]></source>
</section>
</body>
</document>
1.1
cocoon-2.1/src/webapp/samples/text-wrap/data/with-word-boundaries.xml
Index: with-word-boundaries.xml
===================================================================
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE document PUBLIC "-//APACHE//DTD Documentation V1.2//EN"
"document-v12.dtd">
<document>
<header>
<title>Long Line With Word Boundaries</title>
<authors>
<person name="David Crossley" email="[EMAIL PROTECTED]"/>
</authors>
</header>
<body>
<section>
<title>Source element with plain text</title>
<source>
_________1_________2_________3_________4_________5_________6_________7
12345678901234567890123456789012345678901234567890123456789012345678901234567890
Long Line With Word Boundaries. Long Line With Word Boundaries. Long Line
With Word Boundaries. Long Line With Word Boundaries. Long Line With Word
Boundaries. Long Line With Word Boundaries. Long Line With Word Boundaries.
Long Line With Word Boundaries. Long Line With Word Boundaries. Long Line With
Word Boundaries. Long Line With Word Boundaries. Long Line With Word
Boundaries. Long Line With Word Boundaries. Long Line With Word Boundaries.
Long Line With Word Boundaries.
</source>
</section>
</body>
</document>
1.1
cocoon-2.1/src/webapp/samples/text-wrap/data/without-word-boundaries.xml
Index: without-word-boundaries.xml
===================================================================
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE document PUBLIC "-//APACHE//DTD Documentation V1.2//EN"
"document-v12.dtd">
<document>
<header>
<title>Long Line Without Word Boundaries</title>
<authors>
<person name="David Crossley" email="[EMAIL PROTECTED]"/>
</authors>
</header>
<body>
<section>
<title>Source element with plain text</title>
<source>
_________1_________2_________3_________4_________5_________6_________7
12345678901234567890123456789012345678901234567890123456789012345678901234567890
LongLineWithoutWordBoundariesLongLineWithoutWordBoundariesLongLineWithoutWordBoundariesLongLineWithoutWordBoundariesLongLineWithoutWordBoundariesLongLineWithoutWordBoundariesLongLineWithoutWordBoundariesLongLineWithoutWordBoundariesLongLineWithoutWordBoundariesLongLineWithoutWordBoundariesLongLineWithoutWordBoundariesLongLineWithoutWordBoundariesLongLineWithoutWordBoundariesLongLineWithoutWordBoundariesLongLineWithoutWordBoundaries
</source>
</section>
</body>
</document>
1.1 cocoon-2.1/src/webapp/samples/text-wrap/xslt/docraw.xsl
Index: docraw.xsl
===================================================================
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- doc.xsl - text line wrapping
This stylesheet does not do any line wrapping.
-->
<xsl:template match="document">
<html>
<head>
<title><xsl:value-of select="header/title"/></title>
</head>
<xsl:apply-templates/>
</html>
</xsl:template>
<xsl:template match="body">
<body>
<h1><xsl:value-of select="header/title"/></h1>
<p>Comment from stylesheet: No special handling was done for the
<source> elements. Note the long right-left scrollbar.
</p>
<xsl:apply-templates/>
</body>
</xsl:template>
<xsl:template match="section">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="source">
<div style="padding:4pt; margin-bottom:8pt; border-width:1px;
border-style:solid; border-color:#0086b2;">
<pre class="code">
<xsl:apply-templates/>
</pre>
</div>
</xsl:template>
<xsl:template match="title">
<h2><xsl:apply-templates/></h2>
</xsl:template>
<xsl:template match="p">
<p><xsl:apply-templates/></p>
</xsl:template>
</xsl:stylesheet>
1.1 cocoon-2.1/src/webapp/samples/text-wrap/xslt/docsplit.xsl
Index: docsplit.xsl
===================================================================
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- docsplit.xsl - text line wrapping
This stylesheet includes split.xsl to handle all <source> elements.
-->
<xsl:include href="split.xsl"/>
<xsl:template match="document">
<html>
<head>
<title><xsl:value-of select="header/title"/></title>
</head>
<xsl:apply-templates/>
</html>
</xsl:template>
<xsl:template match="body">
<body>
<h1><xsl:value-of select="header/title"/></h1>
<p>Comment from stylesheet: All <source> elements had their long
lines split by the included split.xsl stylesheet.
</p>
<xsl:apply-templates/>
</body>
</xsl:template>
<xsl:template match="section">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="source">
<div style="padding:4pt; margin-bottom:8pt; border-width:1px;
border-style:solid; border-color:#0086b2;">
<pre class="code">
<xsl:call-template name="format">
<xsl:with-param select="." name="txt" />
<xsl:with-param name="width">72</xsl:with-param>
</xsl:call-template>
</pre>
</div>
</xsl:template>
<xsl:template match="title">
<h2><xsl:apply-templates/></h2>
</xsl:template>
<xsl:template match="p">
<p><xsl:apply-templates/></p>
</xsl:template>
</xsl:stylesheet>
1.1 cocoon-2.1/src/webapp/samples/text-wrap/xslt/docwrap.xsl
Index: docwrap.xsl
===================================================================
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- docwrap.xsl - text line wrapping
This stylesheet includes wrap2para.xsl to handle just <source> elements
that have PCDATA.
Any other type of source element is the reponsibility of the caller xslt.
-->
<xsl:include href="wrap2para.xsl"/>
<xsl:template match="document">
<html>
<head>
<title><xsl:value-of select="header/title"/></title>
</head>
<xsl:apply-templates/>
</html>
</xsl:template>
<xsl:template match="body">
<body>
<h1><xsl:value-of select="header/title"/></h1>
<p>Comment from stylesheet: Only <source> elements that did not
contain an xml content model, had their long
lines handled by the included wrap2para.xsl stylesheet.
</p>
<xsl:apply-templates/>
</body>
</xsl:template>
<xsl:template match="section">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="source">
<pre class="code">
<xsl:apply-templates/>
</pre>
</xsl:template>
<xsl:template match="source[not(*)]">
<div style="padding:4pt; margin-bottom:8pt; border-width:1px;
border-style:solid; border-color:#0086b2;">
<xsl:call-template name="format-source">
<xsl:with-param name="source" select="string(.)"/>
</xsl:call-template>
</div>
</xsl:template>
<xsl:template match="title">
<h2><xsl:apply-templates/></h2>
</xsl:template>
<xsl:template match="p">
<p><xsl:apply-templates/></p>
</xsl:template>
</xsl:stylesheet>
1.1 cocoon-2.1/src/webapp/samples/text-wrap/xslt/split.xsl
Index: split.xsl
===================================================================
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<!--
This stylesheet was taken from the XSLT FAQ http://www.dpawson.co.uk/xsl/
Comments and adaption to be used without normalize-space()
by Nicola Ken Barozzi [EMAIL PROTECTED]
-->
<!--
Input:
<doc>
<para>
123456 2345 343434 545454 43434 343
12345 343434 545454 43434 343
32345645 343434 545454 43434 343
3422222225 343434 545454 43434 343
llllllllllllllllllllllooooooooooooooonnnnnnnnnnnggggggggg
345 343434 545454 43434 343
</para>
</doc>
Output:
<HTML>
<BODY>
<PRE>123456 2345 343434 545454
43434 343 12345 343434 545454
43434 343 32345645 343434
545454 43434 343 3422222225
343434 545454 43434 343
lllllllllllllllllllllloooooooo
ooooooonnnnnnnnnnnggggggggg
345 343434 545454 43434
343
</PRE>
</BODY>
</HTML>
Fragment ised:
<xsl:template match="/doc">
<HTML><BODY><PRE>
<xsl:call-template name="format">
<xsl:with-param select="normalize-space(para)" name="txt" />
<xsl:with-param name="width">30</xsl:with-param>
</xsl:call-template>
</PRE></BODY></HTML>
</xsl:template>
-->
<xsl:template match="/body">
<body>
<xsl:call-template name="format">
<xsl:with-param select="source" name="txt" />
<xsl:with-param name="width">40</xsl:with-param>
</xsl:call-template>
</body>
</xsl:template>
<xsl:template name="format">
<xsl:param name="txt" />
<xsl:param name="width" />
<!-- if there is still text left -->
<xsl:if test="$txt">
<xsl:variable name = "pretxt" select = "substring($txt,0, $width)" />
<xsl:choose>
<xsl:when test="contains($pretxt, '
')">
<xsl:value-of select="substring-before($pretxt, '
')"/>
<xsl:text>
</xsl:text>
<xsl:call-template name="format">
<xsl:with-param name="txt" select="substring-after($txt,'
')"/>
<xsl:with-param select="$width" name="width" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<!-- get the width at which to break-->
<xsl:variable name="real-width">
<xsl:call-template name="tune-width">
<xsl:with-param select="$txt" name="txt" />
<xsl:with-param select="$width" name="width" />
<xsl:with-param select="$width" name="def" />
</xsl:call-template>
</xsl:variable>
<!-- output the first part of the broken string -->
<xsl:value-of select="substring($txt, 1, $real-width)" />
<!-- output a newline -->
<xsl:text>
</xsl:text>
<!-- call itself with the remaining part of the text -->
<xsl:call-template name="format">
<xsl:with-param select="substring($txt,$real-width + 1)" name="txt" />
<xsl:with-param select="$width" name="width" />
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</xsl:template>
<!-- used by template "format", it calculates the width at the given def
It starts at def length and comes back till it finds a space -->
<xsl:template name="tune-width">
<xsl:param name="txt" />
<xsl:param name="width" />
<xsl:param name="def" />
<xsl:choose>
<xsl:when test="$width = 0">
<xsl:value-of select="$def" />
</xsl:when>
<xsl:when test="substring($txt, $width, 1 ) = ' '">
<xsl:value-of select="$width" />
</xsl:when>
<xsl:otherwise>
<!-- otherwise need to tune again, trying with $width - 1 -->
<xsl:call-template name="tune-width">
<xsl:with-param select="$width - 1" name="width" />
<xsl:with-param select="$txt" name="txt" />
<xsl:with-param select="$def" name="def" />
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
1.1
cocoon-2.1/src/webapp/samples/text-wrap/xslt/wrap2para.xsl
Index: wrap2para.xsl
===================================================================
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- wrap2para.xsl - text line wrapping
This stylesheet handles just <source> elements that have PCDATA.
Any other type of source element is the reponsibility of the caller xslt.
-->
<!-- unstructured source is laid out as a sequence of paragraphs -->
<xsl:template name="format-source">
<xsl:param name="source"/>
<xsl:if test="normalize-space($source)">
<xsl:choose>
<xsl:when test="not(contains($source,' '))">
<xsl:call-template name="format-source-line">
<xsl:with-param name="line" select="$source"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="format-source-line">
<xsl:with-param name="line"
select="substring-before($source,' ')"/>
</xsl:call-template>
<xsl:call-template name="format-source">
<xsl:with-param name="source"
select="substring-after($source,' ')"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</xsl:template>
<xsl:template name="format-source-line">
<xsl:param name="line"/>
<xsl:variable name="text" select="normalize-space($line)"/>
<xsl:variable name="first-non-white-space-character"
select="substring($text,1,1)"/>
<xsl:variable name="leading-spaces"
select="string-length(substring-before($line,$first-non-white-space-character))"/>
<xsl:variable name="text-with-nbsp">
<xsl:call-template name="no-break-in-strings">
<xsl:with-param name="line" select="$text"/>
</xsl:call-template>
</xsl:variable>
<p
style="margin-top:2pt;margin-bottom:2pt;padding-left:{8+$leading-spaces*4}pt;text-indent:-8pt;font-size:smaller">
<xsl:value-of select="$text-with-nbsp"/>
</p>
</xsl:template>
<xsl:template name="no-break-in-strings">
<xsl:param name="line"/>
<xsl:variable name="quote">"</xsl:variable>
<xsl:choose>
<xsl:when test="contains($line,$quote)">
<xsl:value-of select="substring-before($line,$quote)"/>
<xsl:text>"</xsl:text>
<xsl:variable name="remainder" select="substring-after($line,$quote)"/>
<xsl:choose>
<xsl:when test="contains($remainder,$quote)">
<xsl:variable name="string"
select="substring-before($remainder,$quote)"/>
<xsl:value-of select="translate($string,' ',' ')"/>
<xsl:text>"</xsl:text>
<xsl:call-template name="no-break-in-strings">
<xsl:with-param name="line"
select="substring-after($remainder,$quote)"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="translate($remainder,' ',' ')"/>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise><xsl:value-of select="$line"/></xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>