User:JackSchmidt/ParseRecentChanges.xslt.xml

 

 &#xA;               

  

 <xsl:apply-templates select="document(concat('http://en.wikipedia.org/wiki/Special:Recentchangeslinked/',@page,'?days=1&amp;limit=500'))" mode="parse_recent_changes" /> </xsl:template>

<xsl:template match="xhtml:li" mode="parse_recent_changes"> <xsl:variable name="query" select="substring-after(xhtml:a[text='diff']/@href,'?')"/> <xsl:variable name="oldid" select="substring-after($query,'oldid=')"/> <xsl:variable name="newid" select="substring-before(substring-after($query,'diff='),'&amp;')"/> <xsl:variable name="artid" select="substring-before(substring-after($query,'curid='),'&amp;')"/> <xsl:variable name="time" select="substring-before(substring-after(text[starts-with(.,&quot;&#x200E;;&quot;)],&quot;&#x200E;; &quot;),' ')"/> <xsl:variable name="_date" select="count(../preceding-sibling::xhtml:h4)"/> <xsl:variable name="date" select="(../preceding-sibling::xhtml:h4)[$_date]"/> <xsl:variable name="size" select="substring-before(substring-after((xhtml:span|xhtml:strong)[starts-with(@class,'mw-plusminus')]/text,'('),')')"/> <xsl:variable name="user" select="substring-after(xhtml:a[starts-with(@title,'Special:Contributions/')]/@title,'Special:Contributions/')"/> <xsl:variable name="watched" select="count(xhtml:strong[@class='mw-watched'])"/> <xsl:variable name="minor"  select="count(xhtml:span[@class='minor'])"/> <xsl:variable name="bot"    select="count(xhtml:span[@class='bot'])"/> <xsl:variable name="anon" select="1-count(xhtml:a[starts-with(@title,'User:')])"/> <change watched="{$watched}" minor="{$minor}" bot="{$bot}" anon="{$anon}" size="{$size}" date="{$date}" time="{$time}" oldid="{$oldid}" newid="{$newid}" artid="{$artid}" title="{xhtml:a[text='diff']/@title}" user="{$user}" >       <xsl:apply-templates select="xhtml:span[@class='comment']/node" mode="clean_copy" />   <xsl:text>&#xA;</xsl:text> </xsl:template>

<xsl:template mode="clean_copy" match="xhtml:a/@shape[.='rect']"/> <xsl:template mode="clean_copy" match="xhtml:span/@dir[.='ltr']"/> <xsl:template mode="clean_copy" match="xhtml:td/@rowspan[.=1]"/> <xsl:template mode="clean_copy" match="xhtml:td/@colspan[.=1]"/> <xsl:template mode="clean_copy" match="xhtml:th/@rowspan[.=1]"/> <xsl:template mode="clean_copy" match="xhtml:th/@colspan[.=1]"/> <xsl:template mode="clean_copy" match="@*"> <xsl:copy-of select="."/> </xsl:template> <xsl:template mode="clean_copy" match="*[name]"> <xsl:element name="{name}"> <xsl:apply-templates mode="clean_copy" select="@*"/> <xsl:apply-templates mode="clean_copy" select="*"/> </xsl:element> </xsl:template> <xsl:template mode="clean_copy" match="text"> <xsl:if test="normalize-space(.)"> <xsl:copy-of select="."/> </xsl:if> </xsl:template>

</xsl:stylesheet>