1
<?xml version="1.0" encoding="UTF-8"?>
3
(c) by Naoki Nose, Eric Lavarde 2006-2008
4
This code is licensed under the GPLv2 or later.
5
(http://www.gnu.org/copyleft/gpl.html)
6
Stylesheet to transform a FreeMind map into an Excel sheet, use menu point
7
File -> Export -> Using XSLT... to choose this XSL file, and name the
8
ExportFile Something.xls or Something.xml.
9
2006-12-10: added support for notes and attributes (EWL)
10
2008-10-23: corrected issue with ss namespace not being output (EWL)
12
<xsl:stylesheet version="1.0"
13
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
14
xmlns="urn:schemas-microsoft-com:office:spreadsheet"
15
xmlns:o="urn:schemas-microsoft-com:office:office"
16
xmlns:x="urn:schemas-microsoft-com:office:excel"
17
xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
18
xmlns:duss="urn:schemas-microsoft-com:office:dummyspreadsheet">
19
<xsl:output method="xml" indent="yes" encoding="UTF-8" standalone="yes"/>
20
<!-- the duss namespace alias is required in order to be able to output
21
ss:Data properly, Excel ignores the extraneous dummy namespace. -->
22
<xsl:namespace-alias stylesheet-prefix="duss" result-prefix="ss"/>
24
<xsl:template match="/map">
25
<xsl:processing-instruction name="mso-application"> progid="Excel.Sheet"</xsl:processing-instruction>
28
<Style ss:ID="s16" ss:Name="attribute_cell">
30
<Border ss:Position="Bottom" ss:LineStyle="Continuous" ss:Weight="1"/>
31
<Border ss:Position="Left" ss:LineStyle="Continuous" ss:Weight="1"/>
32
<Border ss:Position="Right" ss:LineStyle="Continuous" ss:Weight="1"/>
33
<Border ss:Position="Top" ss:LineStyle="Continuous" ss:Weight="1"/>
36
<Style ss:ID="s17" ss:Name="attribute_header">
38
<Border ss:Position="Bottom" ss:LineStyle="Continuous" ss:Weight="1"/>
39
<Border ss:Position="Left" ss:LineStyle="Continuous" ss:Weight="1"/>
40
<Border ss:Position="Right" ss:LineStyle="Continuous" ss:Weight="1"/>
41
<Border ss:Position="Top" ss:LineStyle="Continuous" ss:Weight="1"/>
46
<!-- we could probably put something more intelligent as worksheet name,
47
but it would require name mangling to avoid unallowed characters -->
48
<Worksheet ss:Name="FreeMind Sheet">
50
<xsl:apply-templates select="node">
51
<xsl:with-param name="index" select="1" />
52
</xsl:apply-templates>
58
<xsl:template match="node">
59
<xsl:param name="index" />
60
<Row><Cell ss:Index="{$index}">
61
<xsl:call-template name="output-node-text-as-data" />
63
<xsl:if test="attribute">
64
<Cell ss:StyleID="s17">
65
<Data ss:Type="String">Names</Data></Cell>
66
<Cell ss:StyleID="s17">
67
<Data ss:Type="String">Values</Data></Cell>
70
<xsl:apply-templates select="attribute">
71
<xsl:with-param name="index" select="$index + 1" />
72
</xsl:apply-templates>
73
<xsl:apply-templates select="node">
74
<xsl:with-param name="index" select="$index + 1" />
75
</xsl:apply-templates>
78
<xsl:template match="attribute">
79
<xsl:param name="index" />
80
<Row><Cell ss:Index="{$index}" ss:StyleID="s16">
81
<Data ss:Type="String"><xsl:value-of select="@NAME" /></Data>
83
<Cell ss:StyleID="s16">
84
<Data ss:Type="String"><xsl:value-of select="@VALUE" /></Data>
89
<xsl:template name="output-node-text-as-data">
91
<xsl:when test="richcontent[@TYPE='NODE']">
92
<!-- see comments about rich text and HTML format below -->
93
<duss:Data ss:Type="String" xmlns="http://www.w3.org/TR/REC-html40"><xsl:copy-of select="richcontent[@TYPE='NODE']/html/body/*" /></duss:Data>
96
<Data ss:Type="String"><xsl:value-of select="@TEXT"/></Data>
97
<!-- xsl:value-of select="normalize-space(@TEXT)" / -->
100
<xsl:call-template name="output-note-text-as-comment" />
103
<!-- export of rich text in HTML format should work, but formatting is lost
104
because Excel understands only HTML tags in capitals, whereas
105
FreeMind exports in small caps. This can probably be solved but would
106
require some more tweaking -->
107
<xsl:template name="output-note-text-as-comment">
108
<xsl:if test="richcontent[@TYPE='NOTE']">
109
<Comment><duss:Data xmlns="http://www.w3.org/TR/REC-html40"><xsl:copy-of
110
select="richcontent[@TYPE='NOTE']/html/body/*" /></duss:Data></Comment>