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