source: freemind/trunk/fuentes/freemind/accessories/mm2xls_utf8.xsl @ 68

Last change on this file since 68 was 68, checked in by jrpelegrina, 4 years ago

First release to Xenial

File size: 4.4 KB
Line 
1<?xml version="1.0" encoding="UTF-8"?>
2<!--
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)
11-->
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"/>
23
24  <xsl:template match="/map">
25    <xsl:processing-instruction name="mso-application"> progid="Excel.Sheet"</xsl:processing-instruction>
26    <Workbook>
27      <Styles>
28        <Style ss:ID="s16" ss:Name="attribute_cell">
29        <Borders>
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"/>
34        </Borders>
35        </Style>
36        <Style ss:ID="s17" ss:Name="attribute_header">
37        <Borders>
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"/>
42        </Borders>
43        <Font ss:Bold="1"/>
44        </Style>
45      </Styles>
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">
49        <Table>
50                <xsl:apply-templates select="node">
51                        <xsl:with-param name="index" select="1" />
52                </xsl:apply-templates>
53        </Table>
54      </Worksheet>
55    </Workbook>
56  </xsl:template>
57
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" />
62        </Cell>
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>
68        </xsl:if>
69        </Row>
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>
76</xsl:template>
77
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>
82             </Cell>
83             <Cell ss:StyleID="s16">
84                <Data ss:Type="String"><xsl:value-of select="@VALUE" /></Data>
85             </Cell>
86        </Row>
87</xsl:template>
88
89<xsl:template name="output-node-text-as-data">
90        <xsl:choose>
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>
94        </xsl:when>
95        <xsl:otherwise>
96              <Data ss:Type="String"><xsl:value-of select="@TEXT"/></Data>
97        <!-- xsl:value-of select="normalize-space(@TEXT)" / -->
98        </xsl:otherwise>
99        </xsl:choose>
100        <xsl:call-template name="output-note-text-as-comment" />
101</xsl:template>
102
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>
111        </xsl:if>
112</xsl:template>
113
114</xsl:stylesheet>
115
116                 
Note: See TracBrowser for help on using the repository browser.