Created
April 10, 2015 11:03
-
-
Save danielres/83c7ede91c2aef439e04 to your computer and use it in GitHub Desktop.
XSLT to transform freeplane mindmaps (.mm) to pretty html files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0"?> | |
<xsl:stylesheet | |
version="1.0" | |
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | |
xmlns:ex="http://exslt.org/dates-and-times" | |
extension-element-prefixes="ex"> | |
<xsl:output | |
method="xml" | |
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" | |
doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" | |
indent="yes"/> | |
<xsl:template match="/ | @* | node()"> | |
<xsl:copy> | |
<xsl:apply-templates select="@* | node()" /> | |
</xsl:copy> | |
</xsl:template> | |
<xsl:template match="/"> | |
<html> | |
<head> | |
<meta charset='utf-8' /> | |
<meta content='IE=edge,chrome=1' http-equiv='X-UA-Compatible' /> | |
<title><xsl:value-of select="/*/node/@TEXT" /></title> | |
<style type="text/css"> | |
body { | |
background: white; | |
font-family: verdana, sans-serif; | |
font-size: 14px; | |
padding: 0px; | |
margin: 60px; | |
} | |
h1, h2, h3 { | |
font-weight: normal; | |
} | |
h1 { | |
color: #32568C; | |
font-size: 1.8em; | |
margin-bottom: 2em; | |
} | |
h2 { | |
color: #6C5640; | |
border-bottom: 3px solid; | |
margin-top: 1.5em; | |
margin-bottom: 1.5em; | |
} | |
h3{ | |
color: #007326; | |
border-bottom: 1px dashed; | |
margin-top: 1.5em; | |
margin-bottom: 1.5em; | |
} | |
body>ul{ | |
margin-top: 0.5em; | |
margin-bottom: 0.5em; | |
list-style: none; | |
} | |
body>ul>li>ul{ | |
margin-top: 0.25em; | |
margin-bottom: 0.25em; | |
color: #555; | |
} | |
body>ul>li>ul>li>ul{ | |
margin-top: 0.125em; | |
margin-bottom: 0.125em; | |
} | |
body>ul>li{ | |
margin-bottom: 1em; | |
} | |
body>ul>li>ul>li{ | |
font-size: 0.9em | |
} | |
</style> | |
<script src="script.js" type="text/javascript"></script> | |
</head> | |
<body> | |
<xsl:value-of select="ex:date()"/> - | |
<xsl:value-of select="ex:time()"/> | |
<xsl:apply-templates /> | |
</body> | |
</html> | |
</xsl:template> | |
<xsl:template match="/map"> | |
<xsl:apply-templates select="node()" /> | |
</xsl:template> | |
<xsl:template match="//stylenode | //edge | //map_styles | //hook | //font"> | |
</xsl:template> | |
<xsl:template match="/*/node"> | |
<h1><xsl:value-of select="@TEXT" /></h1> | |
<xsl:apply-templates /> | |
</xsl:template> | |
<xsl:template match="/*/node/node"> | |
<h2><xsl:value-of select="1 + count(preceding-sibling::node)" />. <xsl:value-of select="@TEXT" /></h2> | |
<xsl:apply-templates /> | |
</xsl:template> | |
<xsl:template match="/*/node/node/node"> | |
<p><xsl:value-of select="@TEXT" /></p> | |
</xsl:template> | |
<xsl:template match="/*/node/node/node[node]"> | |
<h3> | |
<xsl:value-of select="1 + count(../preceding-sibling::node)" />.<xsl:value-of select="1 + count(preceding-sibling::node)" />. | |
<xsl:value-of select="@TEXT" /> | |
</h3> | |
<ul><xsl:apply-templates /></ul> | |
</xsl:template> | |
<xsl:template match="/*/node/node/node//node"> | |
<li> | |
<xsl:value-of select="@TEXT" /> | |
</li> | |
</xsl:template> | |
<xsl:template match="/*/node/node/node//node[node]"> | |
<li> | |
<xsl:value-of select="@TEXT" /> | |
<ul><xsl:apply-templates /></ul> | |
</li> | |
</xsl:template> | |
</xsl:stylesheet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment