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