~annegentle/openstack-devel/working

« back to all changes in this revision

Viewing changes to doc/buildpdf/rc-maven-cloud-docs/target/classes/cloud/cover.xsl

  • Committer: Anne Gentle
  • Date: 2011-01-28 23:01:29 UTC
  • Revision ID: anne@openstack.org-20110128230129-73peiiwoeebab2f9
Updates and edits while testing docs

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<?xml version="1.0" encoding="UTF-8"?>
2
 
 
3
 
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4
 
                xmlns:d="http://docbook.org/ns/docbook"
5
 
                xmlns:svg="http://www.w3.org/2000/svg"
6
 
                version="1.0">
7
 
    <xsl:output method="xml" encoding="UTF-8" media-type="image/svg+xml" standalone="no"/>
8
 
    <xsl:param name="docbook.infile" select="'/Users/jorgew/projects/cloud-files-api-docs/src/docbkx/cfdevguide_d5.xml'"/>
9
 
    <xsl:variable name="docbook" select="document(concat('file://',$docbook.infile))"/>
10
 
    <xsl:variable name="plaintitle">
11
 
        <xsl:choose>
12
 
            <xsl:when test="$docbook/*/d:title">
13
 
                <xsl:copy-of select="$docbook/*/d:title"/>
14
 
            </xsl:when>
15
 
            <xsl:when test="$docbook/*/d:info/d:title">
16
 
                <xsl:copy-of select="$docbook/*/d:info/d:title"/>
17
 
            </xsl:when>
18
 
            <xsl:otherwise>
19
 
                <xsl:message terminate="yes">
20
 
                    <xsl:text>This template requires a docbook title!</xsl:text>
21
 
                </xsl:message>
22
 
            </xsl:otherwise>
23
 
        </xsl:choose>
24
 
    </xsl:variable>
25
 
    <xsl:variable name="plainsubtitle">
26
 
        <xsl:choose>
27
 
            <xsl:when test="$docbook/*/d:subtitle">
28
 
                <xsl:copy-of select="$docbook/*/d:subtitle"/>
29
 
            </xsl:when>
30
 
            <xsl:when test="$docbook/*/d:info/d:subtitle">
31
 
                <xsl:copy-of select="$docbook/*/d:info/d:subtitle"/>
32
 
            </xsl:when>
33
 
        </xsl:choose>
34
 
    </xsl:variable>
35
 
    <xsl:variable name="productname">
36
 
        <xsl:copy-of select="$docbook/*/d:info/d:productname"/>
37
 
    </xsl:variable>
38
 
    <xsl:variable name="title">
39
 
        <xsl:choose>
40
 
            <!--
41
 
                If there's a product name, and the product name is in the
42
 
                subtitle then use the product name for the title.
43
 
            -->
44
 
            <xsl:when test="$productname and contains($plaintitle,$productname)">
45
 
                <xsl:copy-of select="$productname"/>
46
 
            </xsl:when>
47
 
            <xsl:otherwise>
48
 
                <xsl:copy-of select="$plaintitle"/>
49
 
            </xsl:otherwise>
50
 
        </xsl:choose>
51
 
    </xsl:variable>
52
 
    <xsl:variable name="subtitle">
53
 
        <xsl:choose>
54
 
            <xsl:when test="$productname and contains($plaintitle,$productname)">
55
 
                <xsl:value-of select="substring-before($plaintitle,$productname)"/>
56
 
                <xsl:value-of select="substring-after($plaintitle,$productname)"/>
57
 
            </xsl:when>
58
 
            <xsl:when test="$plainsubtitle">
59
 
                <xsl:value-of select="$plainsubtitle"/>
60
 
            </xsl:when>
61
 
            <xsl:otherwise>
62
 
                <xsl:message terminate="yes">Missing &lt;subtitle/&gt; docbook tag!</xsl:message>
63
 
            </xsl:otherwise>
64
 
        </xsl:choose>
65
 
    </xsl:variable>
66
 
    <xsl:variable name="releaseinfo">
67
 
        <xsl:choose>
68
 
            <xsl:when test="$docbook//d:info[1]/d:releaseinfo">
69
 
                <xsl:value-of select="$docbook//d:info[1]/d:releaseinfo"/>
70
 
            </xsl:when>
71
 
            <xsl:otherwise>
72
 
                <xsl:message terminate="yes">
73
 
                    <xsl:text>This template requires the &lt;releaseinfo/&gt; docbook tag!</xsl:text>
74
 
                </xsl:message>
75
 
            </xsl:otherwise>
76
 
        </xsl:choose>
77
 
    </xsl:variable>
78
 
    <xsl:variable name="pubdate">
79
 
        <xsl:choose>
80
 
            <xsl:when test="$docbook//d:info[1]/d:pubdate">
81
 
                <xsl:call-template name="shortDate">
82
 
                    <xsl:with-param name="in" select="$docbook//d:info[1]/d:pubdate"/>
83
 
                </xsl:call-template>
84
 
            </xsl:when>
85
 
            <xsl:otherwise>
86
 
                <xsl:text>This template requires the &lt;pubdate/&gt; docbook tag!</xsl:text>
87
 
            </xsl:otherwise>
88
 
        </xsl:choose>
89
 
    </xsl:variable>
90
 
 
91
 
    <xsl:template match="node() | @*">
92
 
        <xsl:copy>
93
 
            <xsl:apply-templates select="@* | node()"/>
94
 
        </xsl:copy>
95
 
    </xsl:template>
96
 
 
97
 
    <xsl:template match="text()">
