user_names.xsl
author ali@yendor.vm.bytemark.co.uk
Thu Nov 16 08:30:26 2006 +0000 (2006-11-16)
changeset 0 ae7b3fa753dc
permissions -rw-r--r--
First cut. Distintly raw around the edges:
* Assumes it will be running in /home/ali/wk/slashem/web.scripts
* Assumes cache directory will be in topdir
* No build system (simple compiling and linking against libxml2)
* No configure system (eg., tagsoup)
* Output XML untested
* Doesn't set bugzilla maintainer or exporter
* Handling of artifact priorities and resolution is suspect
     1 <?xml version="1.0"?>
     2 
     3 <xsl:stylesheet version="1.0"
     4 		xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     5 		xmlns:xhtml="http://www.w3.org/1999/xhtml"
     6 		xmlns:exsl="http://exslt.org/common"
     7 		extension-element-prefixes="exsl"
     8 		exclude-result-prefixes="xhtml">
     9 
    10 <xsl:variable name="users">
    11   <xsl:for-each select="//users/user">
    12     <user>
    13       <xsl:copy-of select="@name"/>
    14       <xsl:value-of select="."/>
    15     </user>
    16   </xsl:for-each>
    17   <xsl:for-each select="//xhtml:td[xhtml:b='Submitted By:' and xhtml:a]">
    18     <xsl:element name="user">
    19       <xsl:attribute name="name">
    20 	<xsl:for-each select="text()">
    21 	  <xsl:if test="contains(., '-')">
    22 	    <xsl:value-of select="normalize-space(substring-before(., '-'))"/>
    23 	  </xsl:if>
    24 	</xsl:for-each>
    25       </xsl:attribute>
    26       <xsl:value-of select="xhtml:a"/>
    27       <xsl:text>@users.sourceforge.net</xsl:text>
    28     </xsl:element>
    29   </xsl:for-each>
    30   <xsl:for-each select="//xhtml:table[xhtml:tr/xhtml:td[normalize-space(.)='Login Name:'] and xhtml:tr/xhtml:td[normalize-space(.)='Publicly Displayed Name:']]">
    31     <xsl:element name="user">
    32       <xsl:attribute name="name">
    33 	<xsl:value-of select="normalize-space(xhtml:tr/xhtml:td[normalize-space(.)='Publicly Displayed Name:']/following-sibling::xhtml:td)"/>
    34       </xsl:attribute>
    35 	<xsl:value-of select="normalize-space(xhtml:tr/xhtml:td[normalize-space(.)='Login Name:']/following-sibling::xhtml:td)"/>
    36       <xsl:text>@users.sourceforge.net</xsl:text>
    37     </xsl:element>
    38   </xsl:for-each>
    39 </xsl:variable>
    40 
    41 <xsl:variable name="sorted_users">
    42   <xsl:for-each select="exsl:node-set($users)/user">
    43     <xsl:sort/>
    44     <xsl:copy-of select="."/>
    45   </xsl:for-each>
    46 </xsl:variable>
    47 
    48 <xsl:template match="/">
    49   <users>
    50     <xsl:for-each select="exsl:node-set($sorted_users)/user">
    51       <xsl:if test="not(. = following-sibling::user[1])">
    52 	<xsl:copy>
    53 	  <xsl:copy-of select="@name"/>
    54 	  <xsl:value-of select="."/>
    55 	</xsl:copy>
    56       </xsl:if>
    57     </xsl:for-each>
    58   </users>
    59 </xsl:template>
    60 
    61 </xsl:stylesheet>