1 <?xml version="1.0" encoding="UTF-8"?>
2 <!DOCTYPE xsl:stylesheet
4 <!-- Namespace for XHTML -->
5 <!ENTITY xhtmlns "http://www.w3.org/1999/xhtml">
9 Document : vym2xhtml.xsl
15 Author : Thomas Schraitle <tom_schr@web.de>
16 modified by Clemens Kraus (http://www.clemens-kraus.de)
17 Description : transforms vym-files into XHTML.
18 Bugs : Many. ;) Produces at the moment not valid XHTML
20 - li/ul structure not ok
21 Changes : - <br>s in headings removed
22 - error fixed in "alt" and "title"
25 <xsl:stylesheet version="1.0"
26 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
27 xmlns:date="http://exslt.org/dates-and-times"
28 extension-element-prefixes="date"
32 <xsl:output method="xml"
33 doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
34 doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
37 media-type="application/xhtml+xml"/>
41 <!-- ====================================================================== -->
42 <!-- 1 = true, 0 = false -->
44 <!-- URL to CSS stylesheet -->
45 <xsl:param name="css.stylesheet" select="'vym.css'"/>
47 <!-- Should a default CSS stylesheet be used? -->
48 <xsl:param name="use.default.css.stylesheet" select="1"/>
50 <!-- Should textcolors be used? -->
51 <xsl:param name="use.textcolor" select="0"/>
53 <!-- Should an imagemap be generated? -->
54 <xsl:param name="use.imagemap" select="1"/>
56 <!-- URL to image for imagemap -->
57 <xsl:param name="imagemap" select="''"/>
59 <!-- This stylesheet is able to process the following VYM version -->
60 <xsl:param name="vym.version" select="'1.7.7'"/>
62 <!-- Should the VYM XML format be checked -->
63 <xsl:param name="checkvym.version" select="1"/>
65 <!-- Which is the image extension? -->
66 <xsl:param name="image.extension" select="'.png'"/>
68 <!-- Where are the flags? -->
69 <xsl:param name="image.flags.path" select="'flags/'"/>
71 <!-- Filename of the XML document -->
72 <xsl:param name="mapname" />
74 <!-- Should a footer be generated? -->
75 <xsl:param name="use.footer" select="1"/>
77 <!-- How should Links generated:
78 name : Use only the name of the branch (default)
79 url : Use only the URL of the branch
82 <xsl:param name="link.style" select="'name'"/>
84 <!-- Accept different html-notes?
85 Only for imported MindManager maps! -->
86 <xsl:param name="use.diffnotes" select="0"/>
88 <!-- Debuggin on/off? -->
89 <xsl:param name="debug" select="0"/>
92 <xsl:template name="generate.footer">
93 <xsl:if test="$use.footer">
95 <table class="vym-footer">
97 <td class="vym-footerL"><xsl:value-of select="$mapname"/></td>
98 <td class="vym-footerC"><xsl:value-of select="vymmap/@date"/> </td>
99 <!--<td class="vym-footerC"><xsl:value-of select="date:date()"/></td>-->
100 <td class="vym-footerR">vym <xsl:value-of select="vymmap/@version"/></td>
110 <!-- ====================================================================== -->
111 <xsl:variable name="head.title">
113 <xsl:when test="/vymmap/mapcenter/heading">
115 <xsl:variable name="title">
116 <xsl:call-template name="gettitle" >
117 <xsl:with-param name="txt" select="/vymmap/mapcenter/heading" />
121 <xsl:value-of select="$title"/>
123 <xsl:otherwise></xsl:otherwise>
128 <xsl:variable name="default.css.stylesheet">
130 h1 {border-width: 1; border: solid; text-align: center}
131 div.imagemap { align: center; border: 0; }
136 <!-- ====================================================================== -->
137 <xsl:template name="generate.head">
139 <title><xsl:value-of select="$head.title"/></title>
140 <xsl:if test="$use.default.css.stylesheet">
141 <style type="text/css">
142 <xsl:value-of select="$default.css.stylesheet"/>
145 <xsl:if test="vymmap/@author!=''">
146 <meta name="author" content="{vymmap/@author}"/>
148 <xsl:if test="vymmap/@comment!=''">
149 <meta name="comment" content="{vymmap/@comment}"/>
151 <meta name="generator" content="vym"/>
152 <xsl:if test="$css.stylesheet!=''">
153 <link rel="stylesheet" id="css.stylesheet" href="{$css.stylesheet}"/>
159 <xsl:template name="check.vym.version">
160 <xsl:if test="$checkvym.version">
161 <xsl:if test="not(/vymmap/@version=$vym.version)">
163 <xsl:text> </xsl:text>
164 <xsl:text> WARNING:</xsl:text>
165 <xsl:text> This stylesheet applies to VYM XML format v.</xsl:text>
166 <xsl:value-of select="$vym.version"/>
167 <xsl:text>. Your XML format has v</xsl:text>
168 <xsl:value-of select="/vymmap/@version"/>
169 <xsl:text>. Check your HTML output!</xsl:text>
170 <xsl:text> </xsl:text>
177 <!-- ====================================================================== -->
178 <xsl:template match="*">
180 <xsl:text>WARNING: Unknown tag "</xsl:text>
181 <xsl:value-of select="local-name(.)"/>
182 <xsl:text>": </xsl:text>
183 <xsl:value-of select="normalize-space(.)"/>
184 <xsl:text> </xsl:text>
189 <xsl:template match="/">
190 <xsl:call-template name="check.vym.version"/>
192 <html xmlns="&xhtmlns;">
193 <xsl:call-template name="generate.head"/>
195 <xsl:apply-templates/>
196 <xsl:call-template name="generate.footer"/>
203 <xsl:template match="vymmap">
205 <xsl:apply-templates/>
210 <xsl:template match="mapcenter">
211 <div class="mapcenter">
212 <xsl:apply-templates/>
217 <xsl:template match="mapcenter/heading">
218 <div class="vym-header">
219 <xsl:apply-templates/>
222 <xsl:if test="$use.imagemap=1">
223 <div class="vym-imagemap">
224 <img src="{$imagemap}"
227 usemap="#vym_imagemap"/>
229 <map name="vym_imagemap">
230 <xsl:apply-templates select="../branch" mode="imagemap"/>
236 <xsl:template match="mapcenter/branch">
239 <xsl:apply-templates/>
244 <xsl:template match="branch">
246 <xsl:apply-templates/>
251 <xsl:template match="heading">
253 <span id="{generate-id(..)}">
254 <xsl:if test="@textColor!='' and $use.textcolor=1">
255 <xsl:attribute name="style" >color: <xsl:value-of select="@textColor" />
259 <xsl:when test="../@url">
260 <xsl:variable name="url" select="../@url"/>
262 <!-- Check, how links should be generated -->
264 <xsl:when test="$link.style = 'name'">
266 <img src="{concat($image.flags.path,'url-16x16.png')}" border="0" alt="URL"/>
267 <xsl:text> </xsl:text>
268 <xsl:apply-templates/>
271 <xsl:when test="$link.style = 'url'">
273 <img src="{concat($image.flags.path,'url-16x16.png')}" border="0" alt="URL"/>
274 <xsl:text> </xsl:text>
275 <xsl:value-of select="$url"/>
278 <xsl:when test="$link.style = 'both'">
280 <img src="{concat($image.flags.path,'url-16x16.png')}" border="0" alt="URL"/>
281 <xsl:text> </xsl:text>
282 <xsl:apply-templates/> (<xsl:value-of select="$url"/>)
287 <xsl:text>WARNING: Parameter link.style doesn't contain the correct</xsl:text>
288 <xsl:text> value (name|url|both)</xsl:text>
289 <xsl:text> was "</xsl:text>
290 <xsl:value-of select="$link.style"/>
291 <xsl:text>"</xsl:text>
293 <a href="{$url}"><xsl:apply-templates/></a>
299 <xsl:call-template name="gettitle" >
300 <xsl:with-param name="txt" select="." />
306 <xsl:for-each select="following-sibling::standardflag">
307 <xsl:apply-templates select="current()" mode="standardflag"/><xsl:text> </xsl:text>
314 <xsl:template match="floatimage">
315 <xsl:variable name="filename">
317 <xsl:when test="contains(@href,':')">
318 <xsl:value-of select="substring-after(@href,':')"/>
321 <xsl:value-of select="@href"/>
326 <xsl:if test="@floatExport='true'">
327 <span><img src="{$filename}" alt="{$filename}"/></span>
332 <xsl:template match="standardflag"/><!-- Do nothing in normal mode -->
334 <xsl:template match="standardflag" mode="standardflag">
335 <span class="standardflag">
336 <xsl:element name="img">
337 <xsl:variable name="_srcimg">
339 <xsl:when test="$image.flags.path">
340 <xsl:value-of select="concat($image.flags.path,
345 <xsl:value-of select="concat(., $image.extension)"/>
349 <xsl:attribute name="src">
350 <xsl:value-of select="$_srcimg"/>
352 <xsl:attribute name="alt">
353 <xsl:value-of select="$_srcimg"/>
360 <xsl:template match="select"/>
361 <xsl:template match="setting"/>
364 <xsl:template match="htmlnote">
365 <div class="vym-htmlnote">
367 <xsl:when test="$use.diffnotes=1">
368 <xsl:copy-of select="."/>
371 <xsl:apply-templates select=".//body/*"/><!-- Select only body elements -->
377 <!-- Do nothing! We don't need some informational elements -->
378 <xsl:template match="htmlnote/html/*"/>
380 <xsl:template match="htmlnote/html/body">
381 <xsl:copy-of select="."/>
384 <xsl:template match="htmlnote/html/body/*">
385 <xsl:copy-of select="."/>
389 <!-- ====================================================================== -->
390 <xsl:template match="branch" mode="imagemap">
391 <xsl:param name="node"/>
392 <xsl:variable name="title">
393 <xsl:apply-templates mode="imagemap"/>
396 <xsl:if test="$debug=1">
398 branch/heading = "<xsl:value-of select="normalize-space($title)"/>"
403 <xsl:attribute name="href">
404 <xsl:choose><!-- Fix begin (!) -->
405 <xsl:when test="$imagemap != ''">
406 <xsl:value-of select="concat('#', generate-id(.))"/>
408 <xsl:when test="$imagemap and @url">
409 <xsl:value-of select="@url"/>
411 <xsl:when test="$imagemap and @vymLink">
412 <xsl:value-of select="concat( substring-before(@vymLink,
415 </xsl:choose><!-- Fix end -->
417 <xsl:attribute name="alt">
418 <xsl:call-template name="gettitle" >
419 <xsl:with-param name="txt" select="heading" />
422 <xsl:attribute name="title">
423 <xsl:call-template name="gettitle" >
424 <xsl:with-param name="txt" select="heading" />
427 <xsl:attribute name="coords">
429 <xsl:when test="@x1!='' and @x2!='' and @y1!='' and @y2!=''">
430 <xsl:value-of select="@x1"/>
431 <xsl:text>,</xsl:text>
432 <xsl:value-of select="@y1"/>
433 <xsl:text>,</xsl:text>
434 <xsl:value-of select="@x2"/>
435 <xsl:text>,</xsl:text>
436 <xsl:value-of select="@y2"/>
441 <xsl:text>ERROR: Some coordinates in branch are
442 missing! </xsl:text>
443 <xsl:text> See branch with </xsl:text>
444 <xsl:value-of select="normalize-space($title)"/>
451 <xsl:apply-templates select="./branch" mode="imagemap"/>
455 <xsl:template match="heading" mode="imagemap">
456 <xsl:call-template name="gettitle" >
457 <xsl:with-param name="txt" select="." />
459 <!--<xsl:message>title2: <xsl:value-of select="$title" /></xsl:message>-->
461 <xsl:apply-templates mode="imagemap"/>
465 <xsl:template match="xlink">
466 <xsl:element name="a">
467 <xsl:attribute name="name">
468 <xsl:value-of select="translate(@beginBranch, ':,', '')"/>
473 <xsl:text>See: </xsl:text>
474 <xsl:element name="a">
475 <xsl:attribute name="href">
476 <xsl:text>#</xsl:text><!--<xsl:value-of select="translate(@endBranch, ':,', '')"/>-->
478 <!--<xsl:value-of select="translate(@endBranch, ':,', '')"/>-->reference
480 <!--<xsl:apply-templates/>-->
481 <!--<xsl:message>->xlink: <xsl:value-of select="concat(@endBranch, ' ', position())" /></xsl:message>-->
486 <xsl:template name="gettitle">
487 <xsl:param name="txt" select="." />
489 <xsl:variable name="br">
490 <xsl:text disable-output-escaping="yes"><br></xsl:text>
494 <xsl:when test="contains($txt, $br)" >
495 <xsl:variable name="right" select="substring-after($txt, $br)" />
496 <xsl:variable name="left" select="substring-before($txt, $br)" />
497 <xsl:variable name="txt" select="concat( $left, ' ', $right )" />
498 <xsl:call-template name="gettitle" >
499 <xsl:with-param name="txt" select="$txt" />
503 <xsl:value-of select="$txt" />