1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/styles/vym2xhtml.xsl Thu Sep 22 12:14:23 2005 +0000
1.3 @@ -0,0 +1,430 @@
1.4 +<?xml version="1.0" encoding="ISO-8859-1"?>
1.5 +<!DOCTYPE xsl:stylesheet
1.6 +[
1.7 + <!-- Namespace for XHTML -->
1.8 + <!ENTITY xhtmlns "http://www.w3.org/1999/xhtml">
1.9 +]>
1.10 +
1.11 +<!--
1.12 + Document : vym2xhtml.xsl
1.13 + Created : 20040818
1.14 + License : GPL
1.15 + Version : 0.3.4
1.16 + VYM version : 1.6.0
1.17 + Author : Thomas Schraitle <tom_schr@web.de>
1.18 + Description : transforms vym-files into XHTML.
1.19 + Bugs : Many. ;) Produces at the moment not valid XHTML
1.20 + Needs to checked.
1.21 +-->
1.22 +
1.23 +<xsl:stylesheet version="1.0"
1.24 + xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
1.25 + xmlns:date="http://exslt.org/dates-and-times"
1.26 + extension-element-prefixes="date"
1.27 + xmlns="&xhtmlns;">
1.28 +
1.29 +
1.30 +<xsl:output method="xml"
1.31 + doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
1.32 + doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
1.33 + encoding="UTF-8"
1.34 + indent="yes"
1.35 + media-type="application/xhtml+xml"/>
1.36 +
1.37 +
1.38 +
1.39 +<!-- ====================================================================== -->
1.40 +<!-- 1 = true, 0 = false -->
1.41 +
1.42 +<!-- URL to CSS stylesheet -->
1.43 +<xsl:param name="css.stylesheet" select="'vym.css'"/>
1.44 +
1.45 +<!-- Should a default CSS stylesheet be used? -->
1.46 +<xsl:param name="use.default.css.stylesheet" select="1"/>
1.47 +
1.48 +<!-- Should textcolors be used? -->
1.49 +<xsl:param name="use.textcolor" select="0"/>
1.50 +
1.51 +<!-- Should an imagemap be generated? -->
1.52 +<xsl:param name="use.imagemap" select="1"/>
1.53 +
1.54 +<!-- URL to image for imagemap -->
1.55 +<xsl:param name="imagemap" select="''"/>
1.56 +
1.57 +<!-- This stylesheet is able to process the following VYM version -->
1.58 +<xsl:param name="vym.version" select="'1.6.0'"/>
1.59 +
1.60 +<!-- Should the VYM XML format be checked -->
1.61 +<xsl:param name="checkvym.version" select="1"/>
1.62 +
1.63 +<!-- Which is the image extension? -->
1.64 +<xsl:param name="image.extension" select="'.png'"/>
1.65 +
1.66 +<!-- Where are the flags? -->
1.67 +<xsl:param name="image.flags.path" select="'flags/'"/>
1.68 +
1.69 +<!-- Filename of the XML document -->
1.70 +<xsl:param name="mapname" />
1.71 +
1.72 +<!-- Should a footer be generated? -->
1.73 +<xsl:param name="use.footer" select="1"/>
1.74 +
1.75 +<!-- How should Links generated:
1.76 + name : Use only the name of the branch (default)
1.77 + url : Use only the URL of the branch
1.78 + both : Use both
1.79 +-->
1.80 +<xsl:param name="link.style" select="'name'"/>
1.81 +
1.82 +
1.83 +
1.84 +<!-- Debuggin on/off? -->
1.85 +<xsl:param name="debug" select="0"/>
1.86 +<xsl:template name="generate.footer">
1.87 + <xsl:if test="$use.footer">
1.88 + <hr/>
1.89 + <table class="vym-footer">
1.90 + <tr >
1.91 + <td class="vym-footerL"><xsl:value-of select="$mapname"/></td>
1.92 + <td class="vym-footerC"><xsl:value-of select="vymmap/@date"/> </td>
1.93 + <!--<td class="vym-footerC"><xsl:value-of select="date:date()"/></td>-->
1.94 + <td class="vym-footerR">vym <xsl:value-of select="vymmap/@version"/></td>
1.95 + </tr>
1.96 + </table>
1.97 + </xsl:if>
1.98 +</xsl:template>
1.99 +
1.100 +
1.101 +
1.102 +
1.103 +
1.104 +<!-- ====================================================================== -->
1.105 +<xsl:variable name="head.title">
1.106 + <xsl:choose>
1.107 + <xsl:when test="/vymmap/mapcenter/heading">
1.108 + <xsl:value-of select="normalize-space(/vymmap/mapcenter/heading)"/>
1.109 + </xsl:when>
1.110 + <xsl:otherwise></xsl:otherwise>
1.111 + </xsl:choose>
1.112 +</xsl:variable>
1.113 +
1.114 +
1.115 +<xsl:variable name="default.css.stylesheet">
1.116 + <xsl:text>
1.117 +h1 {border-width: 1; border: solid; text-align: center}
1.118 +div.imagemap { align: center; border: 0; }
1.119 + </xsl:text>
1.120 +</xsl:variable>
1.121 +
1.122 +
1.123 +<!-- ====================================================================== -->
1.124 +<xsl:template name="generate.head">
1.125 + <head>
1.126 + <title><xsl:value-of select="$head.title"/></title>
1.127 + <xsl:if test="$use.default.css.stylesheet">
1.128 + <style type="text/css">
1.129 + <xsl:value-of select="$default.css.stylesheet"/>
1.130 + </style>
1.131 + </xsl:if>
1.132 + <xsl:if test="vymmap/@author!=''">
1.133 + <meta name="author" content="{vymmap/@author}"/>
1.134 + </xsl:if>
1.135 + <xsl:if test="vymmap/@comment!=''">
1.136 + <meta name="comment" content="{vymmap/@comment}"/>
1.137 + </xsl:if>
1.138 + <meta name="generator" content="vym"/>
1.139 + <xsl:if test="$css.stylesheet!=''">
1.140 + <link rel="stylesheet" id="css.stylesheet" href="{$css.stylesheet}"/>
1.141 + </xsl:if>
1.142 + </head>
1.143 +</xsl:template>
1.144 +
1.145 +
1.146 +<xsl:template name="check.vym.version">
1.147 + <xsl:if test="$checkvym.version">
1.148 + <xsl:if test="not(/vymmap/@version=$vym.version)">
1.149 + <xsl:message>
1.150 + <xsl:text> </xsl:text>
1.151 + <xsl:text> WARNING:</xsl:text>
1.152 + <xsl:text> This stylesheet applies to VYM XML format v.</xsl:text>
1.153 + <xsl:value-of select="$vym.version"/>
1.154 + <xsl:text>. Your XML format has v</xsl:text>
1.155 + <xsl:value-of select="/vymmap/@version"/>
1.156 + <xsl:text>. Check your HTML output!</xsl:text>
1.157 + <xsl:text> </xsl:text>
1.158 + </xsl:message>
1.159 + </xsl:if>
1.160 + </xsl:if>
1.161 +</xsl:template>
1.162 +
1.163 +
1.164 +<!-- ====================================================================== -->
1.165 +<xsl:template match="*">
1.166 + <xsl:message>
1.167 + <xsl:text>WARNING: Unknown tag "</xsl:text>
1.168 + <xsl:value-of select="local-name(.)"/>
1.169 + <xsl:text>": </xsl:text>
1.170 + <xsl:value-of select="normalize-space(.)"/>
1.171 + <xsl:text> </xsl:text>
1.172 + </xsl:message>
1.173 +</xsl:template>
1.174 +
1.175 +
1.176 +<xsl:template match="/">
1.177 + <xsl:call-template name="check.vym.version"/>
1.178 +
1.179 + <html xmlns="&xhtmlns;">
1.180 + <xsl:call-template name="generate.head"/>
1.181 + <body>
1.182 + <xsl:apply-templates/>
1.183 + <xsl:call-template name="generate.footer"/>
1.184 +
1.185 + </body>
1.186 + </html>
1.187 +</xsl:template>
1.188 +
1.189 +
1.190 +<xsl:template match="vymmap">
1.191 + <div class="vymmap">
1.192 + <xsl:apply-templates/>
1.193 + </div>
1.194 +</xsl:template>
1.195 +
1.196 +
1.197 +<xsl:template match="mapcenter">
1.198 + <div class="mapcenter">
1.199 + <xsl:apply-templates/>
1.200 + </div>
1.201 +</xsl:template>
1.202 +
1.203 +
1.204 +<xsl:template match="mapcenter/heading">
1.205 + <div class="vym-header">
1.206 + <xsl:apply-templates/>
1.207 + </div>
1.208 +
1.209 + <xsl:if test="$use.imagemap=1">
1.210 + <div class="vym-imagemap">
1.211 + <img src="{$imagemap}"
1.212 + alt="Imagemap"
1.213 + class="imagemap"
1.214 + usemap="#vym_imagemap"/>
1.215 + </div>
1.216 + <map name="vym_imagemap">
1.217 + <xsl:apply-templates select="../branch" mode="imagemap"/>
1.218 + </map>
1.219 + </xsl:if>
1.220 +</xsl:template>
1.221 +
1.222 +
1.223 +<xsl:template match="mapcenter/branch">
1.224 + <hr/>
1.225 + <ul class="branch">
1.226 + <xsl:apply-templates/>
1.227 + </ul>
1.228 +</xsl:template>
1.229 +
1.230 +
1.231 +<xsl:template match="branch">
1.232 + <ul class="branch">
1.233 + <xsl:apply-templates/>
1.234 + </ul>
1.235 +</xsl:template>
1.236 +
1.237 +
1.238 +<xsl:template match="heading">
1.239 + <li class="heading">
1.240 + <span id="{generate-id(..)}">
1.241 + <xsl:if test="@textColor!='' and $use.textcolor=1">
1.242 + <xsl:attribute name="style" >color: <xsl:value-of select="@textColor" />
1.243 + </xsl:attribute>
1.244 + </xsl:if>
1.245 + <xsl:choose>
1.246 + <xsl:when test="../@url">
1.247 + <xsl:variable name="url" select="../@url"/>
1.248 +
1.249 + <!-- Check, how links should be generated -->
1.250 + <xsl:choose>
1.251 + <xsl:when test="$link.style = 'name'">
1.252 + <a href="{$url}">
1.253 + <img src="{concat($image.flags.path,'url.png')}" border="0" valign="middle" alt="URL"/>
1.254 + <xsl:apply-templates/>
1.255 + </a>
1.256 + </xsl:when>
1.257 + <xsl:when test="$link.style = 'url'">
1.258 + <a href="{$url}">
1.259 + <img src="{concat($image.flags.path,'url.png')}" border="0" valign="middle" alt="URL"/>
1.260 + <xsl:value-of select="$url"/>
1.261 + </a>
1.262 + </xsl:when>
1.263 + <xsl:when test="$link.style = 'both'">
1.264 + <a href="{$url}">
1.265 + <img src="{concat($image.flags.path,'url.png')}" border="0" valign="middle" alt="URL"/>
1.266 + <xsl:apply-templates/> ( <xsl:value-of select="$url"/>)
1.267 + </a>
1.268 + </xsl:when>
1.269 + <xsl:otherwise>
1.270 + <xsl:message>
1.271 + <xsl:text>WARNING: Parameter link.style doesn't contain the correct</xsl:text>
1.272 + <xsl:text> value (name|url|both)</xsl:text>
1.273 + <xsl:text> was "</xsl:text>
1.274 + <xsl:value-of select="$link.style"/>
1.275 + <xsl:text>"</xsl:text>
1.276 + </xsl:message>
1.277 + <a href="{$url}"><xsl:apply-templates/></a>
1.278 + </xsl:otherwise>
1.279 + </xsl:choose>
1.280 +
1.281 + </xsl:when>
1.282 + <xsl:otherwise>
1.283 + <xsl:apply-templates/>
1.284 + </xsl:otherwise>
1.285 + </xsl:choose>
1.286 +
1.287 + <xsl:for-each select="following-sibling::standardflag">
1.288 + <xsl:apply-templates select="current()" mode="standardflag"/>
1.289 + </xsl:for-each>
1.290 + </span>
1.291 + </li>
1.292 +</xsl:template>
1.293 +
1.294 +
1.295 +<xsl:template match="floatimage">
1.296 + <xsl:variable name="filename">
1.297 + <xsl:choose>
1.298 + <xsl:when test="contains(@href,':')">
1.299 + <xsl:value-of select="substring-after(@href,':')"/>
1.300 + </xsl:when>
1.301 + <xsl:otherwise>
1.302 + <xsl:value-of select="@href"/>
1.303 + </xsl:otherwise>
1.304 + </xsl:choose>
1.305 + </xsl:variable>
1.306 +
1.307 + <xsl:if test="@floatExport='true'">
1.308 + <span><img src="{$filename}" alt="{$filename}"/></span>
1.309 + </xsl:if>
1.310 +</xsl:template>
1.311 +
1.312 +
1.313 +<xsl:template match="standardflag"/><!-- Do nothing in normal mode -->
1.314 +
1.315 +<xsl:template match="standardflag" mode="standardflag">
1.316 + <span class="standardflag">
1.317 + <xsl:element name="img">
1.318 + <xsl:variable name="_srcimg">
1.319 + <xsl:choose>
1.320 + <xsl:when test="$image.flags.path">
1.321 + <xsl:value-of select="concat($image.flags.path,
1.322 + .,
1.323 + $image.extension)"/>
1.324 + </xsl:when>
1.325 + <xsl:otherwise>
1.326 + <xsl:value-of select="concat(., $image.extension)"/>
1.327 + </xsl:otherwise>
1.328 + </xsl:choose>
1.329 + </xsl:variable>
1.330 + <xsl:attribute name="src">
1.331 + <xsl:value-of select="$_srcimg"/>
1.332 + </xsl:attribute>
1.333 + <xsl:attribute name="alt">
1.334 + <xsl:value-of select="$_srcimg"/>
1.335 + </xsl:attribute>
1.336 + </xsl:element>
1.337 + </span>
1.338 +</xsl:template>
1.339 +
1.340 +<!-- Do nothing! -->
1.341 +<xsl:template match="select"/>
1.342 +<xsl:template match="setting"/>
1.343 +
1.344 +
1.345 +<xsl:template match="htmlnote">
1.346 + <div class="vym-htmlnote" >
1.347 + <xsl:apply-templates select=".//body/*"/><!-- Select only body elements -->
1.348 + </div>
1.349 +</xsl:template>
1.350 +
1.351 +<!-- Do nothing! We don't need some informational elements -->
1.352 +<xsl:template match="htmlnote/html/*"/>
1.353 +
1.354 +<xsl:template match="htmlnote/html/body">
1.355 + <xsl:copy-of select="."/>
1.356 +</xsl:template>
1.357 +
1.358 +<xsl:template match="htmlnote/html/body/*">
1.359 + <xsl:copy-of select="."/>
1.360 +</xsl:template>
1.361 +
1.362 +
1.363 +<!-- ====================================================================== -->
1.364 +<xsl:template match="branch" mode="imagemap">
1.365 + <xsl:param name="node"/>
1.366 + <xsl:variable name="title">
1.367 + <xsl:apply-templates mode="imagemap"/>
1.368 + </xsl:variable>
1.369 +
1.370 + <xsl:if test="$debug=1">
1.371 + <xsl:message>
1.372 + branch/heading = "<xsl:value-of select="normalize-space($title)"/>"
1.373 + x1, x2 = <xsl:value-of select="concat(@x1, '/', @x2)"/>
1.374 + y1, y2 = <xsl:value-of select="concat(@y1, '/', @y2)"/>
1.375 + </xsl:message>
1.376 + </xsl:if>
1.377 +
1.378 + <area shape="rect">
1.379 + <xsl:attribute name="href">
1.380 + <xsl:choose><!-- Fix begin (!) -->
1.381 + <xsl:when test="$imagemap != ''">
1.382 + <xsl:value-of select="concat('#', generate-id(.))"/>
1.383 + </xsl:when>
1.384 + <xsl:when test="$imagemap and @url">
1.385 + <xsl:value-of select="@url"/>
1.386 + </xsl:when>
1.387 + <xsl:when test="$imagemap and @vymLink">
1.388 + <xsl:value-of select="concat( substring-before(@vymLink,
1.389 +'.vym'), '.html')"/>
1.390 + </xsl:when>
1.391 + </xsl:choose><!-- Fix end -->
1.392 + </xsl:attribute>
1.393 + <xsl:attribute name="alt">
1.394 + <xsl:value-of select="normalize-space($title)"/>
1.395 + </xsl:attribute>
1.396 + <xsl:attribute name="title">
1.397 + <xsl:value-of select="normalize-space($title)"/>
1.398 + </xsl:attribute>
1.399 + <xsl:attribute name="coords">
1.400 + <xsl:choose>
1.401 + <xsl:when test="@x1!='' and @x2!='' and @y1!='' and @y2!=''">
1.402 + <xsl:value-of select="@x1"/>
1.403 + <xsl:text>,</xsl:text>
1.404 + <xsl:value-of select="@y1"/>
1.405 + <xsl:text>,</xsl:text>
1.406 + <xsl:value-of select="@x2"/>
1.407 + <xsl:text>,</xsl:text>
1.408 + <xsl:value-of select="@y2"/>
1.409 + </xsl:when>
1.410 + <xsl:otherwise>
1.411 + <!--
1.412 + <xsl:message>
1.413 + <xsl:text>ERROR: Some coordinates in branch are
1.414 +missing! </xsl:text>
1.415 + <xsl:text> See branch with </xsl:text>
1.416 + <xsl:value-of select="normalize-space($title)"/>
1.417 + </xsl:message>
1.418 + //-->
1.419 + </xsl:otherwise>
1.420 + </xsl:choose>
1.421 + </xsl:attribute>
1.422 + </area>
1.423 + <xsl:apply-templates select="./branch" mode="imagemap"/>
1.424 +</xsl:template>
1.425 +
1.426 +
1.427 +
1.428 +<xsl:template match="heading" mode="imagemap">
1.429 + <xsl:apply-templates mode="imagemap"/>
1.430 +</xsl:template>
1.431 +
1.432 +
1.433 +</xsl:stylesheet>
1.434 \ No newline at end of file