~ubuntu-branches/ubuntu/trusty/khronos-opencl-man/trusty

« back to all changes in this revision

Viewing changes to man/opencl-manpages-pre.xsl

  • Committer: Package Import Robot
  • Author(s): Mathieu Malaterre
  • Date: 2013-05-21 18:06:15 UTC
  • Revision ID: package-import@ubuntu.com-20130521180615-nzi6xdy3vgmf730j
Tags: 1.0~svn21772-1
InitialĀ DebianĀ Upload

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?xml version='1.0'?>
 
2
 
 
3
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
 
4
    <xsl:output
 
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"
 
8
        indent="yes"
 
9
        encoding="UTF-8"
 
10
    />
 
11
 
 
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)"/>
 
21
            </xsl:element>
 
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"/>
 
26
            </xsl:call-template>
 
27
        </xsl:if>
 
28
    </xsl:template>
 
29
 
 
30
    <!-- identity transform, for nodes that do not match anything else -->
 
31
    <xsl:template match="@*|node()">
 
32
        <xsl:copy>
 
33
            <xsl:apply-templates select="@*|node()"/>
 
34
        </xsl:copy>
 
35
    </xsl:template>
 
36
 
 
37
    <xsl:template match="refpurpose">
 
38
    <refpurpose>
 
39
    <xsl:value-of select="normalize-space(.)"/>
 
40
    </refpurpose>
 
41
    </xsl:template>
 
42
 
 
43
    <xsl:template match="refname">
 
44
    <refname>
 
45
    <xsl:value-of select="normalize-space(.)"/>
 
46
    </refname>
 
47
    </xsl:template>
 
48
 
 
49
    <xsl:template match="refentrytitle">
 
50
    <refentrytitle>
 
51
    <xsl:value-of select="normalize-space(.)"/>
 
52
    </refentrytitle>
 
53
    </xsl:template>
 
54
 
 
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="', '"/>
 
61
        </xsl:call-template>
 
62
    </xsl:template>
 
63
    <!-- TODO the same treatment should be reserved to refentrytitle -->
 
64
 
 
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">
 
69
        <manvolnum>
 
70
            <xsl:value-of select="concat(normalize-space(.), 'clc')"/>
 
71
        </manvolnum>
 
72
    </xsl:template>
 
73
 
 
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">
 
77
        <holder>
 
78
            <xsl:value-of select="concat(substring-before(normalize-space(), '. '), '.')"/>
 
79
        </holder>
 
80
    </xsl:template>
 
81
 
 
82
    <!-- The copyright info should be inside refentryinfo, not inside refmeta/refmiscinfo -->
 
83
    <xsl:template match="/refentry/refentryinfo">
 
84
        <xsl:copy>
 
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, '. ')"/>
 
97
            </xsl:element>
 
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>
 
102
            </xsl:element>
 
103
        </xsl:copy>
 
104
    </xsl:template>
 
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"/>
 
109
 
 
110
    <!-- now we recreate refmiscinfo to read "OpenCL Manual" -->
 
111
    <xsl:template match="/refentry/refmeta">
 
112
        <xsl:copy>
 
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>
 
119
            </xsl:element>
 
120
        </xsl:copy>
 
121
    </xsl:template>
 
122
 
 
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(.)"/>
 
128
    </xsl:template>
 
129
 
 
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(., '*')"/>
 
135
    </xsl:template>
 
136
    <xsl:template match="paramdef/parameter">
 
137
        <xsl:text> </xsl:text>
 
138
        <xsl:if test="starts-with(text(), '*')">
 
139
            <xsl:text>*</xsl:text>
 
140
        </xsl:if>
 
141
        <xsl:copy>
 
142
            <xsl:apply-templates select="@*|node()"/>
 
143
        </xsl:copy>
 
144
    </xsl:template>
 
145
 
 
146
<!--
 
147
         section manipulation
 
148
-->
 
149
 
 
150
    <!-- 'specification' section: skip the image. -->
 
151
    <xsl:template match="refsect1[@id='specification']//imageobject"/>
 
152
 
 
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"/>
 
164
                </xsl:for-each>
 
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"/>
 
168
                </xsl:for-each>
 
169
            </xsl:attribute>
 
170
            <xsl:apply-templates/>
 
171
        </xsl:element>
 
172
    </xsl:template>
 
173
 
 
174
    <!-- don't copy 'copyright' section, it's automatically created from the legal notice -->
 
175
    <xsl:template match="refsect3[@id='Copyright']"/>
 
176
 
 
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>
 
180
    </xsl:template>
 
181
 
 
182
</xsl:stylesheet>