User:Abou Ben Adhem/Sandbox
From dKosopedia
Contents |
Bill page templates
Bills imported:
Since Feb. 12
thomas2wiki.xsl
<?xml version="1.0"?> <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xhtml="http://www.w3.org/1999/xhtml"> <xsl:output method="xml" omit-xml-declaration="yes" /> <xsl:param name="lastHConRes" select="0" /> <xsl:param name="lastSConRes" select="0" /> <xsl:param name="lastHJRes" select="0" /> <xsl:param name="lastSJRes" select="0" /> <xsl:param name="lastHRes" select="0" /> <xsl:param name="lastSRes" select="0" /> <xsl:param name="lastHR" select="0" /> <xsl:param name="lastS" select="0" /> <xsl:template match="/"> <mediawiki xmlns="http://www.mediawiki.org/xml/export-0.3/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mediawiki.org/xml/export-0.3/ http://www.mediawiki.org/xml/export-0.3.xsd" version="0.3" xml:lang="en"> <xsl:apply-templates select="//*[@id='content']/xhtml:p[./*[1] = xhtml:b]" /> </mediawiki> </xsl:template> <xsl:template match="xhtml:p" xmlns="http://www.mediawiki.org/xml/export-0.3/" xml:space="preserve"> <xsl:variable name="congress" select="./xhtml:a[1]/substring(@href, 21, 3)" /> <xsl:variable name="billname" select="./xhtml:a[1]/normalize-space(text())" /> <xsl:variable name="billtype" xml:space="default"> <xsl:choose> <xsl:when test="starts-with($billname, 'H.CON.RES.')">H.Con.Res.</xsl:when> <xsl:when test="starts-with($billname, 'S.CON.RES.')">S.Con.Res.</xsl:when> <xsl:when test="starts-with($billname, 'H.J.RES.')">H.J.Res.</xsl:when> <xsl:when test="starts-with($billname, 'S.J.RES.')">S.J.Res.</xsl:when> <xsl:when test="starts-with($billname, 'H.RES.')">H.Res.</xsl:when> <xsl:when test="starts-with($billname, 'S.RES.')">S.Res.</xsl:when> <xsl:when test="starts-with($billname, 'H.R.')">H.R.</xsl:when> <xsl:when test="starts-with($billname, 'S.')">S.</xsl:when> <xsl:otherwise><xsl:message terminate="yes">Bill type not recognized.</xsl:message></xsl:otherwise> </xsl:choose> </xsl:variable> <xsl:variable name="billtype" select="normalize-space($billtype)" /> <xsl:variable name="billnumber" select="substring($billname, string-length($billtype)+1)" /> <xsl:variable name="billtitle" select="./xhtml:a[1]/(following-sibling::text())[1]" /> <xsl:variable name="billtitle" select="normalize-space(substring($billtitle, 3))" /> <xsl:variable name="sponsor" select="./xhtml:b[./text()='Sponsor:']/(following-sibling::xhtml:a/text())[1]" /> <xsl:variable name="sponsor" select="normalize-space($sponsor)" /> <xsl:variable name="committees" select="./xhtml:b[./text()='Committees:']/following-sibling::text()[1]" /> <xsl:variable name="committees" select="tokenize(normalize-space($committees), '; ')" /> <xsl:variable name="recent" select="./xhtml:b[./text()='Latest Major Action:']/following-sibling::text()[1]" /> <xsl:variable name="recent" select="normalize-space($recent)" /> <xsl:variable name="date" select="tokenize(substring-before($recent, ' '), '/')" /> <xsl:variable name="monthnumber" select="number($date[1])" /> <xsl:variable name="monthname" select="tokenize('January February March April May June July August September October November December', ' ')[$monthnumber]" /> <xsl:variable name="billname" select="concat($billtype, ' ', $billnumber, '-', $congress)" /> <xsl:if test="($billtype='H.Con.Res.' and number($billnumber) > ($lastHConRes)) or ($billtype='S.Con.Res.' and number($billnumber) > number($lastSConRes)) or ($billtype='H.J.Res.' and number($billnumber) > number($lastHJRes)) or ($billtype='S.J.Res.' and number($billnumber) > number($lastSJRes)) or ($billtype='H.Res.' and number($billnumber) > number($lastHRes)) or ($billtype='S.Res.' and number($billnumber) > number($lastSRes)) or ($billtype='H.R.' and number($billnumber) > number($lastHR)) or ($billtype='S.' and number($billnumber) > number($lastS))"> <page> <title><xsl:value-of select="$billname" /></title> <revision> <timestamp><xsl:value-of select="$date[3]" />-<xsl:value-of select="format-number($monthnumber, '00')" />-<xsl:value-of select="format-number(number($date[2]), '00')" />T12:00:00Z</timestamp> <contributor><username>*thomas.gov import*</username></contributor> <text> {{stub}} {{<xsl:value-of select="concat($billtype, 'Info|bill=', $billnumber, '|congress=', $congress)" /> |title=<xsl:value-of select="$billtitle" /> |sponsor=[[<xsl:value-of select="$sponsor" />]] |committees=<xsl:for-each select="$committees">[[<xsl:value-of select="." />]] </xsl:for-each> }} ==Bill Text== [<xsl:value-of select="concat('http://thomas.loc.gov/cgi-bin/query/z?c', $congress, ':', upper-case($billtype), $billnumber, ': Text of ', $billname)" />] ==Update Status== {{Status of <xsl:value-of select="$billname" />}} ==External Links== {{<xsl:value-of select="concat($billtype, 'Links|bill=', $billnumber, '|congress=', $congress)" />}} Source: [http://thomas.loc.gov/bss/<xsl:value-of select="$congress" />search.html thomas.gov search]</text> </revision> </page> <page> <title><xsl:value-of select="concat($billtype, $billnumber, '-', $congress)" /></title> <revision> <timestamp><xsl:value-of select="$date[3]" />-<xsl:value-of select="format-number($monthnumber, '00')" />-<xsl:value-of select="format-number(number($date[2]), '00')" />T12:00:00Z</timestamp> <contributor><username>*thomas.gov import*</username></contributor> <text>#REDIRECT [[<xsl:value-of select="concat($billtype, ' ', $billnumber, '-', $congress)" />]] </text> </revision> </page> </xsl:if> <page> <title>Template:Status of <xsl:value-of select="$billname" /></title> <revision> <timestamp><xsl:value-of select="$date[3]" />-<xsl:value-of select="format-number($monthnumber, '00')" />-<xsl:value-of select="format-number(number($date[2]), '00')" />T12:00:00Z</timestamp> <contributor><username>*thomas.gov import*</username></contributor> <text>{{billstatus|bill=<xsl:value-of select="$billname" /> |title=<xsl:value-of select="$billtitle" /> |year=<xsl:value-of select="$date[3]" /> |monthday=<xsl:value-of select="concat($monthname, ' ', $date[2])" /> |status=<xsl:value-of select="substring-after($recent, ' ')" /> }}</text> </revision> </page> </xsl:template> </xsl:stylesheet>