1 <?xml version=
"1.0" encoding=
"utf-8"?>
3 <xsl:stylesheet xmlns:
xsl=
"http://www.w3.org/1999/XSL/Transform"
4 xmlns:
xlink=
"http://www.w3.org/1999/xlink"
7 <xsl:template match=
"/page">
10 <title>common.lisp.ru -
<xsl:value-of select=
"@xlink:title" /></title>
14 <xsl:apply-templates select=
"*|text()" />
19 <!-- //////////////////////////////////////////////////////////////////////////////////////////////////// -->
20 <!-- //////////////////////////////////////////////////////////////////////////////////////////////////// -->
22 <xsl:template match=
"title" />
24 <xsl:template match=
"code">
26 <!--<xsl:value-of select="normalize-space(.)" />-->
27 <xsl:call-template name=
"multiline-string">
28 <xsl:with-param name=
"str" select=
"string(.)" />
29 <xsl:with-param name=
"trim">
30 <xsl:call-template name=
"left-trim-count">
31 <xsl:with-param name=
"str" select=
"string(.)" />
38 <xsl:template match=
"*|text()">
40 <xsl:copy-of select=
"@*" />
41 <xsl:apply-templates select=
"node()|text()" />
46 <!-- //////////////////////////////////////////////////////////////////////////////////////////////////// -->
47 <!-- //////////////////////////////////////////////////////////////////////////////////////////////////// -->
49 <xsl:template name=
"starts-space-count">
50 <xsl:param name=
"str" />
51 <xsl:param name=
"count" select=
"0" />
54 <xsl:when test=
"normalize-space($str) = ''">1000</xsl:when>
56 <xsl:when test=
"substring($str, 1, 1) = ' '">
57 <xsl:call-template name=
"starts-space-count">
58 <xsl:with-param name=
"str" select=
"substring($str, 2)" />
59 <xsl:with-param name=
"count" select=
"$count + 1" />
64 <xsl:value-of select=
"$count" />
69 <xsl:template name=
"left-trim-count">
70 <xsl:param name=
"str" />
71 <xsl:param name=
"count" select=
"1000" />
73 <xsl:variable name=
"before" select=
"substring-before($str, '
')" />
74 <xsl:variable name=
"after" select=
"substring-after($str, '
')" />
76 <xsl:variable name=
"left">
77 <xsl:call-template name=
"starts-space-count">
78 <xsl:with-param name=
"str" select=
"$before" />
82 <xsl:variable name=
"right">
84 <xsl:when test=
"not($after = '')">
85 <xsl:call-template name=
"left-trim-count">
86 <xsl:with-param name=
"str" select=
"$after" />
91 <xsl:value-of select=
"$count" />
97 <xsl:when test=
"$left < $right">
98 <xsl:value-of select=
"$left" />
102 <xsl:value-of select=
"$right" />
109 <xsl:template name=
"multiline-string">
110 <xsl:param name=
"str" />
111 <xsl:param name=
"trim" select=
"0" />
112 <xsl:param name=
"first" select=
"'true'" />
114 <xsl:if test=
"$str and not(normalize-space($str) = '')">
115 <xsl:if test=
"not($first = 'true')">
119 <xsl:variable name=
"line" select=
"substring(substring-before($str, '
'), $trim + 1)" />
120 <xsl:value-of select=
"$line" />
122 <xsl:variable name=
"nextfirst">
124 <xsl:when test=
"normalize-space($line) = ''"><xsl:text>true
</xsl:text></xsl:when>
125 <xsl:otherwise><xsl:text>false
</xsl:text></xsl:otherwise>
129 <xsl:call-template name=
"multiline-string">
130 <xsl:with-param name=
"str" select=
"substring-after($str, '
')" />
131 <xsl:with-param name=
"trim" select=
"$trim" />
132 <xsl:with-param name=
"first" select=
"$nextfirst" />