1
<?xml version="1.0" encoding="UTF-8"?>
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"
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">
12
<xsl:when test="$docbook/*/d:title">
13
<xsl:copy-of select="$docbook/*/d:title"/>
15
<xsl:when test="$docbook/*/d:info/d:title">
16
<xsl:copy-of select="$docbook/*/d:info/d:title"/>
19
<xsl:message terminate="yes">
20
<xsl:text>This template requires a docbook title!</xsl:text>
25
<xsl:variable name="plainsubtitle">
27
<xsl:when test="$docbook/*/d:subtitle">
28
<xsl:copy-of select="$docbook/*/d:subtitle"/>
30
<xsl:when test="$docbook/*/d:info/d:subtitle">
31
<xsl:copy-of select="$docbook/*/d:info/d:subtitle"/>
35
<xsl:variable name="productname">
36
<xsl:copy-of select="$docbook/*/d:info/d:productname"/>
38
<xsl:variable name="title">
41
If there's a product name, and the product name is in the
42
subtitle then use the product name for the title.
44
<xsl:when test="$productname and contains($plaintitle,$productname)">
45
<xsl:copy-of select="$productname"/>
48
<xsl:copy-of select="$plaintitle"/>
52
<xsl:variable name="subtitle">
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)"/>
58
<xsl:when test="$plainsubtitle">
59
<xsl:value-of select="$plainsubtitle"/>
62
<xsl:message terminate="yes">Missing <subtitle/> docbook tag!</xsl:message>
66
<xsl:variable name="releaseinfo">
68
<xsl:when test="$docbook//d:info[1]/d:releaseinfo">
69
<xsl:value-of select="$docbook//d:info[1]/d:releaseinfo"/>
72
<xsl:message terminate="yes">
73
<xsl:text>This template requires the <releaseinfo/> docbook tag!</xsl:text>
78
<xsl:variable name="pubdate">
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"/>
86
<xsl:text>This template requires the <pubdate/> docbook tag!</xsl:text>
91
<xsl:template match="node() | @*">
93
<xsl:apply-templates select="@* | node()"/>
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"/>
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"/>
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"/>
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"/>
126
<xsl:copy-of select="$textWithPubDate"/>
129
<xsl:template name="replaceText">
130
<xsl:param name="text"/>
131
<xsl:param name="replace"/>
132
<xsl:param name="with"/>
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)"/>
141
<xsl:copy-of select="$text"/>
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,'/'))"/>
153
<xsl:when test="$month = 1">
154
<xsl:text>Jan</xsl:text>
156
<xsl:when test="$month = 2">
157
<xsl:text>Feb</xsl:text>
159
<xsl:when test="$month = 3">
160
<xsl:text>Mar</xsl:text>
162
<xsl:when test="$month = 4">
163
<xsl:text>Apr</xsl:text>
165
<xsl:when test="$month = 5">
166
<xsl:text>May</xsl:text>
168
<xsl:when test="$month = 6">
169
<xsl:text>Jun</xsl:text>
171
<xsl:when test="$month = 7">
172
<xsl:text>Jul</xsl:text>
174
<xsl:when test="$month = 8">
175
<xsl:text>Aug</xsl:text>
177
<xsl:when test="$month = 9">
178
<xsl:text>Sep</xsl:text>
180
<xsl:when test="$month = 10">
181
<xsl:text>Oct</xsl:text>
183
<xsl:when test="$month = 11">
184
<xsl:text>Nov</xsl:text>
186
<xsl:when test="$month = 12">
187
<xsl:text>Dec</xsl:text>
190
<xsl:message terminate="yes">Bad Month value <xsl:value-of select="$month"/></xsl:message>
193
<xsl:text>. </xsl:text>
195
<xsl:when test="starts-with($day, '0')">
196
<xsl:value-of select="substring($day, 2)"/>
199
<xsl:value-of select="$day"/>
202
<xsl:text>, 20</xsl:text>
203
<xsl:value-of select="$year"/>