attachment_details.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 <!-- This stylesheet extracts some details of attachments from the artifact
     4      history of a sourceforge project export. -->
     5 
     6 <xsl:stylesheet version="1.0"
     7 		xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     8 		xmlns:xi="http://www.w3.org/2001/XInclude">
     9 
    10 <xsl:import href="sf2bz.xsl"/>
    11 
    12 <!-- Process a sourceforge artifact, outputting attachments as found -->
    13 <xsl:template name="process-artifact">
    14     <xsl:apply-templates/>
    15     <xsl:for-each
    16       select="field[@name='artifact_history']/history[field[@name='field_name']='File Added']">
    17       <xsl:variable name="file_id"
    18         select="substring-before(field[@name='old_value'],':')"/>
    19       <attachment>
    20 	<!-- isobsolete is an attribute of bugzilla:attachment, but that
    21 	     proves hard to deal with so we treat it as a node and fix it
    22 	     up in attachment_post.xsl -->
    23 	<isobsolete>
    24 	  <xsl:value-of select="number(boolean(../history[field[@name='field_name']='File Deleted' and substring-before(field[@name='old_value'],':')=$file_id]))"/>
    25 	</isobsolete>
    26 	<attachid>
    27 	  <xsl:value-of select="$file_id"/>
    28 	</attachid>
    29 	<date>
    30 	  <xsl:call-template name="bugzilla-timestamp">
    31 	    <xsl:with-param name="secs" select="field[@name='entrydate']"/>
    32 	  </xsl:call-template>
    33 	</date>
    34 	<filename>
    35 	  <xsl:value-of
    36 	    select="substring-after(field[@name='old_value'],': ')"/>
    37 	</filename>
    38       </attachment>
    39     </xsl:for-each>
    40 </xsl:template>
    41 
    42 <xsl:template match="project_export">
    43   <attachments>
    44     <xsl:apply-templates/>
    45   </attachments>
    46 </xsl:template>
    47 
    48 <xsl:template match="artifacts">
    49   <xsl:apply-templates/>
    50 </xsl:template>
    51 
    52 <xsl:template match="artifact">
    53   <xsl:variable name="type"
    54     select="normalize-space(field[@name='artifact_type'])"/>
    55   <xsl:choose>
    56     <xsl:when test="$type = 'Feature Requests'">
    57       <xsl:call-template name="process-artifact"/>
    58     </xsl:when>
    59     <xsl:when test="$type = 'Patches'">
    60       <xsl:call-template name="process-artifact"/>
    61     </xsl:when>
    62     <xsl:when test="$type = 'Bugs'">
    63       <xsl:call-template name="process-artifact"/>
    64     </xsl:when>
    65   </xsl:choose>
    66 </xsl:template>
    67 
    68 <xsl:template match="node()|text()" priority="-1"></xsl:template>
    69 
    70 </xsl:stylesheet>