(no commit message)
[utils] / crawler / kiss / src / login.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                 <xsl:when test="preceding::xhtml:h2[position() = 1 and text() = 'Favorite Channels'] and contains(text(), 's on now?')">
28                     <xsl:text>channels-whats-on-now</xsl:text>
29                 </xsl:when>
30                 <xsl:when test="preceding::xhtml:h2[position() = 1 and text() = 'Favorite Channels'] and contains(text(), 's on?')">
31                     <xsl:text>channels-whats-on</xsl:text>
32                 </xsl:when>
33                 <xsl:when test="preceding::xhtml:h2[position() = 1 and text() = 'Favorite Channels'] and contains(text(), 'Favorites')">
34                     <xsl:text>channels-favorites</xsl:text>
35                 </xsl:when>
36                 
37                 <xsl:when test="preceding::xhtml:h2[position() = 1 and text() = 'Favorite Shows'] and contains(text(), 's on?')">
38                     <xsl:text>shows-whats-on</xsl:text>
39                 </xsl:when>
40                 <xsl:when test="preceding::xhtml:h2[position() = 1 and text() = 'Favorite Shows'] and contains(text(), 'Search a show')">
41                     <xsl:text>shows-search</xsl:text>
42                 </xsl:when>
43                 <xsl:when test="preceding::xhtml:h2[position() = 1 and text() = 'Favorite Shows'] and contains(text(), 'Favorites')">
44                     <xsl:text>shows-favorites</xsl:text>
45                 </xsl:when>
46                 <xsl:when test="preceding::xhtml:h2[position() = 1 and text() = 'Favorite Shows'] and contains(text(), 'Add a favorite')">
47                     <xsl:text>shows-add-favorite</xsl:text>
48                 </xsl:when>
49                 
50                 <xsl:when test="preceding::xhtml:h2[position() = 1 and text() = 'Movies'] and contains(text(), 's on?')">
51                     <xsl:text>movies-whats-on</xsl:text>
52                 </xsl:when>
53                 
54                 
55                 <xsl:when test="preceding::xhtml:h2[position() = 1 and text() = 'Sports'] and contains(text(), 's on?')">
56                     <xsl:text>sports-whats-on</xsl:text>
57                 </xsl:when>
58                 
59                 <xsl:when test="contains(text(), 'Logout')">
60                     <xsl:text>logout</xsl:text>
61                 </xsl:when>
62                 <xsl:when test="contains(text(), 'Manual')">
63                     <xsl:text>manual-recording</xsl:text>
64                 </xsl:when>
65                 <xsl:when test="contains(text(), 'View')">
66                     <xsl:text>view-recordings</xsl:text>
67                 </xsl:when>
68                 <xsl:otherwise>
69                     unknown
70                     <xsl:value-of select="text()"/>
71                 </xsl:otherwise>
72             </xsl:choose>
73         </xsl:variable>
74         <xsl:element name="action">
75             <xsl:attribute name="name"><xsl:value-of select="$type"/></xsl:attribute>
76             <xsl:attribute name="type"><xsl:value-of select="$type"/></xsl:attribute>
77             <xsl:attribute name="reference"><xsl:value-of select="@href"/></xsl:attribute>
78         </xsl:element>
79     </xsl:template>
80     
81 </xsl:stylesheet>