1 <?xml version="1.0" encoding="utf-8"?>
2 <xsl:stylesheet version="1.0"
3 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4 xmlns:h="http://www.w3.org/1999/xhtml"
7 Convert HTML generated by grauphel's tomboy2html converter
8 back into the tomboy note markup
10 <xsl:output omit-xml-declaration="yes"/>
12 <xsl:template match="/">
13 <xsl:apply-templates select="h:html/h:body"/>
16 <xsl:template match="h:body">
17 <xsl:call-template name="content"/>
20 <xsl:template name="content">
21 <xsl:for-each select="child::node()">
23 <xsl:when test="local-name(.) = ''">
24 <xsl:call-template name="string-replace-all">
25 <xsl:with-param name="text" select="string(.)" />
26 <xsl:with-param name="replace" select="'        '" />
27 <xsl:with-param name="by" select="'	'" />
30 <xsl:when test="local-name(.) = 'br'">
33 <xsl:when test="local-name(.) = 'ul'">
35 <xsl:for-each select="h:li">
36 <list-item dir="ltr"><xsl:call-template name="content"/></list-item>
40 <xsl:when test="local-name(.) = 'b'">
41 <bold><xsl:call-template name="content"/></bold>
43 <xsl:when test="local-name(.) = 'i'">
44 <italic><xsl:call-template name="content"/></italic>
46 <xsl:when test="local-name(.) = 'span' and @class = 'strikethrough'">
47 <strikethrough><xsl:call-template name="content"/></strikethrough>
49 <xsl:when test="local-name(.) = 'span' and @class = 'highlight'">
50 <highlight><xsl:call-template name="content"/></highlight>
52 <xsl:when test="local-name(.) = 'span' and contains(@style, 'monospace')">
53 <monospace><xsl:call-template name="content"/></monospace>
55 <xsl:when test="local-name(.) = 'span' and @class = 'small'">
56 <xsl:text disable-output-escaping="yes"><size:small></xsl:text>
57 <xsl:call-template name="content"/>
58 <xsl:text disable-output-escaping="yes"></size:small></xsl:text>
60 <xsl:when test="local-name(.) = 'span' and @class = 'large'">
61 <xsl:text disable-output-escaping="yes"><size:large></xsl:text>
62 <xsl:call-template name="content"/>
63 <xsl:text disable-output-escaping="yes"></size:large></xsl:text>
65 <xsl:when test="local-name(.) = 'span' and @class = 'huge'">
66 <xsl:text disable-output-escaping="yes"><size:huge></xsl:text>
67 <xsl:call-template name="content"/>
68 <xsl:text disable-output-escaping="yes"></size:huge></xsl:text>
70 <xsl:when test="local-name(.) = 'a' and contains(@href, '://')">
71 <xsl:text disable-output-escaping="yes"><link:url></xsl:text>
73 <xsl:when test="starts-with(@href, 'file://')">
74 <xsl:value-of select="substring(@href, 8)"/>
77 <xsl:value-of select="@href"/>
80 <xsl:text disable-output-escaping="yes"></link:url></xsl:text>
82 <xsl:when test="local-name(.) = 'a' and not(contains(@href, '://'))">
83 <xsl:text disable-output-escaping="yes"><link:internal></xsl:text>
84 <xsl:call-template name="content"/>
85 <xsl:text disable-output-escaping="yes"></link:internal></xsl:text>
88 <xsl:message terminate="yes">
90 <xsl:value-of select="local-name(.)"/>
97 <!-- http://geekswithblogs.net/Erik/archive/2008/04/01/120915.aspx -->
98 <xsl:template name="string-replace-all">
99 <xsl:param name="text" />
100 <xsl:param name="replace" />
101 <xsl:param name="by" />
103 <xsl:when test="contains($text, $replace)">
104 <xsl:value-of select="substring-before($text,$replace)" />
105 <xsl:value-of select="$by" />
106 <xsl:call-template name="string-replace-all">
107 <xsl:with-param name="text" select="substring-after($text,$replace)" />
108 <xsl:with-param name="replace" select="$replace" />
109 <xsl:with-param name="by" select="$by" />
113 <xsl:value-of select="$text" />