styles/vym2html.xsl
author insilmaril
Sat Jul 23 10:26:30 2005 +0000 (2005-07-23)
changeset 134 6c199971ddb5
permissions -rw-r--r--
updated api.*
insilmaril@37
     1
<?xml version="1.0" encoding="UTF-8" ?>
insilmaril@37
     2
insilmaril@37
     3
<!--
insilmaril@37
     4
    Document   : vym2html.xsl
insilmaril@37
     5
    Created on : 20040313
insilmaril@37
     6
	Modified   : 20040512,20040622	Uwe Drechsel
insilmaril@37
     7
	Version    : 0.7
insilmaril@37
     8
    Author     : Clemens Kraus (http://www.clemens-kraus.de)
insilmaril@37
     9
    Description: transforms vym-files into html format.
insilmaril@37
    10
    
insilmaril@37
    11
	Hint:
insilmaril@37
    12
	tm.xsl and cm.xsl were taken from Alexander Johannesen's 
insilmaril@37
    13
	beautiful xSiteable content management system: 
insilmaril@37
    14
		http://xsiteable.org
insilmaril@37
    15
	and are used with kind permission
insilmaril@37
    16
-->
insilmaril@37
    17
insilmaril@37
    18
	
insilmaril@37
    19
insilmaril@37
    20
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
insilmaril@37
    21
insilmaril@37
    22
	<!-- Include external stylesheets -->
insilmaril@37
    23
	<xsl:include href="tm.xsl" />
insilmaril@37
    24
	<xsl:include href="cm.xsl" />
insilmaril@37
    25
  
insilmaril@37
    26
	<!-- Settings and parameters -->
insilmaril@37
    27
	<xsl:output method="html" indent="no" encoding="UTF-8"/> 
insilmaril@37
    28
	<xsl:param name="filenamep" />
insilmaril@37
    29
	<xsl:param name="wikistylep" />
insilmaril@37
    30
	<xsl:param name="genimagep" />
insilmaril@37
    31
	<xsl:param name="imageonlyp" />
insilmaril@37
    32
	<xsl:param name="stylesheetp" />
insilmaril@37
    33
	<xsl:param name="urlHeadingp" />
insilmaril@37
    34
	<xsl:param name="urlImagep" />
insilmaril@37
    35
	<xsl:variable name="filename" select="$filenamep"/>
insilmaril@37
    36
	<xsl:variable name="wikistyle" select="$wikistylep"/>
insilmaril@37
    37
	<xsl:variable name="genimage" select="$genimagep"/>
insilmaril@37
    38
	<xsl:variable name="imageonly" select="$imageonlyp"/>	
insilmaril@37
    39
	<xsl:variable name="stylesheet" select="$stylesheetp"/>
insilmaril@37
    40
	<xsl:variable name="topics" select="//item" /> 
insilmaril@37
    41
	<xsl:variable name="urlHeading" select="$urlHeadingp"/> 
insilmaril@37
    42
	<xsl:variable name="urlImage" select="$urlImagep"/> 
insilmaril@37
    43
insilmaril@37
    44
	<xsl:variable name="level" select="'0'"/>			
insilmaril@37
    45
	<xsl:variable name="contentlist" select="false()"/> 
insilmaril@37
    46
insilmaril@37
    47
  
insilmaril@37
    48
	<xsl:variable name="fn" >
insilmaril@37
    49
		<xsl:call-template name="getfn" >
insilmaril@37
    50
			<xsl:with-param name="txt" select="$filename" />
insilmaril@37
    51
		</xsl:call-template>
insilmaril@37
    52
	</xsl:variable>
insilmaril@37
    53
insilmaril@37
    54
	<xsl:variable name="path" >
insilmaril@37
    55
	  <xsl:value-of select="normalize-space( substring($filename, 1, number(string-length($filename)-string-length($fn))) )" />
insilmaril@37
    56
	</xsl:variable>
insilmaril@37
    57
insilmaril@37
    58
	<xsl:variable name="stylesheetn" >
insilmaril@37
    59
	<xsl:call-template name="getfn" >
insilmaril@37
    60
		<xsl:with-param name="txt" select="$stylesheet" />
insilmaril@37
    61
	</xsl:call-template>
insilmaril@37
    62
	</xsl:variable><!-- path -->
insilmaril@37
    63
insilmaril@37
    64
insilmaril@37
    65
insilmaril@37
    66
	<!-- Beginning of transformation here -->
insilmaril@37
    67
	<xsl:template match="/">
insilmaril@37
    68
	<xsl:variable name="mapversion" select="vymmap/@version"/>
insilmaril@37
    69
	<xsl:variable name="header" >
insilmaril@37
    70
		<xsl:call-template name="getheading" >
insilmaril@37
    71
			<xsl:with-param name="txt" select="vymmap/mapcenter/heading" />
insilmaril@37
    72
		</xsl:call-template>
insilmaril@37
    73
	</xsl:variable><!-- header -->
insilmaril@37
    74
		
insilmaril@37
    75
	<!-- Write head of HTML document -->  
insilmaril@37
    76
	<xsl:text disable-output-escaping="yes"><![CDATA[<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">]]>&#xA;</xsl:text>
insilmaril@37
    77
	<html><xsl:text>&#xA;</xsl:text>
insilmaril@37
    78
		<head><xsl:text>&#xA;</xsl:text>
insilmaril@37
    79
			<title><xsl:value-of select="$header"/></title>
insilmaril@37
    80
			<xsl:text disable-output-escaping="yes">&#xA;<![CDATA[<link href="]]></xsl:text>
insilmaril@37
    81
			<xsl:value-of select="$stylesheetn"/>
insilmaril@37
    82
			<xsl:text disable-output-escaping="yes"><![CDATA[" rel="stylesheet" id="]]></xsl:text>
insilmaril@37
    83
			<xsl:value-of select="$stylesheetn"/>
insilmaril@37
    84
			<xsl:text disable-output-escaping="yes"><![CDATA[">]]>&#xA;</xsl:text>
insilmaril@37
    85
			<meta name="generator" content="vym (http://www.insilmaril.de/vym/) and vym2html.xsl (http://www.clemens-kraus.de)"/><xsl:text>&#xA;</xsl:text>
insilmaril@37
    86
		</head>
insilmaril@37
    87
		<xsl:text>&#xA;</xsl:text>
insilmaril@37
    88
insilmaril@37
    89
		<!-- Write body of HTML document -->  
insilmaril@37
    90
		<body>
insilmaril@37
    91
			<!-- vym title box at top of page -->
insilmaril@37
    92
			<xsl:text>&#xA;</xsl:text>
insilmaril@37
    93
			<div class="vymTitleBox">
insilmaril@37
    94
				<xsl:value-of select="$header"/>
insilmaril@37
    95
			</div>
insilmaril@37
    96
insilmaril@37
    97
			<!-- Include image of map, if wanted -->
insilmaril@37
    98
			<xsl:if test="$genimage != ''">
insilmaril@37
    99
				<xsl:variable name="image" select="concat($fn, '.png')" />
insilmaril@37
   100
insilmaril@37
   101
				<div class="vymImageMap">
insilmaril@37
   102
					<img src="images/{$image}" 
insilmaril@37
   103
						border="0" 
insilmaril@37
   104
						usemap="#vymmap"
insilmaril@37
   105
						alt="vymmap">
insilmaril@37
   106
					</img>
insilmaril@37
   107
				</div>
insilmaril@37
   108
				<xsl:text>&#xA;</xsl:text>
insilmaril@37
   109
insilmaril@37
   110
				<!-- Generate image map by a first walk through all branches -->
insilmaril@37
   111
				<map name="vymmap">
insilmaril@37
   112
					<xsl:apply-templates select="vymmap/mapcenter/branch">
insilmaril@37
   113
						<xsl:with-param name="genarea" select="true()"/>
insilmaril@37
   114
						<xsl:with-param name="imageonly" select="$imageonly"/>
insilmaril@37
   115
					</xsl:apply-templates>
insilmaril@37
   116
				</map>
insilmaril@37
   117
insilmaril@37
   118
				<xsl:text>&#xA;</xsl:text>
insilmaril@37
   119
			</xsl:if>
insilmaril@37
   120
insilmaril@37
   121
			<!-- Include note of mapcenter here -->
insilmaril@37
   122
			<xsl:apply-templates select="vymmap/mapcenter/note/@href"/>
insilmaril@37
   123
insilmaril@37
   124
insilmaril@37
   125
			<!-- Include all the branches, if not only image is wanted-->
insilmaril@37
   126
			<xsl:if test="$imageonly = ''">
insilmaril@37
   127
				<xsl:apply-templates select="vymmap/mapcenter/branch">
insilmaril@37
   128
					<xsl:with-param name="genarea" select="false()"/>
insilmaril@37
   129
					<xsl:with-param name="imageonly" select="$imageonly"/>
insilmaril@37
   130
					<xsl:with-param name="depth" select="0"/>
insilmaril@37
   131
				</xsl:apply-templates>
insilmaril@37
   132
			</xsl:if>
insilmaril@37
   133
insilmaril@37
   134
			<!-- Box at bottom of page, containing comment and author -->
insilmaril@37
   135
			<div class="vymBoxBottom">
insilmaril@37
   136
				<xsl:value-of select="vymmap/@comment"/>
insilmaril@37
   137
				<div class="vymBoxBottomR">
insilmaril@37
   138
					<xsl:value-of select="vymmap/@author"/>
insilmaril@37
   139
				</div>
insilmaril@37
   140
			</div>
insilmaril@37
   141
insilmaril@37
   142
			<!-- Footer containing filename, date, selfpromotion -->
insilmaril@37
   143
			<table class="vymFooter">
insilmaril@37
   144
				<tr>
insilmaril@37
   145
					<td class="vymFooterL">
insilmaril@37
   146
						<xsl:value-of select="$fn"/>.vym
insilmaril@37
   147
					</td>
insilmaril@37
   148
					<td class="vymFooterC">
insilmaril@37
   149
						<xsl:value-of select="vymmap/@date"/>
insilmaril@37
   150
					</td>
insilmaril@37
   151
					<td class="vymFooterR">
insilmaril@37
   152
						vym <xsl:value-of select="$mapversion"/> 
insilmaril@37
   153
					</td>  
insilmaril@37
   154
				</tr>
insilmaril@37
   155
			</table>
insilmaril@37
   156
insilmaril@37
   157
		</body>&#xA;
insilmaril@37
   158
	</html>&#xA;
insilmaril@37
   159
	</xsl:template><!-- Beginning of tranformation, "/" template -->
insilmaril@37
   160
insilmaril@37
   161
	
insilmaril@37
   162
	<!-- Main Function generating a branch  -->
insilmaril@37
   163
	<xsl:template match="branch">
insilmaril@37
   164
		<!-- Work a branch twice: a) make id for anchors, b) make output -->
insilmaril@37
   165
		<xsl:param name="genarea"/>
insilmaril@37
   166
		<xsl:param name="imageonly"/>
insilmaril@37
   167
		<xsl:param name="depth"/>
insilmaril@37
   168
		<xsl:if test="$genarea">
insilmaril@37
   169
			<!-- Generate id's and anchors, no output yet -->
insilmaril@37
   170
			<xsl:if test="(@x1 != '' and @y1 != '' and @x2 != '' and @y2 != '') and not(../@scrolled = 'yes')">
insilmaril@37
   171
				<!-- Heading is used in ALT field of anchor -->
insilmaril@37
   172
				<xsl:variable name="header">
insilmaril@37
   173
					<xsl:call-template name="getheading" >
insilmaril@37
   174
						<xsl:with-param name="txt" select="heading" />
insilmaril@37
   175
					</xsl:call-template>
insilmaril@37
   176
				</xsl:variable>
insilmaril@37
   177
insilmaril@37
   178
				<xsl:if test="($imageonly and @url) or ($imageonly and @vymLink) or $imageonly=''">
insilmaril@37
   179
					<area>
insilmaril@37
   180
					<xsl:attribute name="shape">
insilmaril@37
   181
						<xsl:text>rect</xsl:text>
insilmaril@37
   182
					</xsl:attribute>
insilmaril@37
   183
					<xsl:attribute name="coords">
insilmaril@37
   184
						<xsl:value-of select="@x1"/>
insilmaril@37
   185
						<xsl:text>,</xsl:text>
insilmaril@37
   186
						<xsl:value-of select="@y1"/>
insilmaril@37
   187
						<xsl:text>,</xsl:text>
insilmaril@37
   188
						<xsl:value-of select="@x2"/>
insilmaril@37
   189
						<xsl:text>,</xsl:text>
insilmaril@37
   190
						<xsl:value-of select="@y2"/>
insilmaril@37
   191
					</xsl:attribute>
insilmaril@37
   192
					<xsl:attribute name="href">
insilmaril@37
   193
						<xsl:if test="$imageonly = ''">
insilmaril@37
   194
							<xsl:text>#</xsl:text>
insilmaril@37
   195
							<xsl:value-of select="generate-id(.)"/>
insilmaril@37
   196
						</xsl:if>
insilmaril@37
   197
						<xsl:if test="$imageonly and @url">
insilmaril@37
   198
							<xsl:value-of select="@url"/>
insilmaril@37
   199
						</xsl:if>
insilmaril@37
   200
						<xsl:if test="$imageonly and @vymLink">
insilmaril@37
   201
							<xsl:value-of select="concat( substring-before(@vymLink, '.vym'), '.html')"/>
insilmaril@37
   202
						</xsl:if>
insilmaril@37
   203
					</xsl:attribute>
insilmaril@37
   204
					<xsl:attribute name="alt">
insilmaril@37
   205
						<xsl:value-of select="$header"/>
insilmaril@37
   206
					</xsl:attribute>
insilmaril@37
   207
					<xsl:attribute name="title">
insilmaril@37
   208
						<xsl:value-of select="$header"/>
insilmaril@37
   209
					</xsl:attribute>
insilmaril@37
   210
					</area>
insilmaril@37
   211
					<xsl:text>&#xA;</xsl:text>
insilmaril@37
   212
				</xsl:if>
insilmaril@37
   213
			</xsl:if> <!--generating id's and anchors -->
insilmaril@37
   214
insilmaril@37
   215
			<xsl:apply-templates select="branch">
insilmaril@37
   216
				<xsl:with-param name="genarea" select="true()"/>
insilmaril@37
   217
				<xsl:with-param name="imageonly" select="$imageonly"/>
insilmaril@37
   218
				<xsl:with-param name="depth" select="$depth +1"/>
insilmaril@37
   219
			</xsl:apply-templates>
insilmaril@37
   220
		</xsl:if><!--genarea-->
insilmaril@37
   221
insilmaril@37
   222
		
insilmaril@37
   223
		<xsl:if test="$imageonly = ''">
insilmaril@37
   224
			<xsl:if test="not($genarea)">
insilmaril@37
   225
				<xsl:call-template name="anchor">
insilmaril@37
   226
					<xsl:with-param name="depth" select="$depth"/>
insilmaril@37
   227
				</xsl:call-template>
insilmaril@37
   228
				<xsl:text>&#xA;</xsl:text>
insilmaril@37
   229
			</xsl:if>
insilmaril@37
   230
		</xsl:if>
insilmaril@37
   231
	</xsl:template><!--branch-->
insilmaril@37
   232
insilmaril@37
   233
insilmaril@37
   234
insilmaril@37
   235
	<xsl:template name="anchor">
insilmaril@37
   236
		<xsl:param name="depth"/>
insilmaril@37
   237
		<xsl:if test="$depth=0"> 
insilmaril@37
   238
			<hr />
insilmaril@37
   239
			<xsl:call-template name="gen-anchor-tag">
insilmaril@37
   240
				<xsl:with-param name="depth" select="$depth"/>
insilmaril@37
   241
			</xsl:call-template>
insilmaril@37
   242
				<xsl:if test="count(descendant::branch)">
insilmaril@37
   243
					<ul>
insilmaril@37
   244
					<xsl:apply-templates select="branch">
insilmaril@37
   245
						<xsl:with-param name="genarea" select="false()"/>
insilmaril@37
   246
						<xsl:with-param name="depth" select="$depth+1"/>
insilmaril@37
   247
					</xsl:apply-templates>
insilmaril@37
   248
					</ul>
insilmaril@37
   249
				</xsl:if>	
insilmaril@37
   250
		</xsl:if>
insilmaril@37
   251
insilmaril@37
   252
	<xsl:if test="$depth > 0">
insilmaril@37
   253
			<li>
insilmaril@37
   254
				<xsl:call-template name="gen-anchor-tag">
insilmaril@37
   255
					<xsl:with-param name="depth" select="$depth"/>
insilmaril@37
   256
				</xsl:call-template>
insilmaril@37
   257
				<xsl:if test="count(descendant::branch)">
insilmaril@37
   258
					<ul>
insilmaril@37
   259
					<xsl:apply-templates select="branch">
insilmaril@37
   260
						<xsl:with-param name="genarea" select="false()"/>
insilmaril@37
   261
						<xsl:with-param name="depth" select="$depth+1"/>
insilmaril@37
   262
					</xsl:apply-templates>
insilmaril@37
   263
					</ul>
insilmaril@37
   264
				</xsl:if>	
insilmaril@37
   265
			</li>
insilmaril@37
   266
		</xsl:if>
insilmaril@37
   267
	</xsl:template><!--anchor-->
insilmaril@37
   268
insilmaril@37
   269
insilmaril@37
   270
	<xsl:template name="gen-anchor-tag">
insilmaril@37
   271
		<xsl:param name="depth"/>
insilmaril@37
   272
insilmaril@37
   273
		<xsl:variable name="header">
insilmaril@37
   274
			<xsl:call-template name="getheading" >
insilmaril@37
   275
			<xsl:with-param name="txt" select="heading" />
insilmaril@37
   276
			</xsl:call-template>
insilmaril@37
   277
		</xsl:variable><!--header-->
insilmaril@37
   278
insilmaril@37
   279
		<div class="vymBranch{$depth}">
insilmaril@37
   280
			<xsl:if test="not($genimage = '')">
insilmaril@37
   281
				<a name="{generate-id(.)}"></a>
insilmaril@37
   282
			</xsl:if>
insilmaril@37
   283
insilmaril@37
   284
			<!-- start header -->
insilmaril@37
   285
			<xsl:value-of select="$header"/>
insilmaril@37
   286
insilmaril@37
   287
			<!-- Include flags -->
insilmaril@37
   288
			<xsl:apply-templates select="./standardFlag" />
insilmaril@37
   289
insilmaril@37
   290
			<!-- URL to external document  -->
insilmaril@37
   291
			<xsl:if test="@url != ''">
insilmaril@37
   292
				<p class="vymURL">
insilmaril@37
   293
				<xsl:element name="a">
insilmaril@37
   294
					<xsl:attribute name="href">
insilmaril@37
   295
						<xsl:value-of select="@url"/>
insilmaril@37
   296
					</xsl:attribute>
insilmaril@37
   297
					<xsl:if test="$urlImage= 'yes'">
insilmaril@37
   298
						<img src="flags/url.png" 
insilmaril@37
   299
							border="0" 
insilmaril@37
   300
							valign="middle"
insilmaril@37
   301
							alt="URL">
insilmaril@37
   302
						</img>
insilmaril@37
   303
					</xsl:if>
insilmaril@37
   304
					<xsl:if test="$urlImage!= 'yes'">
insilmaril@37
   305
						<xsl:text>&gt; </xsl:text>
insilmaril@37
   306
					</xsl:if>
insilmaril@37
   307
					<xsl:if test="$urlHeading = 'yes'">
insilmaril@37
   308
						<xsl:value-of select="$header"/>
insilmaril@37
   309
					</xsl:if>
insilmaril@37
   310
					<xsl:if test="$urlHeading != 'yes'">
insilmaril@37
   311
						<xsl:value-of select="@url"/>
insilmaril@37
   312
					</xsl:if>
insilmaril@37
   313
				</xsl:element>
insilmaril@37
   314
				</p>
insilmaril@37
   315
			</xsl:if><!-- URL to ext. doc -->
insilmaril@37
   316
			<xsl:text>&#xA;</xsl:text>
insilmaril@37
   317
		</div>
insilmaril@37
   318
insilmaril@37
   319
		<xsl:apply-templates select="note/@href"/>
insilmaril@37
   320
insilmaril@37
   321
		<xsl:text>&#xA;</xsl:text>
insilmaril@37
   322
	</xsl:template><!--gen-anchor-tag-->
insilmaril@37
   323
insilmaril@37
   324
insilmaril@37
   325
	<xsl:template match="standardFlag">
insilmaril@37
   326
		<xsl:variable name="flag" select="concat(., '.png')" />
insilmaril@37
   327
		<img src="flags/{$flag}" valign="middle" border="0" alt="{$flag}">
insilmaril@37
   328
		</img>
insilmaril@37
   329
insilmaril@37
   330
	</xsl:template><!--standardFlag-->
insilmaril@37
   331
insilmaril@37
   332
insilmaril@37
   333
	<xsl:template match="note/@href">
insilmaril@37
   334
		<div class="vymNote">
insilmaril@37
   335
		<xsl:variable name="actualnotename">
insilmaril@37
   336
			<xsl:value-of select="substring-after(current(),':')"/>
insilmaril@37
   337
		</xsl:variable>
insilmaril@37
   338
insilmaril@37
   339
		<xsl:variable name="note-name">
insilmaril@37
   340
			<xsl:if test="$path = ''">
insilmaril@37
   341
				<xsl:value-of select="$actualnotename"/>
insilmaril@37
   342
			</xsl:if>
insilmaril@37
   343
			<xsl:if test="not($path = '')">
insilmaril@37
   344
				<xsl:value-of select="concat($path, '/', $actualnotename)"/>
insilmaril@37
   345
			</xsl:if>
insilmaril@37
   346
		</xsl:variable><!--note-name-->
insilmaril@37
   347
insilmaril@37
   348
insilmaril@37
   349
		<xsl:if test="../@fonthint = 'fixed'">
insilmaril@37
   350
			<xsl:text disable-output-escaping="yes">&lt;pre></xsl:text>
insilmaril@37
   351
		</xsl:if>
insilmaril@37
   352
insilmaril@37
   353
		<xsl:variable name="currentID" select="@id" />
insilmaril@37
   354
insilmaril@37
   355
		<xsl:apply-templates select="document($note-name)/note">
insilmaril@37
   356
			<xsl:with-param name="currentID" select="$currentID" />
insilmaril@37
   357
		</xsl:apply-templates>
insilmaril@37
   358
insilmaril@37
   359
		<xsl:if test="../@fonthint = 'fixed'">
insilmaril@37
   360
			<xsl:text disable-output-escaping="yes">&lt;/pre></xsl:text>
insilmaril@37
   361
		</xsl:if>
insilmaril@37
   362
insilmaril@37
   363
		</div>
insilmaril@37
   364
	</xsl:template><!--note/@href-->
insilmaril@37
   365
insilmaril@37
   366
insilmaril@37
   367
  
insilmaril@37
   368
<!--	Wiki-style notation overview:
insilmaril@37
   369
  		Lines:
insilmaril@37
   370
		+ Big headlines start with the '+' character.
insilmaril@37
   371
		- Small headlines start with the '-' character.
insilmaril@37
   372
		Normal text doesn't have any starting notation.
insilmaril@37
   373
		! Notes start with an exclamation.
insilmaril@37
   374
		. Indented text starts with a dot.
insilmaril@37
   375
		? Questions start with a question-mark, and
insilmaril@37
   376
		= Answers starts with the equal-sign.
insilmaril@37
   377
		* Points for a item-list
insilmaril@37
   378
		# clues
insilmaril@37
   379
		
insilmaril@37
   380
		Links:
insilmaril@37
   381
		use "{...}" or {(Clemens homepage) http://www.clemens-kraus.de/} for external links.
insilmaril@37
   382
		
insilmaril@37
   383
		Markup:
insilmaril@37
   384
		|This is bold| text, while |/this text is italic|, |*this is pre-formatted|, and |!this is a note|
insilmaril@37
   385
	-->
insilmaril@37
   386
  
insilmaril@37
   387
	<xsl:template match="note">
insilmaril@37
   388
		<xsl:param name="currentID"/>
insilmaril@37
   389
insilmaril@37
   390
insilmaril@37
   391
		<xsl:call-template name="doLine">
insilmaril@37
   392
			<xsl:with-param name="content" select="concat(translate(.,$crlf,$controlCharacter), $controlCharacter)"/>
insilmaril@37
   393
			<xsl:with-param name="currentID" select="$currentID"/>
insilmaril@37
   394
		</xsl:call-template>
insilmaril@37
   395
	</xsl:template><!--note-->
insilmaril@37
   396
insilmaril@37
   397
	  
insilmaril@37
   398
  
insilmaril@37
   399
  
insilmaril@37
   400
  
insilmaril@37
   401
	<xsl:template name="getfn">
insilmaril@37
   402
		<xsl:param name="txt" select="." />
insilmaril@37
   403
insilmaril@37
   404
		<xsl:choose>
insilmaril@37
   405
			<xsl:when test="contains($txt, '/')" >
insilmaril@37
   406
				<xsl:variable name="right" select="substring-after($txt, '/')" />
insilmaril@37
   407
				<xsl:if test="string-length($right)>1" >
insilmaril@37
   408
					<xsl:call-template name="getfn" >
insilmaril@37
   409
						<xsl:with-param name="txt" select="$right" />
insilmaril@37
   410
					</xsl:call-template>
insilmaril@37
   411
				</xsl:if>
insilmaril@37
   412
			</xsl:when>
insilmaril@37
   413
			<xsl:otherwise>
insilmaril@37
   414
				<xsl:value-of select="$txt" />
insilmaril@37
   415
			</xsl:otherwise>
insilmaril@37
   416
		</xsl:choose>
insilmaril@37
   417
	</xsl:template><!--getfn-->
insilmaril@37
   418
insilmaril@37
   419
  
insilmaril@37
   420
	<!-- Take care of br's  (WHY?)  --> 
insilmaril@37
   421
	<xsl:template name="getheading">
insilmaril@37
   422
		<xsl:param name="txt" select="." />
insilmaril@37
   423
		<xsl:variable name="br">
insilmaril@37
   424
			<xsl:text disable-output-escaping="yes">&lt;br&gt;</xsl:text>
insilmaril@37
   425
		</xsl:variable>
insilmaril@37
   426
		<xsl:choose>
insilmaril@37
   427
			<xsl:when test="contains($txt, $br)" >
insilmaril@37
   428
				<xsl:variable name="right" select="substring-after($txt, $br)" />
insilmaril@37
   429
				<xsl:variable name="left" select="substring-before($txt, $br)" />
insilmaril@37
   430
				<xsl:value-of select="concat( $left, ' ', $right )" />
insilmaril@37
   431
			</xsl:when>
insilmaril@37
   432
			<xsl:otherwise>
insilmaril@37
   433
				<xsl:value-of select="$txt" />
insilmaril@37
   434
			</xsl:otherwise>
insilmaril@37
   435
		</xsl:choose>
insilmaril@37
   436
	</xsl:template><!--getheading-->
insilmaril@37
   437
  
insilmaril@37
   438
</xsl:stylesheet>
insilmaril@37
   439