1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/attachment_descs.xsl Thu Nov 16 08:30:26 2006 +0000
1.3 @@ -0,0 +1,51 @@
1.4 +<?xml version="1.0"?>
1.5 +
1.6 +<!-- This style sheet takes a sourceforge artifact in html and outputs
1.7 + the attachment descriptions that it finds. The output is as follows:
1.8 + <attachments>
1.9 + <attachment>
1.10 + <attachid>###</attachid>
1.11 + <desc>...</desc>
1.12 + </attachment>
1.13 + ...
1.14 + </attachments>
1.15 +-->
1.16 +
1.17 +<xsl:stylesheet version="1.0"
1.18 + xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
1.19 + xmlns:xhtml="http://www.w3.org/1999/xhtml"
1.20 + exclude-result-prefixes="xhtml">
1.21 +
1.22 +<xsl:template match="xhtml:tr" mode="download">
1.23 + <attachment>
1.24 + <attachid>
1.25 + <xsl:value-of select="substring-before(substring-after(xhtml:td[4]/descendant::xhtml:a/@href,'file_id='),'&')"/>
1.26 + </attachid>
1.27 + <desc>
1.28 + <xsl:value-of select="normalize-space(xhtml:td[3])"/>
1.29 + </desc>
1.30 + </attachment>
1.31 +</xsl:template>
1.32 +
1.33 +<xsl:template match="xhtml:table[preceding-sibling::xhtml:h4='Attached Files:' and xhtml:tr/xhtml:td='Download']">
1.34 + <xsl:for-each select="xhtml:tr[descendant::xhtml:a='Download']">
1.35 + <xsl:apply-templates select="." mode="download"/>
1.36 + </xsl:for-each>
1.37 +</xsl:template>
1.38 +
1.39 +<xsl:template match="/">
1.40 + <attachments>
1.41 + <xsl:apply-templates/>
1.42 + <!-- A null description used as a fallback for when there is no
1.43 + description listed for an attachment. -->
1.44 + <desc xml:id="null"/>
1.45 + </attachments>
1.46 +</xsl:template>
1.47 +
1.48 +<xsl:template match="node()" priority="-1">
1.49 + <xsl:apply-templates/>
1.50 +</xsl:template>
1.51 +
1.52 +<xsl:template match="text()" priority="-1"></xsl:template>
1.53 +
1.54 +</xsl:stylesheet>