--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"\r
+ xmlns:xhtml="http://www.w3.org/1999/xhtml"\r
+ version="1.0">\r
+ \r
+ <xsl:output method="xml"/>\r
+ <xsl:strip-space elements="*"/>\r
+ \r
+ <!-- =====================================================\r
+ Copying template.\r
+ ===================================================== -->\r
+ <xsl:template match="@*|node()" mode="copy">\r
+ <xsl:copy>\r
+ <xsl:apply-templates select="@*|node()" mode="copy"/>\r
+ </xsl:copy>\r
+ </xsl:template>\r
+ \r
+ <xsl:template match="/">\r
+ <xsl:element name="login">\r
+ <xsl:apply-templates select="//xhtml:table[@class = 'tvstart']"/>\r
+ </xsl:element>\r
+ </xsl:template>\r
+ \r
+ <xsl:template match="xhtml:table">\r
+ <action type="channels-whats-on-now" name="channels-whats-on-now" reference="{xhtml:tr[3]/xhtml:td[1]//@href}"/>\r
+ \r
+ <action type="channels-whats-on" name="channels-whats-on" reference="{xhtml:tr[5]/xhtml:td[1]//@href}"/>\r
+ \r
+ <action type="channels-favorites" name="channels-favorites" reference="{xhtml:tr[7]/xhtml:td[1]//@href}"/>\r
+ \r
+ <action type="shows-whats-on" name="shows-whats-on" reference="{xhtml:tr[3]/xhtml:td[3]//@href}"/>\r
+ \r
+ <action type="shows-search" name="shows-search" reference="{xhtml:tr[5]/xhtml:td[3]//@href}"/>\r
+ \r
+ <action type="shows-favorites" name="shows-favorites" reference="{xhtml:tr[7]/xhtml:td[3]//@href}"/>\r
+ \r
+ <action type="shows-add-favorite" name="shows-add-favorite" reference="{xhtml:tr[9]/xhtml:td[3]//@href}"/>\r
+ \r
+ <action type="movies-whats-on" name="movies-whats-on" reference="{xhtml:tr[3]/xhtml:td[5]//@href}"/>\r
+ \r
+ <action type="sports-whats-on" name="sports-whats-on" reference="{xhtml:tr[9]/xhtml:td[5]//@href}"/>\r
+ \r
+ \r
+ </xsl:template>\r
+ \r
+ <xsl:template match="xhtml:a">\r
+ <xsl:variable name="type">\r
+ <xsl:choose>\r
+ <!-- Everything in the Favorite Channels section --> \r
+ <xsl:when test="preceding::node()[contains(text(), 'Favorite') and \r
+ contains(text(),\r
+ 'Channels')]\r
+ and following::node()[contains(text(), 'Favorite') and\r
+ contains(text(), 'Shows')]">\r
+ <favorite-channels>\r
+ <xsl:choose>\r
+ <xsl:when test="contains(text(), \r
+ 's on now?')">\r
+ <xsl:text>channels-whats-on-now</xsl:text>\r
+ </xsl:when>\r
+ <xsl:when test="contains(text(), 's on?')">\r
+ <xsl:text>channels-whats-on</xsl:text> \r
+ </xsl:when>\r
+ <xsl:when test="contains(text(), 'Favorites')">\r
+ <xsl:text>channels-favorites</xsl:text> \r
+ </xsl:when>\r
+ </xsl:choose>\r
+ </favorite-channels>\r
+ </xsl:when>\r
+ \r
+ <!-- Everything in the Favorite Shows section --> \r
+ <xsl:when test="preceding::node()[contains(text(), 'Favorite') and \r
+ contains(text(),\r
+ 'Shows')]\r
+ and following::node()[contains(text(), 'Movies')]">\r
+ <xsl:choose>\r
+ <xsl:when test="contains(text(), 's on?')">\r
+ <xsl:text>shows-whats-on</xsl:text>\r
+ </xsl:when>\r
+ <xsl:when test="contains(text(), 'Search a show')">\r
+ <xsl:text>shows-search</xsl:text>\r
+ </xsl:when>\r
+ <xsl:when test="contains(text(), 'Favorites')">\r
+ <xsl:text>shows-favorites</xsl:text>\r
+ </xsl:when>\r
+ <xsl:when test="contains(text(), 'Add a favorite')">\r
+ <xsl:text>shows-add-favorite</xsl:text>\r
+ </xsl:when> \r
+ </xsl:choose> \r
+ </xsl:when>\r
+ \r
+ <!-- The Movies section -->\r
+ <xsl:when test="preceding::node()[contains(text(), 'Movies')]\r
+ and following::node()[contains(text(), 'Sports')] \r
+ and contains(text(), 's on?')">\r
+ <xsl:text>movies-whats-on</xsl:text> \r
+ </xsl:when>\r
+ \r
+ <!-- Everything in the sports section --> \r
+ \r
+ <xsl:when test="preceding::node()[contains(text(), 'Sports')] \r
+ and contains(text(), 's on?')">\r
+ <xsl:text>sports-whats-on</xsl:text> \r
+ </xsl:when>\r
+ \r
+ <xsl:when test="contains(text(), 'Logout')">\r
+ <xsl:text>logout</xsl:text>\r
+ </xsl:when>\r
+ <xsl:when test="contains(text(), 'Manual')">\r
+ <xsl:text>manual-recording</xsl:text>\r
+ </xsl:when>\r
+ <xsl:when test="contains(text(), 'View')">\r
+ <xsl:text>view-recordings</xsl:text>\r
+ </xsl:when>\r
+ <xsl:otherwise>\r
+ <xsl:text>unknown</xsl:text>\r
+ <xsl:value-of select="text()"/>\r
+ </xsl:otherwise>\r
+ </xsl:choose>\r
+ </xsl:variable>\r
+ <xsl:element name="action">\r
+ <xsl:attribute name="name"><xsl:value-of select="$type"/></xsl:attribute>\r
+ <xsl:attribute name="type"><xsl:value-of select="$type"/></xsl:attribute>\r
+ <xsl:attribute name="reference"><xsl:value-of select="@href"/></xsl:attribute>\r
+ </xsl:element>\r
+ </xsl:template>\r
+ \r
+</xsl:stylesheet>\r