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"/>
63
<xsl:variable name="releaseinfo">
65
<xsl:when test="$docbook//d:info[1]/d:releaseinfo">
66
<xsl:value-of select="$docbook//d:info[1]/d:releaseinfo"/>
70
<xsl:variable name="pubdate">
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"/>
80
<xsl:template match="node() | @*">
82
<xsl:apply-templates select="@* | node()"/>
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"/>
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"/>
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"/>
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"/>
115
<xsl:copy-of select="$textWithPubDate"/>
118
<xsl:template name="replaceText">
119
<xsl:param name="text"/>
120
<xsl:param name="replace"/>
121
<xsl:param name="with"/>
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)"/>
130
<xsl:copy-of select="$text"/>
135
<xsl:template name="shortDate">
136
<xsl:param name="in"/>
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,'/'))"/>
144
<xsl:when test="$month = 1">
145
<xsl:text>Jan</xsl:text>
147
<xsl:when test="$month = 2">
148
<xsl:text>Feb</xsl:text>
150
<xsl:when test="$month = 3">
151
<xsl:text>Mar</xsl:text>
153
<xsl:when test="$month = 4">
154
<xsl:text>Apr</xsl:text>
156
<xsl:when test="$month = 5">
157
<xsl:text>May</xsl:text>
159
<xsl:when test="$month = 6">
160
<xsl:text>Jun</xsl:text>
162
<xsl:when test="$month = 7">
163
<xsl:text>Jul</xsl:text>
165
<xsl:when test="$month = 8">
166
<xsl:text>Aug</xsl:text>
168
<xsl:when test="$month = 9">
169
<xsl:text>Sep</xsl:text>
171
<xsl:when test="$month = 10">
172
<xsl:text>Oct</xsl:text>
174
<xsl:when test="$month = 11">
175
<xsl:text>Nov</xsl:text>
177
<xsl:when test="$month = 12">
178
<xsl:text>Dec</xsl:text>
181
<xsl:message terminate="yes">Bad Month value <xsl:value-of select="$month"/></xsl:message>
184
<xsl:text>. </xsl:text>
186
<xsl:when test="starts-with($day, '0')">
187
<xsl:value-of select="substring($day, 2)"/>
190
<xsl:value-of select="$day"/>
193
<xsl:text>, 20</xsl:text>
194
<xsl:value-of select="$year"/>