+ <xsl:variable name="screen-name" select="normalize-space(substring-after(//table[@class='profile-details' or @class='main-tweet']//*[@class='username'], '@'))"/>
+
+ <xsl:template match="//div[contains(@class, 'timeline')]/table[@class='tweet ']|//div[@class='main-tweet-container']/table[@class='main-tweet']">
+ <xsl:variable name="user-name" select="normalize-space(.//*[@class='username']/text()[2])"/>
+ <xsl:variable name="item-content" select=".//div[@class='tweet-text']/div"/>
+ <xsl:variable name="item-media" select=".//a[@data-pre-embedded='true']"/>
+ <xsl:variable name="item-permalink">
+ <xsl:choose>
+ <xsl:when test="@href">
+ <xsl:value-of select="concat($BaseURL, substring-before(@href, '?'))"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <!--
+ The main tweet in permalink pages do not have a timestamp tag,
+ just use the canonical URL as permalink.
+ -->
+ <xsl:value-of select="//link[@rel='canonical']/@href"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>