3
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
5
doctype-public="-//OASIS//DTD DocBook MathML Module V1.1b1//EN"
6
doctype-system="http://www.oasis-open.org/docbook/xml/mathml/1.1CR1/dbmathml.dtd"
7
cdata-section-elements="book"
12
<!-- split an element with comma-separated text into multiple elements -->
13
<xsl:template name="str.split">
14
<xsl:param name="text"/>
15
<xsl:param name="elem"/>
16
<xsl:param name="sep" />
17
<xsl:if test="string-length($text) > 0">
18
<xsl:variable name="next" select="substring-before(concat($text,$sep), $sep)"/>
19
<xsl:element name="{$elem}">
20
<xsl:value-of select="normalize-space($next)"/>
22
<xsl:call-template name="str.split">
23
<xsl:with-param name="text" select="substring-after($text, $sep)"/>
24
<xsl:with-param name="elem" select="$elem"/>
25
<xsl:with-param name="sep" select="$sep"/>
30
<!-- identity transform, for nodes that do not match anything else -->
31
<xsl:template match="@*|node()">
33
<xsl:apply-templates select="@*|node()"/>
37
<xsl:template match="refpurpose">
39
<xsl:value-of select="normalize-space(.)"/>
43
<xsl:template match="refname">
45
<xsl:value-of select="normalize-space(.)"/>
49
<xsl:template match="refentrytitle">
51
<xsl:value-of select="normalize-space(.)"/>
55
<!-- keywords should be individual keywords, not a comma-separated list -->
56
<xsl:template match="keyword">
57
<xsl:call-template name="str.split">
58
<xsl:with-param name="text" select="."/>
59
<xsl:with-param name="elem" select="'keyword'"/>
60
<xsl:with-param name="sep" select="', '"/>
63
<!-- TODO the same treatment should be reserved to refentrytitle -->
65
<!-- The khronos documents are marked to be in man section 3, but this
66
causes conflicts with the C standard library pages (e.g. cbrt).
67
Append 'cl' to the OpenCL sections to resolve the conflict. -->
68
<xsl:template match="/refentry/refmeta/manvolnum">
70
<xsl:value-of select="concat(normalize-space(.), 'clc')"/>
74
<!-- copyright/holder should only be the copyright holder. The rest of the legal notice should
75
go into a legalnotice element inside refentryinfo -->
76
<xsl:template match="copyright/holder">
78
<xsl:value-of select="concat(substring-before(normalize-space(), '. '), '.')"/>
82
<!-- The copyright info should be inside refentryinfo, not inside refmeta/refmiscinfo -->
83
<xsl:template match="/refentry/refentryinfo">
85
<!-- copy existing stuff in refentryinfo -->
86
<xsl:apply-templates select="@*|node()"/>
87
<!-- copy and fix the copyright; note that this can't all be done from the
88
copyright/holder template because the legalnotice must go out -->
89
<xsl:variable name="wrongpath" select="../refmeta/refmiscinfo/copyright"/>
90
<!-- extract copyright/holder text -->
91
<xsl:variable name="cprt" select="normalize-space($wrongpath)"/>
92
<xsl:apply-templates select="$wrongpath"/>
93
<xsl:element name="legalnotice">
94
<!-- get the text after the first full-stop in the former
95
copyright/holder text -->
96
<xsl:value-of select="substring-after($cprt, '. ')"/>
98
<!-- while we're at it, add the orgname that should go here too -->
99
<xsl:element name="orgname">
100
<xsl:attribute name="class">consortium</xsl:attribute>
101
<xsl:text>The Khronos Group</xsl:text>
105
<!-- delete the copyright from original position, as well as the now-empty refmiscinfo
106
TODO: check that refmiscinfo is actually empty.
107
This is simply done by NOT copying it to the output file -->
108
<xsl:template match="/refentry/refmeta/refmiscinfo"/>
110
<!-- now we recreate refmiscinfo to read "OpenCL Manual" -->
111
<xsl:template match="/refentry/refmeta">
113
<!-- again, copy existing children -->
114
<xsl:apply-templates select="@*|node()"/>
115
<!-- and add our new refmiscinfo now -->
116
<xsl:element name="refmiscinfo">
117
<xsl:attribute name="class">manual</xsl:attribute>
118
<xsl:text>OpenCL Manual</xsl:text>
123
<!-- links are used throughout the OpenCL man pages to cross-reference enums and data types.
124
For the manpages production, we replace them with their textual content -->
125
<!-- TODO: we might want to automatically add these to the "see also" section" -->
126
<xsl:template match="link">
127
<xsl:value-of select="normalize-space(.)"/>
130
<!-- paramdefs have no space after them, and the * is inside the parameter,
131
so we manipulate them to add a space, and a * if necessary;
132
parameter elements are stripped of the leading * -->
133
<xsl:template match="paramdef/parameter/text()[starts-with(.,'*')]">
134
<xsl:value-of select="substring-after(., '*')"/>
136
<xsl:template match="paramdef/parameter">
137
<xsl:text> </xsl:text>
138
<xsl:if test="starts-with(text(), '*')">
139
<xsl:text>*</xsl:text>
142
<xsl:apply-templates select="@*|node()"/>
150
<!-- 'specification' section: skip the image. -->
151
<xsl:template match="refsect1[@id='specification']//imageobject"/>
153
<!-- turn olinks into ulinks with an url attribute that renders to page XX, section Title,
154
using data looked up from the section-to-page.xml table -->
155
<xsl:key name='specref' match='section' use='@id'/>
156
<xsl:template match="olink">
157
<xsl:variable name="secref" select="@uri"/>
158
<xsl:element name="ulink">
159
<xsl:attribute name="url">
160
<!-- TODO there must be a way to collect both in one go -->
161
<xsl:text>page </xsl:text>
162
<xsl:for-each select="document('section-to-page.xml')">
163
<xsl:value-of select="key('specref', $secref)/page"/>
165
<xsl:text>, section </xsl:text>
166
<xsl:for-each select="document('section-to-page.xml')">
167
<xsl:value-of select="key('specref', $secref)/title"/>
170
<xsl:apply-templates/>
174
<!-- don't copy 'copyright' section, it's automatically created from the legal notice -->
175
<xsl:template match="refsect3[@id='Copyright']"/>
177
<!-- Also see is more usually written See also in man pages-->
178
<xsl:template match="refsect1[@id='seealso']/title">
179
<title>See also</title>