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