Updated contact's get_changes with the working changes for calendar's function
[opensync/google-calendar-cdf.git] / src / gcal2osync.xslt
blob8ac62cea1cbf8f9379f86e079a7db0cf130d0a82
1 <?xml version="1.0" ?>
2 <xsl:stylesheet version="1.0"
3 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4 xmlns:atom="http://www.w3.org/2005/Atom"
5 xmlns:gd="http://schemas.google.com/g/2005">
7 <xsl:output method="xml" indent="yes"/>
9 <xsl:template match="child::entry">
10 <event>
11 <Comment>
12 <Content>
13 <xsl:value-of select="descendant::atom:content"/>
14 </Content>
15 </Comment>
17 <Contact>
18 <Content>
19 <xsl:value-of select="descendant::atom:author/atom:name"/>
20 </Content>
21 </Contact>
23 <Created>
24 <Content>
25 <xsl:value-of select="descendant::atom:published"/>
26 </Content>
27 </Created>
29 <DateEnd>
30 <Content>
31 <xsl:choose>
32 <xsl:when test="descendant::gd:when/@endTime">
33 <xsl:value-of select="descendant::gd:when/@endTime"/>
34 </xsl:when>
35 <xsl:otherwise>
36 <xsl:variable name="recurrence">
37 <xsl:value-of select="descendant::gd:recurrence"/>
38 </xsl:variable>
40 <xsl:choose>
41 <xsl:when test="substring-after($recurrence,'DTEND;VALUE=DATE:')">
42 <xsl:value-of select="substring-before(substring-after($recurrence, 'DTEND;VALUE=DATE:'),'RRULE:')"/>
43 </xsl:when>
44 <xsl:otherwise>
45 <xsl:value-of select="substring-after(substring-before(substring-after($recurrence,'DTEND;TZID='),
46 'RRULE:'), ':')"/>
47 </xsl:otherwise>
48 </xsl:choose>
50 </xsl:otherwise>
51 </xsl:choose>
52 </Content>
53 </DateEnd>
55 <DateStarted>
56 <Content>
57 <xsl:choose>
58 <xsl:when test="descendant::gd:when/@startTime">
59 <xsl:value-of select="descendant::gd:when/@startTime"/>
60 </xsl:when>
61 <xsl:otherwise>
62 <!-- TODO: remove trailing empty space... -->
63 <xsl:variable name="recurrence">
64 <xsl:value-of select="descendant::gd:recurrence"/>
65 </xsl:variable>
67 <xsl:choose>
68 <xsl:when test="substring-after($recurrence, 'DTSTART;VALUE=DATE:')">
69 <xsl:value-of select="substring-before(substring-after($recurrence, 'DTSTART;VALUE=DATE:'),'DTEND')"/>
70 </xsl:when>
71 <xsl:otherwise>
72 <xsl:value-of select="substring-after(substring-before(substring-after($recurrence,'DTSTART;TZID='),
73 'DTEND;'), ':')"/>
74 </xsl:otherwise>
75 </xsl:choose>
77 </xsl:otherwise>
78 </xsl:choose>
79 </Content>
80 </DateStarted>
82 <Summary>
83 <Content>
84 <xsl:value-of select="descendant::atom:title"/>
85 </Content>
86 </Summary>
88 <Description>
89 <Content>
90 <xsl:value-of select="descendant::atom:content"/>
91 </Content>
92 </Description>
94 <LastModified>
95 <Content>
96 <xsl:value-of select="descendant::atom:updated"/>
97 </Content>
98 </LastModified>
100 <Location>
101 <Content>
102 <xsl:value-of select="descendant::gd:where/@valueString"/>
103 </Content>
104 </Location>
106 <xsl:if test="descendant::gd:recurrence">
107 <RecurrenceRule>
108 <!-- TODO: remove trailing empty space... -->
109 <xsl:variable name="recurrence">
110 <xsl:value-of select="descendant::gd:recurrence"/>
111 </xsl:variable>
113 <Frequency>
114 <xsl:value-of select="substring-before(substring-after($recurrence,
115 'RRULE:FREQ='),';BYDAY=')"/>
116 </Frequency>
117 <Until>
118 <xsl:value-of select="substring-after($recurrence,';UNTIL=')"/>
119 </Until>
120 <ByDay>
121 <xsl:value-of select="substring-before(substring-after($recurrence,
122 ';BYDAY='),';')"/>
123 </ByDay>
124 </RecurrenceRule>
125 </xsl:if>
127 <Status>
128 <Content>
129 <xsl:variable name="status">
130 <xsl:value-of select="descendant::gd:eventStatus/@value"/>
131 </xsl:variable>
132 <xsl:choose>
133 <xsl:when test="substring-after($status, '#event.') =
134 'confirmed'">CONFIRMED</xsl:when>
135 <xsl:otherwise>CANCELLED</xsl:otherwise>
136 </xsl:choose>
137 </Content>
138 </Status>
140 <Uid>
141 <Content>
142 <xsl:value-of select="descendant::atom:id"/>
143 </Content>
144 </Uid>
146 <Url>
147 <Content>
148 <xsl:value-of select="descendant::atom:link[@rel='edit']/@href"/>
149 </Content>
150 </Url>
152 </event>
153 </xsl:template>
156 </xsl:stylesheet>