692d196ced3257a3f7c72a080b9fb3279dda55d5
[utils] /
1 <?xml version="1.0" encoding="UTF-8"?>\r
2 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"\r
3     xmlns:xhtml="http://www.w3.org/1999/xhtml"\r
4     version="1.0">\r
5     \r
6     <xsl:output method="xml"/>\r
7     <xsl:strip-space elements="*"/>\r
8     \r
9     <!-- =====================================================\r
10         Copying template.\r
11         ===================================================== -->\r
12     <xsl:template match="@*|node()" mode="copy">\r
13         <xsl:copy>\r
14             <xsl:apply-templates select="@*|node()" mode="copy"/>\r
15         </xsl:copy>\r
16     </xsl:template>\r
17     \r
18     <xsl:template match="/">\r
19         <xsl:element name="login">\r
20             <xsl:apply-templates select="//xhtml:table[@class = 'tvstart']"/>\r
21         </xsl:element>\r
22     </xsl:template>\r
23     \r
24     <xsl:template match="xhtml:table">\r
25         <action type="channels-whats-on-now"  name="channels-whats-on-now" reference="{xhtml:tr[3]/xhtml:td[1]//@href}"/>\r
26       \r
27         <action type="channels-whats-on"  name="channels-whats-on" reference="{xhtml:tr[5]/xhtml:td[1]//@href}"/>\r
28       \r
29         <action type="channels-favorites"  name="channels-favorites" reference="{xhtml:tr[7]/xhtml:td[1]//@href}"/>\r
30         \r
31         <action type="shows-whats-on"  name="shows-whats-on" reference="{xhtml:tr[3]/xhtml:td[3]//@href}"/>\r
32         \r
33         <action type="shows-search"  name="shows-search" reference="{xhtml:tr[5]/xhtml:td[3]//@href}"/>\r
34         \r
35         <action type="shows-favorites"  name="shows-favorites" reference="{xhtml:tr[7]/xhtml:td[3]//@href}"/>\r
36         \r
37         <action type="shows-add-favorite"  name="shows-add-favorite" reference="{xhtml:tr[9]/xhtml:td[3]//@href}"/>\r
38         \r
39         <action type="movies-whats-on"  name="movies-whats-on" reference="{xhtml:tr[3]/xhtml:td[5]//@href}"/>\r
40         \r
41         <action type="sports-whats-on"  name="sports-whats-on"  reference="{xhtml:tr[9]/xhtml:td[5]//@href}"/>\r
42       \r
43        \r
44     </xsl:template>\r
45     \r
46     <xsl:template match="xhtml:a">\r
47         <xsl:variable name="type">\r
48             <xsl:choose>\r
49                 <!-- Everything in the Favorite Channels section --> \r
50                 <xsl:when test="preceding::node()[contains(text(), 'Favorite') and \r
51                     contains(text(),\r
52                     'Channels')]\r
53                     and following::node()[contains(text(), 'Favorite') and\r
54                     contains(text(), 'Shows')]">\r
55                     <favorite-channels>\r
56                     <xsl:choose>\r
57                         <xsl:when test="contains(text(), \r
58                             's on now?')">\r
59                             <xsl:text>channels-whats-on-now</xsl:text>\r
60                         </xsl:when>\r
61                         <xsl:when test="contains(text(), 's on?')">\r
62                             <xsl:text>channels-whats-on</xsl:text>        \r
63                         </xsl:when>\r
64                         <xsl:when test="contains(text(), 'Favorites')">\r
65                             <xsl:text>channels-favorites</xsl:text>          \r
66                         </xsl:when>\r
67                     </xsl:choose>\r
68                         </favorite-channels>\r
69                 </xsl:when>\r
70                 \r
71                 <!-- Everything in the Favorite Shows section --> \r
72                 <xsl:when test="preceding::node()[contains(text(), 'Favorite') and \r
73                     contains(text(),\r
74                     'Shows')]\r
75                     and following::node()[contains(text(), 'Movies')]">\r
76                     <xsl:choose>\r
77                         <xsl:when test="contains(text(), 's on?')">\r
78                             <xsl:text>shows-whats-on</xsl:text>\r
79                         </xsl:when>\r
80                         <xsl:when test="contains(text(), 'Search a show')">\r
81                             <xsl:text>shows-search</xsl:text>\r
82                         </xsl:when>\r
83                         <xsl:when test="contains(text(), 'Favorites')">\r
84                             <xsl:text>shows-favorites</xsl:text>\r
85                         </xsl:when>\r
86                         <xsl:when test="contains(text(), 'Add a favorite')">\r
87                             <xsl:text>shows-add-favorite</xsl:text>\r
88                         </xsl:when>    \r
89                     </xsl:choose>               \r
90                 </xsl:when>\r
91                 \r
92                 <!-- The Movies section -->\r
93                 <xsl:when test="preceding::node()[contains(text(), 'Movies')]\r
94                     and following::node()[contains(text(), 'Sports')] \r
95                     and contains(text(), 's on?')">\r
96                     <xsl:text>movies-whats-on</xsl:text>    \r
97                 </xsl:when>\r
98                 \r
99                 <!-- Everything in the sports section --> \r
100                 \r
101                 <xsl:when test="preceding::node()[contains(text(), 'Sports')] \r
102                     and contains(text(), 's on?')">\r
103                     <xsl:text>sports-whats-on</xsl:text>    \r
104                 </xsl:when>\r
105                 \r
106                 <xsl:when test="contains(text(), 'Logout')">\r
107                     <xsl:text>logout</xsl:text>\r
108                 </xsl:when>\r
109                 <xsl:when test="contains(text(), 'Manual')">\r
110                     <xsl:text>manual-recording</xsl:text>\r
111                 </xsl:when>\r
112                 <xsl:when test="contains(text(), 'View')">\r
113                     <xsl:text>view-recordings</xsl:text>\r
114                 </xsl:when>\r
115                 <xsl:otherwise>\r
116                     <xsl:text>unknown</xsl:text>\r
117                     <xsl:value-of select="text()"/>\r
118                 </xsl:otherwise>\r
119             </xsl:choose>\r
120         </xsl:variable>\r
121         <xsl:element name="action">\r
122             <xsl:attribute name="name"><xsl:value-of select="$type"/></xsl:attribute>\r
123             <xsl:attribute name="type"><xsl:value-of select="$type"/></xsl:attribute>\r
124             <xsl:attribute name="reference"><xsl:value-of select="@href"/></xsl:attribute>\r
125         </xsl:element>\r
126     </xsl:template>\r
127     \r
128 </xsl:stylesheet>\r