add xsltproc and diff to travis deps
[grauphel.git] / templates / html2tomboy.xsl
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"
5 >
6  <!--
7   Convert HTML generated by grauphel's tomboy2html converter
8   back into the tomboy note markup
9  -->
10  <xsl:output omit-xml-declaration="yes"/>
11
12  <xsl:template match="/">
13   <xsl:apply-templates select="h:html/h:body"/>
14  </xsl:template>
15
16  <xsl:template match="h:body">
17   <xsl:call-template name="content"/>
18  </xsl:template>
19
20  <xsl:template name="content">
21   <xsl:for-each select="child::node()">
22    <xsl:choose>
23     <xsl:when test="local-name(.) = ''">
24      <xsl:value-of select="."/>
25     </xsl:when>
26     <xsl:when test="local-name(.) = 'br'">
27      <!-- do nothing -->
28     </xsl:when>
29     <xsl:when test="local-name(.) = 'ul'">
30      <list>
31       <xsl:for-each select="h:li">
32        <list-item dir="ltr"><xsl:call-template name="content"/></list-item>
33       </xsl:for-each>
34      </list>
35     </xsl:when>
36     <xsl:when test="local-name(.) = 'b'">
37      <bold><xsl:call-template name="content"/></bold>
38     </xsl:when>
39     <xsl:when test="local-name(.) = 'i'">
40      <italic><xsl:call-template name="content"/></italic>
41     </xsl:when>
42     <xsl:when test="local-name(.) = 'span' and @class = 'strikethrough'">
43      <strikethrough><xsl:call-template name="content"/></strikethrough>
44     </xsl:when>
45     <xsl:when test="local-name(.) = 'span' and @class = 'highlight'">
46      <highlight><xsl:call-template name="content"/></highlight>
47     </xsl:when>
48     <xsl:when test="local-name(.) = 'span' and contains(@style, 'monospace')">
49      <monospace><xsl:call-template name="content"/></monospace>
50     </xsl:when>
51     <xsl:when test="local-name(.) = 'span' and @class = 'small'">
52      <xsl:text disable-output-escaping="yes">&lt;size:small></xsl:text>
53      <xsl:call-template name="content"/>
54      <xsl:text disable-output-escaping="yes">&lt;/size:small></xsl:text>
55     </xsl:when>
56     <xsl:when test="local-name(.) = 'span' and @class = 'large'">
57      <xsl:text disable-output-escaping="yes">&lt;size:large></xsl:text>
58      <xsl:call-template name="content"/>
59      <xsl:text disable-output-escaping="yes">&lt;/size:large></xsl:text>
60     </xsl:when>
61     <xsl:when test="local-name(.) = 'span' and @class = 'huge'">
62      <xsl:text disable-output-escaping="yes">&lt;size:huge></xsl:text>
63      <xsl:call-template name="content"/>
64      <xsl:text disable-output-escaping="yes">&lt;/size:huge></xsl:text>
65     </xsl:when>
66     <xsl:when test="local-name(.) = 'a' and contains(@href, '://')">
67      <xsl:text disable-output-escaping="yes">&lt;link:url></xsl:text>
68      <xsl:choose>
69       <xsl:when test="starts-with(@href, 'file://')">
70        <xsl:value-of select="substring(@href, 8)"/>
71       </xsl:when>
72       <xsl:otherwise>
73        <xsl:value-of select="@href"/>
74       </xsl:otherwise>
75      </xsl:choose>
76      <xsl:text disable-output-escaping="yes">&lt;/link:url></xsl:text>
77     </xsl:when>
78     <xsl:when test="local-name(.) = 'a' and not(contains(@href, '://'))">
79      <xsl:text disable-output-escaping="yes">&lt;link:internal></xsl:text>
80      <xsl:call-template name="content"/>
81      <xsl:text disable-output-escaping="yes">&lt;/link:internal></xsl:text>
82     </xsl:when>
83     <xsl:otherwise>
84      <xsl:message terminate="yes">
85       Unsupported tag
86       <xsl:value-of select="local-name(.)"/>
87      </xsl:message>
88     </xsl:otherwise>
89    </xsl:choose>
90   </xsl:for-each>
91  </xsl:template>
92
93 </xsl:stylesheet>