98
 
        <xsl:variable name="textWithTitle">
99
 
            <xsl:call-template name="replaceText">
100
 
                <xsl:with-param name="text" select="."/>
101
 
                <xsl:with-param name="replace" select="'$title$'"/>
102
 
                <xsl:with-param name="with" select="$title"/>
103
 
            </xsl:call-template>
104
 
        </xsl:variable>
105
 
        <xsl:variable name="textWithSubTitle">
106
 
            <xsl:call-template name="replaceText">
107
 
                <xsl:with-param name="text" select="$textWithTitle"/>
108
 
                <xsl:with-param name="replace" select="'$subtitle$'"/>
109
 
                <xsl:with-param name="with" select="$subtitle"/>
110
 
            </xsl:call-template>
111
 
        </xsl:variable>
112
 
        <xsl:variable name="textWithReleaseInfo">
113
 
            <xsl:call-template name="replaceText">
114
 
                <xsl:with-param name="text" select="$textWithSubTitle"/>
115
 
                <xsl:with-param name="replace" select="'$releaseinfo$'"/>
116
 
                <xsl:with-param name="with" select="$releaseinfo"/>
117
 
            </xsl:call-template>
118
 
        </xsl:variable>
119
 
        <xsl:variable name="textWithPubDate">
120
 
            <xsl:call-template name="replaceText">
121
 
                <xsl:with-param name="text" select="$textWithReleaseInfo"/>
122
 
                <xsl:with-param name="replace" select="'$pubdate$'"/>
123
 
                <xsl:with-param name="with" select="$pubdate"/>
124
 
            </xsl:call-template>
125
 
        </xsl:variable>
126
 
        <xsl:copy-of select="$textWithPubDate"/>
127
 
    </xsl:template>
128
 
 
129
 
    <xsl:template name="replaceText">
130
 
        <xsl:param name="text"/>
131
 
        <xsl:param name="replace"/>
132
 
        <xsl:param name="with"/>
133
 
 
134
 
        <xsl:choose>
135
 
            <xsl:when test="contains($text,$replace)">
136
 
                <xsl:value-of select="substring-before($text,$replace)"/>
137
 
                <xsl:value-of select="normalize-space($with)"/>
138
 
                <xsl:value-of select="substring-after($text,$replace)"/>
139
 
            </xsl:when>
140
 
            <xsl:otherwise>
141
 
                <xsl:copy-of select="$text"/>
142
 
            </xsl:otherwise>
143
 
        </xsl:choose>
144
 
    </xsl:template>
145
 
 
146
 
  <xsl:template name="shortDate">
147
 
      <xsl:param name="in"/>
148
 
      <xsl:variable name="month" select="normalize-space(substring-before(string($in),'/'))"/>
149
 
      <xsl:variable name="rest"   select="substring-after(string($in),'/')"/>
150
 
      <xsl:variable name="day"   select="normalize-space(substring-before($rest,'/'))"/>
151
 
      <xsl:variable name="year" select="normalize-space(substring-after($rest,'/'))"/>
152
 
      <xsl:choose>
153
 
          <xsl:when test="$month = 1">
154
 
              <xsl:text>Jan</xsl:text>
155
 
          </xsl:when>
156
 
          <xsl:when test="$month = 2">
157
 
              <xsl:text>Feb</xsl:text>
158
 
          </xsl:when>
159
 
          <xsl:when test="$month = 3">
160
 
              <xsl:text>Mar</xsl:text>
161
 
          </xsl:when>
162
 
          <xsl:when test="$month = 4">
163
 
              <xsl:text>Apr</xsl:text>
164
 
          </xsl:when>
165
 
          <xsl:when test="$month = 5">
166
 
              <xsl:text>May</xsl:text>
167
 
          </xsl:when>
168
 
          <xsl:when test="$month = 6">
169
 
              <xsl:text>Jun</xsl:text>
170
 
          </xsl:when>
171
 
          <xsl:when test="$month = 7">
172
 
              <xsl:text>Jul</xsl:text>
173
 
          </xsl:when>
174
 
          <xsl:when test="$month = 8">
175
 
              <xsl:text>Aug</xsl:text>
176
 
          </xsl:when>
177
 
          <xsl:when test="$month = 9">
178
 
              <xsl:text>Sep</xsl:text>
179
 
          </xsl:when>
180
 
          <xsl:when test="$month = 10">
181
 
              <xsl:text>Oct</xsl:text>
182
 
          </xsl:when>
183
 
          <xsl:when test="$month = 11">
184
 
              <xsl:text>Nov</xsl:text>
185
 
          </xsl:when>
186
 
          <xsl:when test="$month = 12">
187
 
              <xsl:text>Dec</xsl:text>
188
 
          </xsl:when>
189
 
          <xsl:otherwise>
190
 
              <xsl:message terminate="yes">Bad Month value <xsl:value-of select="$month"/></xsl:message>
191
 
          </xsl:otherwise>
192
 
      </xsl:choose>
193
 
      <xsl:text>. </xsl:text>
194
 
      <xsl:choose>
195
 
          <xsl:when test="starts-with($day, '0')">
196
 
              <xsl:value-of select="substring($day, 2)"/>
197
 
          </xsl:when>
198
 
          <xsl:otherwise>
199
 
              <xsl:value-of select="$day"/>
200
 
          </xsl:otherwise>
201
 
      </xsl:choose>
202
 
      <xsl:text>, 20</xsl:text>
203
 
      <xsl:value-of select="$year"/>
204
 
  </xsl:template>
205
 
</xsl:stylesheet>