Removed more QT3 stuff. Drag & Drop not 100% functional at the moment
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.10'"/>
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>
127 <xsl:variable name="default.css.stylesheet">
129 h1 {border-width: 1; border: solid; text-align: center}
130 div.imagemap { align: center; border: 0; }
135 <!-- ====================================================================== -->
136 <xsl:template name="generate.head">
138 <title><xsl:value-of select="$head.title"/></title>
139 <xsl:if test="$use.default.css.stylesheet">
140 <style type="text/css">
141 <xsl:value-of select="$default.css.stylesheet"/>
144 <xsl:if test="vymmap/@author!=''">
145 <meta name="author" content="{vymmap/@author}"/>
147 <xsl:if test="vymmap/@comment!=''">
148 <meta name="comment" content="{vymmap/@comment}"/>
150 <meta name="generator" content="vym"/>
151 <xsl:if test="$css.stylesheet!=''">
152 <link rel="stylesheet" id="css.stylesheet" href="{$css.stylesheet}"/>
158 <xsl:template name="check.vym.version">
159 <xsl:if test="$checkvym.version">
160 <xsl:if test="not(/vymmap/@version=$vym.version)">
162 <xsl:text> </xsl:text>
163 <xsl:text> WARNING:</xsl:text>
164 <xsl:text> This stylesheet applies to VYM XML format v.</xsl:text>
165 <xsl:value-of select="$vym.version"/>
166 <xsl:text>. Your XML format has v</xsl:text>
167 <xsl:value-of select="/vymmap/@version"/>
168 <xsl:text>. Check your HTML output!</xsl:text>
169 <xsl:text> </xsl:text>
176 <!-- ====================================================================== -->
177 <xsl:template match="*">
179 <xsl:text>WARNING: Unknown tag "</xsl:text>
180 <xsl:value-of select="local-name(.)"/>
181 <xsl:text>": </xsl:text>
182 <xsl:value-of select="normalize-space(.)"/>
183 <xsl:text> </xsl:text>
188 <xsl:template match="/">
189 <xsl:call-template name="check.vym.version"/>
191 <html xmlns="&xhtmlns;">
192 <xsl:call-template name="generate.head"/>
194 <xsl:apply-templates/>
195 <xsl:call-template name="generate.footer"/>
201 <xsl:template match="vymmap">
203 <xsl:apply-templates/>
208 <xsl:template match="mapcenter">
209 <div class="mapcenter">
210 <xsl:apply-templates/>
215 <xsl:template match="mapcenter/heading">
216 <div class="vym-header">
217 <xsl:apply-templates/>
220 <xsl:if test="$use.imagemap=1">
221 <div class="vym-imagemap">
222 <img src="{$imagemap}"
225 usemap="#vym_imagemap"/>
227 <map name="vym_imagemap">
228 <xsl:apply-templates select="../branch" mode="imagemap"/>
234 <xsl:template match="mapcenter/branch">
237 <xsl:apply-templates/>
242 <xsl:template match="branch">
244 <xsl:apply-templates/>
249 <xsl:template match="heading">
251 <span id="{generate-id(..)}">
252 <xsl:if test="@textColor!='' and $use.textcolor=1">
253 <xsl:attribute name="style" >color: <xsl:value-of select="@textColor" />
257 <xsl:when test="../@url">
258 <xsl:variable name="url" select="../@url"/>
260 <!-- Check, how links should be generated -->
262 <xsl:when test="$link.style = 'name'">
264 <img src="{concat($image.flags.path,'flag-url-16x16.png')}" border="0" alt="URL"/>
265 <xsl:text> </xsl:text>
266 <xsl:apply-templates/>
269 <xsl:when test="$link.style = 'url'">
271 <img src="{concat($image.flags.path,'flag-url-16x16.png')}" border="0" alt="URL"/>
272 <xsl:text> </xsl:text>
273 <xsl:value-of select="$url"/>
276 <xsl:when test="$link.style = 'both'">
278 <img src="{concat($image.flags.path,'flag-url-16x16.png')}" border="0" alt="URL"/>
279 <xsl:text> </xsl:text>
280 <xsl:apply-templates/> (<xsl:value-of select="$url"/>)
285 <xsl:text>WARNING: Parameter link.style doesn't contain the correct</xsl:text>
286 <xsl:text> value (name|url|both)</xsl:text>
287 <xsl:text> was "</xsl:text>
288 <xsl:value-of select="$link.style"/>
289 <xsl:text>"</xsl:text>
291 <a href="{$url}"><xsl:apply-templates/></a>
297 <xsl:call-template name="gettitle" >
298 <xsl:with-param name="txt" select="." />
304 <xsl:for-each select="following-sibling::standardflag">
305 <xsl:apply-templates select="current()" mode="standardflag"/><xsl:text> </xsl:text>
312 <xsl:template match="floatimage">
313 <xsl:variable name="filename">
315 <xsl:when test="contains(@href,':')">
316 <xsl:value-of select="substring-after(@href,':')"/>
319 <xsl:value-of select="@href"/>
324 <xsl:if test="@floatExport='true'">
325 <span><img src="{$filename}" alt="{$filename}"/></span>
330 <xsl:template match="standardflag"/><!-- Do nothing in normal mode -->
332 <xsl:template match="standardflag" mode="standardflag">
333 <span class="standardflag">
334 <xsl:element name="img">
335 <xsl:variable name="_srcimg">
337 <xsl:when test="$image.flags.path">
338 <xsl:value-of select="concat($image.flags.path,
343 <xsl:value-of select="concat(., $image.extension)"/>
347 <xsl:attribute name="src">
348 <xsl:value-of select="$_srcimg"/>
350 <xsl:attribute name="alt">
351 <xsl:value-of select="$_srcimg"/>
358 <xsl:template match="select"/>
359 <xsl:template match="setting"/>
362 <xsl:template match="htmlnote">
363 <div class="vym-htmlnote">
365 <xsl:when test="$use.diffnotes=1">
366 <xsl:copy-of select="."/>
369 <xsl:apply-templates select=".//body/*"/><!-- Select only body elements -->
375 <!-- Do nothing! We don't need some informational elements -->
376 <xsl:template match="htmlnote/html/*"/>
378 <xsl:template match="htmlnote/html/body">
379 <xsl:copy-of select="."/>
382 <xsl:template match="htmlnote/html/body/*">
383 <xsl:copy-of select="."/>
387 <!-- ====================================================================== -->
388 <xsl:template match="branch" mode="imagemap">
389 <xsl:param name="node"/>
390 <xsl:variable name="title">
391 <xsl:apply-templates mode="imagemap"/>
394 <xsl:if test="$debug=1">
396 branch/heading = "<xsl:value-of select="normalize-space($title)"/>"
401 <xsl:attribute name="href">
402 <xsl:choose><!-- Fix begin (!) -->
403 <xsl:when test="$imagemap != ''">
404 <xsl:value-of select="concat('#', generate-id(.))"/>
406 <xsl:when test="$imagemap and @url">
407 <xsl:value-of select="@url"/>
409 <xsl:when test="$imagemap and @vymLink">
410 <xsl:value-of select="concat( substring-before(@vymLink,
413 </xsl:choose><!-- Fix end -->
415 <xsl:attribute name="alt">
416 <xsl:call-template name="gettitle" >
417 <xsl:with-param name="txt" select="heading" />
420 <xsl:attribute name="title">
421 <xsl:call-template name="gettitle" >
422 <xsl:with-param name="txt" select="heading" />
425 <xsl:attribute name="coords">
427 <xsl:when test="@x1!='' and @x2!='' and @y1!='' and @y2!=''">
428 <xsl:value-of select="@x1"/>
429 <xsl:text>,</xsl:text>
430 <xsl:value-of select="@y1"/>
431 <xsl:text>,</xsl:text>
432 <xsl:value-of select="@x2"/>
433 <xsl:text>,</xsl:text>
434 <xsl:value-of select="@y2"/>
439 <xsl:text>ERROR: Some coordinates in branch are
440 missing! </xsl:text>
441 <xsl:text> See branch with </xsl:text>
442 <xsl:value-of select="normalize-space($title)"/>
449 <xsl:apply-templates select="./branch" mode="imagemap"/>
453 <xsl:template match="heading" mode="imagemap">
454 <xsl:call-template name="gettitle" >
455 <xsl:with-param name="txt" select="." />
457 <!--<xsl:message>title2: <xsl:value-of select="$title" /></xsl:message>-->
459 <xsl:apply-templates mode="imagemap"/>
463 <xsl:template match="xlink">
464 <xsl:element name="a">
465 <xsl:attribute name="name">
466 <xsl:value-of select="translate(@beginBranch, ':,', '')"/>
471 <xsl:text>See: </xsl:text>
472 <xsl:element name="a">
473 <xsl:attribute name="href">
474 <xsl:text>#</xsl:text><!--<xsl:value-of select="translate(@endBranch, ':,', '')"/>-->
476 <!--<xsl:value-of select="translate(@endBranch, ':,', '')"/>-->reference
478 <!--<xsl:apply-templates/>-->
479 <!--<xsl:message>->xlink: <xsl:value-of select="concat(@endBranch, ' ', position())" /></xsl:message>-->
484 <xsl:template name="gettitle">
485 <xsl:param name="txt" select="." />
487 <xsl:variable name="br">
488 <xsl:text disable-output-escaping="yes"><br></xsl:text>
492 <xsl:when test="contains($txt, $br)" >
493 <xsl:variable name="right" select="substring-after($txt, $br)" />
494 <xsl:variable name="left" select="substring-before($txt, $br)" />
495 <xsl:variable name="txt" select="concat( $left, ' ', $right )" />
496 <xsl:call-template name="gettitle" >
497 <xsl:with-param name="txt" select="$txt" />
501 <xsl:value-of select="$txt" />