attachment_details.xsl
changeset 0 ae7b3fa753dc
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/attachment_details.xsl	Thu Nov 16 08:30:26 2006 +0000
     1.3 @@ -0,0 +1,70 @@
     1.4 +<?xml version="1.0"?>
     1.5 +
     1.6 +<!-- This stylesheet extracts some details of attachments from the artifact
     1.7 +     history of a sourceforge project export. -->
     1.8 +
     1.9 +<xsl:stylesheet version="1.0"
    1.10 +		xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    1.11 +		xmlns:xi="http://www.w3.org/2001/XInclude">
    1.12 +
    1.13 +<xsl:import href="sf2bz.xsl"/>
    1.14 +
    1.15 +<!-- Process a sourceforge artifact, outputting attachments as found -->
    1.16 +<xsl:template name="process-artifact">
    1.17 +    <xsl:apply-templates/>
    1.18 +    <xsl:for-each
    1.19 +      select="field[@name='artifact_history']/history[field[@name='field_name']='File Added']">
    1.20 +      <xsl:variable name="file_id"
    1.21 +        select="substring-before(field[@name='old_value'],':')"/>
    1.22 +      <attachment>
    1.23 +	<!-- isobsolete is an attribute of bugzilla:attachment, but that
    1.24 +	     proves hard to deal with so we treat it as a node and fix it
    1.25 +	     up in attachment_post.xsl -->
    1.26 +	<isobsolete>
    1.27 +	  <xsl:value-of select="number(boolean(../history[field[@name='field_name']='File Deleted' and substring-before(field[@name='old_value'],':')=$file_id]))"/>
    1.28 +	</isobsolete>
    1.29 +	<attachid>
    1.30 +	  <xsl:value-of select="$file_id"/>
    1.31 +	</attachid>
    1.32 +	<date>
    1.33 +	  <xsl:call-template name="bugzilla-timestamp">
    1.34 +	    <xsl:with-param name="secs" select="field[@name='entrydate']"/>
    1.35 +	  </xsl:call-template>
    1.36 +	</date>
    1.37 +	<filename>
    1.38 +	  <xsl:value-of
    1.39 +	    select="substring-after(field[@name='old_value'],': ')"/>
    1.40 +	</filename>
    1.41 +      </attachment>
    1.42 +    </xsl:for-each>
    1.43 +</xsl:template>
    1.44 +
    1.45 +<xsl:template match="project_export">
    1.46 +  <attachments>
    1.47 +    <xsl:apply-templates/>
    1.48 +  </attachments>
    1.49 +</xsl:template>
    1.50 +
    1.51 +<xsl:template match="artifacts">
    1.52 +  <xsl:apply-templates/>
    1.53 +</xsl:template>
    1.54 +
    1.55 +<xsl:template match="artifact">
    1.56 +  <xsl:variable name="type"
    1.57 +    select="normalize-space(field[@name='artifact_type'])"/>
    1.58 +  <xsl:choose>
    1.59 +    <xsl:when test="$type = 'Feature Requests'">
    1.60 +      <xsl:call-template name="process-artifact"/>
    1.61 +    </xsl:when>
    1.62 +    <xsl:when test="$type = 'Patches'">
    1.63 +      <xsl:call-template name="process-artifact"/>
    1.64 +    </xsl:when>
    1.65 +    <xsl:when test="$type = 'Bugs'">
    1.66 +      <xsl:call-template name="process-artifact"/>
    1.67 +    </xsl:when>
    1.68 +  </xsl:choose>
    1.69 +</xsl:template>
    1.70 +
    1.71 +<xsl:template match="node()|text()" priority="-1"></xsl:template>
    1.72 +
    1.73 +</xsl:stylesheet>