summaryrefslogtreecommitdiffstats
path: root/packaging/insert-colophon.xsl
blob: e64844ff447d1274558f5ffcd5cff6cb2634a321 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<!-- 

Add a worker to a document's colophon. The following stringparam values are
required and expected:
  firstname : Contributor's first name
    surname : Contributor's family or surname
   initials : Initials for use in document revision history
      email : email address (should match Fedora Project email)

The following stringparam values are optional:
  othername : Middle initial

The following stringparam values will be set in this stylesheet:
  wholename : firstname + " " [ + othername + " " ] + surname
         id : firstname + surname

-->

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <xsl:output encoding="UTF-8" indent="yes" method="xml"
    omit-xml-declaration="no" standalone="no" version="1.0"
    doctype-system="../../docs-common/packaging/rpm-info.dtd"/>

  <!-- Cope if no othername is provided -->
  <xsl:param name="othername" select="''"/>

  <xsl:template match="/">
    <xsl:apply-templates/>
  </xsl:template>

  <xsl:template match="rpm-info">
    <xsl:element name="rpm-info">
      <xsl:for-each select="*">
	<xsl:choose>
	  <xsl:when test="self::colophon">
	    <xsl:call-template name="colophon">
	      <xsl:with-param name="firstname"><xsl:value-of
		  select="$firstname"/></xsl:with-param>
	    </xsl:call-template>
	  </xsl:when>
	  <xsl:otherwise><xsl:copy-of select="."/></xsl:otherwise>
	</xsl:choose>
      </xsl:for-each>
    </xsl:element>
  </xsl:template>

  <xsl:template name="colophon">
    <xsl:element name="colophon">
      <xsl:copy-of select="*"/>
      <xsl:element name="worker" use-attribute-sets="person"/>
    </xsl:element>
  </xsl:template>

  <xsl:attribute-set name="person">
    <xsl:attribute name="firstname"><xsl:value-of
	select="$firstname"/></xsl:attribute>
    <xsl:attribute name="othername"><xsl:value-of
	select="$othername"/></xsl:attribute>
    <xsl:attribute name="surname"><xsl:value-of
	select="$surname"/></xsl:attribute>
    <xsl:attribute name="initials"><xsl:value-of
	select="$initials"/></xsl:attribute>
    <xsl:attribute name="email"><xsl:value-of select="$email"/></xsl:attribute>
    <xsl:attribute name="wholename"><xsl:value-of
	select="$firstname"/><xsl:text> </xsl:text><xsl:if
	test="$othername"><xsl:value-of 
	  select="$othername"/><xsl:text> </xsl:text></xsl:if><xsl:value-of 
	select="$surname"/></xsl:attribute>
    <xsl:attribute name="id"><xsl:value-of select="$firstname"/><xsl:value-of
	select="$surname"/></xsl:attribute>
  </xsl:attribute-set>

</xsl:stylesheet>