1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/styles/vym2html.xsl Wed Jan 16 15:45:20 2008 +0000
1.3 @@ -0,0 +1,439 @@
1.4 +<?xml version="1.0" encoding="UTF-8" ?>
1.5 +
1.6 +<!--
1.7 + Document : vym2html.xsl
1.8 + Created on : 20040313
1.9 + Modified : 20040512,20040622 Uwe Drechsel
1.10 + Version : 0.7
1.11 + Author : Clemens Kraus (http://www.clemens-kraus.de)
1.12 + Description: transforms vym-files into html format.
1.13 +
1.14 + Hint:
1.15 + tm.xsl and cm.xsl were taken from Alexander Johannesen's
1.16 + beautiful xSiteable content management system:
1.17 + http://xsiteable.org
1.18 + and are used with kind permission
1.19 +-->
1.20 +
1.21 +
1.22 +
1.23 +<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
1.24 +
1.25 + <!-- Include external stylesheets -->
1.26 + <xsl:include href="tm.xsl" />
1.27 + <xsl:include href="cm.xsl" />
1.28 +
1.29 + <!-- Settings and parameters -->
1.30 + <xsl:output method="html" indent="no" encoding="UTF-8"/>
1.31 + <xsl:param name="filenamep" />
1.32 + <xsl:param name="wikistylep" />
1.33 + <xsl:param name="genimagep" />
1.34 + <xsl:param name="imageonlyp" />
1.35 + <xsl:param name="stylesheetp" />
1.36 + <xsl:param name="urlHeadingp" />
1.37 + <xsl:param name="urlImagep" />
1.38 + <xsl:variable name="filename" select="$filenamep"/>
1.39 + <xsl:variable name="wikistyle" select="$wikistylep"/>
1.40 + <xsl:variable name="genimage" select="$genimagep"/>
1.41 + <xsl:variable name="imageonly" select="$imageonlyp"/>
1.42 + <xsl:variable name="stylesheet" select="$stylesheetp"/>
1.43 + <xsl:variable name="topics" select="//item" />
1.44 + <xsl:variable name="urlHeading" select="$urlHeadingp"/>
1.45 + <xsl:variable name="urlImage" select="$urlImagep"/>
1.46 +
1.47 + <xsl:variable name="level" select="'0'"/>
1.48 + <xsl:variable name="contentlist" select="false()"/>
1.49 +
1.50 +
1.51 + <xsl:variable name="fn" >
1.52 + <xsl:call-template name="getfn" >
1.53 + <xsl:with-param name="txt" select="$filename" />
1.54 + </xsl:call-template>
1.55 + </xsl:variable>
1.56 +
1.57 + <xsl:variable name="path" >
1.58 + <xsl:value-of select="normalize-space( substring($filename, 1, number(string-length($filename)-string-length($fn))) )" />
1.59 + </xsl:variable>
1.60 +
1.61 + <xsl:variable name="stylesheetn" >
1.62 + <xsl:call-template name="getfn" >
1.63 + <xsl:with-param name="txt" select="$stylesheet" />
1.64 + </xsl:call-template>
1.65 + </xsl:variable><!-- path -->
1.66 +
1.67 +
1.68 +
1.69 + <!-- Beginning of transformation here -->
1.70 + <xsl:template match="/">
1.71 + <xsl:variable name="mapversion" select="vymmap/@version"/>
1.72 + <xsl:variable name="header" >
1.73 + <xsl:call-template name="getheading" >
1.74 + <xsl:with-param name="txt" select="vymmap/mapcenter/heading" />
1.75 + </xsl:call-template>
1.76 + </xsl:variable><!-- header -->
1.77 +
1.78 + <!-- Write head of HTML document -->
1.79 + <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">]]>
</xsl:text>
1.80 + <html><xsl:text>
</xsl:text>
1.81 + <head><xsl:text>
</xsl:text>
1.82 + <title><xsl:value-of select="$header"/></title>
1.83 + <xsl:text disable-output-escaping="yes">
<![CDATA[<link href="]]></xsl:text>
1.84 + <xsl:value-of select="$stylesheetn"/>
1.85 + <xsl:text disable-output-escaping="yes"><![CDATA[" rel="stylesheet" id="]]></xsl:text>
1.86 + <xsl:value-of select="$stylesheetn"/>
1.87 + <xsl:text disable-output-escaping="yes"><![CDATA[">]]>
</xsl:text>
1.88 + <meta name="generator" content="vym (http://www.insilmaril.de/vym/) and vym2html.xsl (http://www.clemens-kraus.de)"/><xsl:text>
</xsl:text>
1.89 + </head>
1.90 + <xsl:text>
</xsl:text>
1.91 +
1.92 + <!-- Write body of HTML document -->
1.93 + <body>
1.94 + <!-- vym title box at top of page -->
1.95 + <xsl:text>
</xsl:text>
1.96 + <div class="vymTitleBox">
1.97 + <xsl:value-of select="$header"/>
1.98 + </div>
1.99 +
1.100 + <!-- Include image of map, if wanted -->
1.101 + <xsl:if test="$genimage != ''">
1.102 + <xsl:variable name="image" select="concat($fn, '.png')" />
1.103 +
1.104 + <div class="vymImageMap">
1.105 + <img src="images/{$image}"
1.106 + border="0"
1.107 + usemap="#vymmap"
1.108 + alt="vymmap">
1.109 + </img>
1.110 + </div>
1.111 + <xsl:text>
</xsl:text>
1.112 +
1.113 + <!-- Generate image map by a first walk through all branches -->
1.114 + <map name="vymmap">
1.115 + <xsl:apply-templates select="vymmap/mapcenter/branch">
1.116 + <xsl:with-param name="genarea" select="true()"/>
1.117 + <xsl:with-param name="imageonly" select="$imageonly"/>
1.118 + </xsl:apply-templates>
1.119 + </map>
1.120 +
1.121 + <xsl:text>
</xsl:text>
1.122 + </xsl:if>
1.123 +
1.124 + <!-- Include note of mapcenter here -->
1.125 + <xsl:apply-templates select="vymmap/mapcenter/note/@href"/>
1.126 +
1.127 +
1.128 + <!-- Include all the branches, if not only image is wanted-->
1.129 + <xsl:if test="$imageonly = ''">
1.130 + <xsl:apply-templates select="vymmap/mapcenter/branch">
1.131 + <xsl:with-param name="genarea" select="false()"/>
1.132 + <xsl:with-param name="imageonly" select="$imageonly"/>
1.133 + <xsl:with-param name="depth" select="0"/>
1.134 + </xsl:apply-templates>
1.135 + </xsl:if>
1.136 +
1.137 + <!-- Box at bottom of page, containing comment and author -->
1.138 + <div class="vymBoxBottom">
1.139 + <xsl:value-of select="vymmap/@comment"/>
1.140 + <div class="vymBoxBottomR">
1.141 + <xsl:value-of select="vymmap/@author"/>
1.142 + </div>
1.143 + </div>
1.144 +
1.145 + <!-- Footer containing filename, date, selfpromotion -->
1.146 + <table class="vymFooter">
1.147 + <tr>
1.148 + <td class="vymFooterL">
1.149 + <xsl:value-of select="$fn"/>.vym
1.150 + </td>
1.151 + <td class="vymFooterC">
1.152 + <xsl:value-of select="vymmap/@date"/>
1.153 + </td>
1.154 + <td class="vymFooterR">
1.155 + vym <xsl:value-of select="$mapversion"/>
1.156 + </td>
1.157 + </tr>
1.158 + </table>
1.159 +
1.160 + </body>

1.161 + </html>

1.162 + </xsl:template><!-- Beginning of tranformation, "/" template -->
1.163 +
1.164 +
1.165 + <!-- Main Function generating a branch -->
1.166 + <xsl:template match="branch">
1.167 + <!-- Work a branch twice: a) make id for anchors, b) make output -->
1.168 + <xsl:param name="genarea"/>
1.169 + <xsl:param name="imageonly"/>
1.170 + <xsl:param name="depth"/>
1.171 + <xsl:if test="$genarea">
1.172 + <!-- Generate id's and anchors, no output yet -->
1.173 + <xsl:if test="(@x1 != '' and @y1 != '' and @x2 != '' and @y2 != '') and not(../@scrolled = 'yes')">
1.174 + <!-- Heading is used in ALT field of anchor -->
1.175 + <xsl:variable name="header">
1.176 + <xsl:call-template name="getheading" >
1.177 + <xsl:with-param name="txt" select="heading" />
1.178 + </xsl:call-template>
1.179 + </xsl:variable>
1.180 +
1.181 + <xsl:if test="($imageonly and @url) or ($imageonly and @vymLink) or $imageonly=''">
1.182 + <area>
1.183 + <xsl:attribute name="shape">
1.184 + <xsl:text>rect</xsl:text>
1.185 + </xsl:attribute>
1.186 + <xsl:attribute name="coords">
1.187 + <xsl:value-of select="@x1"/>
1.188 + <xsl:text>,</xsl:text>
1.189 + <xsl:value-of select="@y1"/>
1.190 + <xsl:text>,</xsl:text>
1.191 + <xsl:value-of select="@x2"/>
1.192 + <xsl:text>,</xsl:text>
1.193 + <xsl:value-of select="@y2"/>
1.194 + </xsl:attribute>
1.195 + <xsl:attribute name="href">
1.196 + <xsl:if test="$imageonly = ''">
1.197 + <xsl:text>#</xsl:text>
1.198 + <xsl:value-of select="generate-id(.)"/>
1.199 + </xsl:if>
1.200 + <xsl:if test="$imageonly and @url">
1.201 + <xsl:value-of select="@url"/>
1.202 + </xsl:if>
1.203 + <xsl:if test="$imageonly and @vymLink">
1.204 + <xsl:value-of select="concat( substring-before(@vymLink, '.vym'), '.html')"/>
1.205 + </xsl:if>
1.206 + </xsl:attribute>
1.207 + <xsl:attribute name="alt">
1.208 + <xsl:value-of select="$header"/>
1.209 + </xsl:attribute>
1.210 + <xsl:attribute name="title">
1.211 + <xsl:value-of select="$header"/>
1.212 + </xsl:attribute>
1.213 + </area>
1.214 + <xsl:text>
</xsl:text>
1.215 + </xsl:if>
1.216 + </xsl:if> <!--generating id's and anchors -->
1.217 +
1.218 + <xsl:apply-templates select="branch">
1.219 + <xsl:with-param name="genarea" select="true()"/>
1.220 + <xsl:with-param name="imageonly" select="$imageonly"/>
1.221 + <xsl:with-param name="depth" select="$depth +1"/>
1.222 + </xsl:apply-templates>
1.223 + </xsl:if><!--genarea-->
1.224 +
1.225 +
1.226 + <xsl:if test="$imageonly = ''">
1.227 + <xsl:if test="not($genarea)">
1.228 + <xsl:call-template name="anchor">
1.229 + <xsl:with-param name="depth" select="$depth"/>
1.230 + </xsl:call-template>
1.231 + <xsl:text>
</xsl:text>
1.232 + </xsl:if>
1.233 + </xsl:if>
1.234 + </xsl:template><!--branch-->
1.235 +
1.236 +
1.237 +
1.238 + <xsl:template name="anchor">
1.239 + <xsl:param name="depth"/>
1.240 + <xsl:if test="$depth=0">
1.241 + <hr />
1.242 + <xsl:call-template name="gen-anchor-tag">
1.243 + <xsl:with-param name="depth" select="$depth"/>
1.244 + </xsl:call-template>
1.245 + <xsl:if test="count(descendant::branch)">
1.246 + <ul>
1.247 + <xsl:apply-templates select="branch">
1.248 + <xsl:with-param name="genarea" select="false()"/>
1.249 + <xsl:with-param name="depth" select="$depth+1"/>
1.250 + </xsl:apply-templates>
1.251 + </ul>
1.252 + </xsl:if>
1.253 + </xsl:if>
1.254 +
1.255 + <xsl:if test="$depth > 0">
1.256 + <li>
1.257 + <xsl:call-template name="gen-anchor-tag">
1.258 + <xsl:with-param name="depth" select="$depth"/>
1.259 + </xsl:call-template>
1.260 + <xsl:if test="count(descendant::branch)">
1.261 + <ul>
1.262 + <xsl:apply-templates select="branch">
1.263 + <xsl:with-param name="genarea" select="false()"/>
1.264 + <xsl:with-param name="depth" select="$depth+1"/>
1.265 + </xsl:apply-templates>
1.266 + </ul>
1.267 + </xsl:if>
1.268 + </li>
1.269 + </xsl:if>
1.270 + </xsl:template><!--anchor-->
1.271 +
1.272 +
1.273 + <xsl:template name="gen-anchor-tag">
1.274 + <xsl:param name="depth"/>
1.275 +
1.276 + <xsl:variable name="header">
1.277 + <xsl:call-template name="getheading" >
1.278 + <xsl:with-param name="txt" select="heading" />
1.279 + </xsl:call-template>
1.280 + </xsl:variable><!--header-->
1.281 +
1.282 + <div class="vymBranch{$depth}">
1.283 + <xsl:if test="not($genimage = '')">
1.284 + <a name="{generate-id(.)}"></a>
1.285 + </xsl:if>
1.286 +
1.287 + <!-- start header -->
1.288 + <xsl:value-of select="$header"/>
1.289 +
1.290 + <!-- Include flags -->
1.291 + <xsl:apply-templates select="./standardFlag" />
1.292 +
1.293 + <!-- URL to external document -->
1.294 + <xsl:if test="@url != ''">
1.295 + <p class="vymURL">
1.296 + <xsl:element name="a">
1.297 + <xsl:attribute name="href">
1.298 + <xsl:value-of select="@url"/>
1.299 + </xsl:attribute>
1.300 + <xsl:if test="$urlImage= 'yes'">
1.301 + <img src="flags/url.png"
1.302 + border="0"
1.303 + valign="middle"
1.304 + alt="URL">
1.305 + </img>
1.306 + </xsl:if>
1.307 + <xsl:if test="$urlImage!= 'yes'">
1.308 + <xsl:text>> </xsl:text>
1.309 + </xsl:if>
1.310 + <xsl:if test="$urlHeading = 'yes'">
1.311 + <xsl:value-of select="$header"/>
1.312 + </xsl:if>
1.313 + <xsl:if test="$urlHeading != 'yes'">
1.314 + <xsl:value-of select="@url"/>
1.315 + </xsl:if>
1.316 + </xsl:element>
1.317 + </p>
1.318 + </xsl:if><!-- URL to ext. doc -->
1.319 + <xsl:text>
</xsl:text>
1.320 + </div>
1.321 +
1.322 + <xsl:apply-templates select="note/@href"/>
1.323 +
1.324 + <xsl:text>
</xsl:text>
1.325 + </xsl:template><!--gen-anchor-tag-->
1.326 +
1.327 +
1.328 + <xsl:template match="standardFlag">
1.329 + <xsl:variable name="flag" select="concat(., '.png')" />
1.330 + <img src="flags/{$flag}" valign="middle" border="0" alt="{$flag}">
1.331 + </img>
1.332 +
1.333 + </xsl:template><!--standardFlag-->
1.334 +
1.335 +
1.336 + <xsl:template match="note/@href">
1.337 + <div class="vymNote">
1.338 + <xsl:variable name="actualnotename">
1.339 + <xsl:value-of select="substring-after(current(),':')"/>
1.340 + </xsl:variable>
1.341 +
1.342 + <xsl:variable name="note-name">
1.343 + <xsl:if test="$path = ''">
1.344 + <xsl:value-of select="$actualnotename"/>
1.345 + </xsl:if>
1.346 + <xsl:if test="not($path = '')">
1.347 + <xsl:value-of select="concat($path, '/', $actualnotename)"/>
1.348 + </xsl:if>
1.349 + </xsl:variable><!--note-name-->
1.350 +
1.351 +
1.352 + <xsl:if test="../@fonthint = 'fixed'">
1.353 + <xsl:text disable-output-escaping="yes"><pre></xsl:text>
1.354 + </xsl:if>
1.355 +
1.356 + <xsl:variable name="currentID" select="@id" />
1.357 +
1.358 + <xsl:apply-templates select="document($note-name)/note">
1.359 + <xsl:with-param name="currentID" select="$currentID" />
1.360 + </xsl:apply-templates>
1.361 +
1.362 + <xsl:if test="../@fonthint = 'fixed'">
1.363 + <xsl:text disable-output-escaping="yes"></pre></xsl:text>
1.364 + </xsl:if>
1.365 +
1.366 + </div>
1.367 + </xsl:template><!--note/@href-->
1.368 +
1.369 +
1.370 +
1.371 +<!-- Wiki-style notation overview:
1.372 + Lines:
1.373 + + Big headlines start with the '+' character.
1.374 + - Small headlines start with the '-' character.
1.375 + Normal text doesn't have any starting notation.
1.376 + ! Notes start with an exclamation.
1.377 + . Indented text starts with a dot.
1.378 + ? Questions start with a question-mark, and
1.379 + = Answers starts with the equal-sign.
1.380 + * Points for a item-list
1.381 + # clues
1.382 +
1.383 + Links:
1.384 + use "{...}" or {(Clemens homepage) http://www.clemens-kraus.de/} for external links.
1.385 +
1.386 + Markup:
1.387 + |This is bold| text, while |/this text is italic|, |*this is pre-formatted|, and |!this is a note|
1.388 + -->
1.389 +
1.390 + <xsl:template match="note">
1.391 + <xsl:param name="currentID"/>
1.392 +
1.393 +
1.394 + <xsl:call-template name="doLine">
1.395 + <xsl:with-param name="content" select="concat(translate(.,$crlf,$controlCharacter), $controlCharacter)"/>
1.396 + <xsl:with-param name="currentID" select="$currentID"/>
1.397 + </xsl:call-template>
1.398 + </xsl:template><!--note-->
1.399 +
1.400 +
1.401 +
1.402 +
1.403 +
1.404 + <xsl:template name="getfn">
1.405 + <xsl:param name="txt" select="." />
1.406 +
1.407 + <xsl:choose>
1.408 + <xsl:when test="contains($txt, '/')" >
1.409 + <xsl:variable name="right" select="substring-after($txt, '/')" />
1.410 + <xsl:if test="string-length($right)>1" >
1.411 + <xsl:call-template name="getfn" >
1.412 + <xsl:with-param name="txt" select="$right" />
1.413 + </xsl:call-template>
1.414 + </xsl:if>
1.415 + </xsl:when>
1.416 + <xsl:otherwise>
1.417 + <xsl:value-of select="$txt" />
1.418 + </xsl:otherwise>
1.419 + </xsl:choose>
1.420 + </xsl:template><!--getfn-->
1.421 +
1.422 +
1.423 + <!-- Take care of br's (WHY?) -->
1.424 + <xsl:template name="getheading">
1.425 + <xsl:param name="txt" select="." />
1.426 + <xsl:variable name="br">
1.427 + <xsl:text disable-output-escaping="yes"><br></xsl:text>
1.428 + </xsl:variable>
1.429 + <xsl:choose>
1.430 + <xsl:when test="contains($txt, $br)" >
1.431 + <xsl:variable name="right" select="substring-after($txt, $br)" />
1.432 + <xsl:variable name="left" select="substring-before($txt, $br)" />
1.433 + <xsl:value-of select="concat( $left, ' ', $right )" />
1.434 + </xsl:when>
1.435 + <xsl:otherwise>
1.436 + <xsl:value-of select="$txt" />
1.437 + </xsl:otherwise>
1.438 + </xsl:choose>
1.439 + </xsl:template><!--getheading-->
1.440 +
1.441 +</xsl:stylesheet>
1.442 +