~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-31 18:03:16 UTC
  • Revision ID: anne@openstack.org-20110131180316-3b7spd1avvzvvtye
Updating build enviro for Mac OS X

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:choose>
 
62
    </xsl:variable>
 
63
    <xsl:variable name="releaseinfo">
 
64
        <xsl:choose>
 
65
            <xsl:when test="$docbook//d:info[1]/d:releaseinfo">
 
66
                <xsl:value-of select="$docbook//d:info[1]/d:releaseinfo"/>
 
67
            </xsl:when>
 
68
        </xsl:choose>
 
69
    </xsl:variable>
 
70
    <xsl:variable name="pubdate">
 
71
        <xsl:choose>
 
72
            <xsl:when test="$docbook//d:info[1]/d:pubdate">
 
73
                <xsl:call-template name="shortDate">
 
74
                    <xsl:with-param name="in" select="$docbook//d:info[1]/d:pubdate"/>
 
75
                </xsl:call-template>
 
76
            </xsl:when>
 
77
        </xsl:choose>
 
78
    </xsl:variable>
 
79
 
 
80
    <xsl:template match="node() | @*">
 
81
        <xsl:copy>
 
82
            <xsl:apply-templates select="@* | node()"/>
 
83
        </xsl:copy>
 
84
    </xsl:template>
 
85
 
 
86
    <xsl:template match="text()">
 
87
        <xsl:variable name="textWithTitle">
 
88
            <xsl:call-template name="replaceText">
 
89
                <xsl:with-param name="text" select="."/>
 
90
                <xsl:with-param name="replace" select="'$title$'"/>
 
91
                <xsl:with-param name="with" select="$title"/>
 
92
            </xsl:call-template>
 
93
        </xsl:variable>
 
94
        <xsl:variable name="textWithSubTitle">
 
95
            <xsl:call-template name="replaceText">
 
96
                <xsl:with-param name="text" select="$textWithTitle"/>
 
97
                <xsl:with-param name="replace" select="'$subtitle$'"/>
 
98
                <xsl:with-param name="with" select="$subtitle"/>
 
99
            </xsl:call-template>
 
100
        </xsl:variable>
 
101
        <xsl:variable name="textWithReleaseInfo">
 
102
            <xsl:call-template name="replaceText">
 
103
                <xsl:with-param name="text" select="$textWithSubTitle"/>
 
104
                <xsl:with-param name="replace" select="'$releaseinfo$'"/>
 
105
                <xsl:with-param name="with" select="$releaseinfo"/>
 
106
            </xsl:call-template>
 
107
        </xsl:variable>
 
108
        <xsl:variable name="textWithPubDate">
 
109
            <xsl:call-template name="replaceText">
 
110
                <xsl:with-param name="text" select="$textWithReleaseInfo"/>
 
111
                <xsl:with-param name="replace" select="'$pubdate$'"/>
 
112
                <xsl:with-param name="with" select="$pubdate"/>
 
113
            </xsl:call-template>
 
114
        </xsl:variable>
 
115
        <xsl:copy-of select="$textWithPubDate"/>
 
116
    </xsl:template>
 
117
 
 
118
    <xsl:template name="replaceText">
 
119
        <xsl:param name="text"/>
 
120
        <xsl:param name="replace"/>
 
121
        <xsl:param name="with"/>
 
122
 
 
123
        <xsl:choose>
 
124
            <xsl:when test="contains($text,$replace)">
 
125
                <xsl:value-of select="substring-before($text,$replace)"/>
 
126
                <xsl:value-of select="normalize-space($with)"/>
 
127
                <xsl:value-of select="substring-after($text,$replace)"/>
 
128
            </xsl:when>
 
129
            <xsl:otherwise>
 
130
                <xsl:copy-of select="$text"/>
 
131
            </xsl:otherwise>
 
132
        </xsl:choose>
 
133
    </xsl:template>
 
134
 
 
135
    <xsl:template name="shortDate">
 
136
        <xsl:param name="in"/>
 
137
        <xsl:choose>
 
138
            <xsl:when test="$in">
 
139
                <xsl:variable name="month" select="normalize-space(substring-before(string($in),'/'))"/>
 
140
                <xsl:variable name="rest"   select="substring-after(string($in),'/')"/>
 
141
                <xsl:variable name="day"   select="normalize-space(substring-before($rest,'/'))"/>
 
142
                <xsl:variable name="year" select="normalize-space(substring-after($rest,'/'))"/>
 
143
                <xsl:choose>
 
144
                    <xsl:when test="$month = 1">
 
145
                        <xsl:text>Jan</xsl:text>
 
146
                    </xsl:when>
 
147
                    <xsl:when test="$month = 2">
 
148
                        <xsl:text>Feb</xsl:text>
 
149
                    </xsl:when>
 
150
                    <xsl:when test="$month = 3">
 
151
                        <xsl:text>Mar</xsl:text>
 
152
                    </xsl:when>
 
153
                    <xsl:when test="$month = 4">
 
154
                        <xsl:text>Apr</xsl:text>
 
155
                    </xsl:when>
 
156
                    <xsl:when test="$month = 5">
 
157
                        <xsl:text>May</xsl:text>
 
158
                    </xsl:when>
 
159
                    <xsl:when test="$month = 6">
 
160
                        <xsl:text>Jun</xsl:text>
 
161
                    </xsl:when>
 
162
                    <xsl:when test="$month = 7">
 
163
                        <xsl:text>Jul</xsl:text>
 
164
                    </xsl:when>
 
165
                    <xsl:when test="$month = 8">
 
166
                        <xsl:text>Aug</xsl:text>
 
167
                    </xsl:when>
 
168
                    <xsl:when test="$month = 9">
 
169
                        <xsl:text>Sep</xsl:text>
 
170
                    </xsl:when>
 
171
                    <xsl:when test="$month = 10">
 
172
                        <xsl:text>Oct</xsl:text>
 
173
                    </xsl:when>
 
174
                    <xsl:when test="$month = 11">
 
175
                        <xsl:text>Nov</xsl:text>
 
176
                    </xsl:when>
 
177
                    <xsl:when test="$month = 12">
 
178
                        <xsl:text>Dec</xsl:text>
 
179
                    </xsl:when>
 
180
                    <xsl:otherwise>
 
181
                        <xsl:message terminate="yes">Bad Month value <xsl:value-of select="$month"/></xsl:message>
 
182
                    </xsl:otherwise>
 
183
                </xsl:choose>
 
184
                <xsl:text>. </xsl:text>
 
185
                <xsl:choose>
 
186
                    <xsl:when test="starts-with($day, '0')">
 
187
                        <xsl:value-of select="substring($day, 2)"/>
 
188
                    </xsl:when>
 
189
                    <xsl:otherwise>
 
190
                        <xsl:value-of select="$day"/>
 
191
                    </xsl:otherwise>
 
192
                </xsl:choose>
 
193
                <xsl:text>, 20</xsl:text>
 
194
                <xsl:value-of select="$year"/>
 
195
            </xsl:when>
 
196
            <xsl:otherwise />
 
197
        </xsl:choose>
 
198
    </xsl:template>
 
199
</xsl:stylesheet>