blob: 1ee5435ee8176809df7f68bf4aa228dd3f46e320 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
|
<?xml version="1.0"?>
<!--
docbook-refentry-to-manual-sect1.xsl:
XSLT stylesheet for transforming a refentry (manpage)
to a sect1 for the user manual.
Copyright (C) 2006-2020 Oracle Corporation
This file is part of VirtualBox Open Source Edition (OSE), as
available from http://www.virtualbox.org. This file is free software;
you can redistribute it and/or modify it under the terms of the GNU
General Public License (GPL) as published by the Free Software
Foundation, in version 2 as it comes in the "COPYING" file of the
VirtualBox OSE distribution. VirtualBox OSE is distributed in the
hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
-->
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:str="http://xsltsl.org/string"
>
<xsl:import href="string.xsl"/>
<xsl:output method="xml" version="1.0" encoding="utf-8" indent="yes"/>
<xsl:strip-space elements="*"/>
<!-- - - - - - - - - - - - - - - - - - - - - - -
global XSLT variables
- - - - - - - - - - - - - - - - - - - - - - -->
<!-- - - - - - - - - - - - - - - - - - - - - - -
base operation is to copy.
- - - - - - - - - - - - - - - - - - - - - - -->
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<!-- - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - -->
<!-- rename refentry to sect1 -->
<xsl:template match="refentry">
<xsl:element name="sect1">
<xsl:attribute name="condition">refentry</xsl:attribute>
<xsl:apply-templates select="node()|@*"/>
</xsl:element>
</xsl:template>
<!-- Remove refentryinfo, keeping the title element. -->
<xsl:template match="refentryinfo">
<xsl:if test="./title">
<xsl:copy-of select="./title"/>
</xsl:if>
</xsl:template>
<!-- Morph refnamediv into a brief description. -->
<xsl:template match="refnamediv">
<xsl:element name="para">
<xsl:call-template name="capitalize">
<xsl:with-param name="text" select="normalize-space(./refpurpose)"/>
</xsl:call-template>
<xsl:text>.</xsl:text>
</xsl:element>
</xsl:template>
<!-- Morph the refsynopsisdiv part into a synopsis section. -->
<xsl:template match="refsynopsisdiv">
<xsl:if test="name(*[1]) != 'cmdsynopsis'"><xsl:message terminate="yes">Expected refsynopsisdiv to start with cmdsynopsis</xsl:message></xsl:if>
<xsl:if test="title"><xsl:message terminate="yes">No title element supported in refsynopsisdiv</xsl:message></xsl:if>
<xsl:element name="sect2">
<xsl:attribute name="role">not-in-toc</xsl:attribute>
<xsl:attribute name="condition">refsynopsisdiv</xsl:attribute>
<xsl:element name="title">
<xsl:text>Synopsis</xsl:text>
</xsl:element>
<xsl:apply-templates />
</xsl:element>
</xsl:template>
<!-- refsect1 -> sect2 -->
<xsl:template match="refsect1">
<xsl:if test="not(title)"><xsl:message terminate="yes">refsect1 requires title</xsl:message></xsl:if>
<xsl:element name="sect2">
<xsl:attribute name="role">not-in-toc</xsl:attribute>
<xsl:attribute name="condition">refsect1</xsl:attribute>
<xsl:apply-templates />
</xsl:element>
</xsl:template>
<!-- refsect2 -> sect3 -->
<xsl:template match="refsect2">
<xsl:if test="not(title)"><xsl:message terminate="yes">refsect2 requires title</xsl:message></xsl:if>
<xsl:element name="sect3">
<xsl:attribute name="role">not-in-toc</xsl:attribute>
<xsl:attribute name="condition">refsect2</xsl:attribute>
<xsl:apply-templates />
</xsl:element>
</xsl:template>
<!-- refsect3 -> sect4 -->
<xsl:template match="refsect3">
<xsl:if test="not(title)"><xsl:message terminate="yes">refsect3 requires title</xsl:message></xsl:if>
<xsl:element name="sect4">
<xsl:attribute name="role">not-in-toc</xsl:attribute>
<xsl:attribute name="condition">refsect3</xsl:attribute>
<xsl:apply-templates />
</xsl:element>
</xsl:template>
<!-- Remove refmeta. -->
<xsl:template match="refmeta"/>
<!--
remark extensions:
-->
<!-- Default: remove all remarks. -->
<xsl:template match="remark"/>
<!-- help-manual - stuff that should only be included in the manual. -->
<xsl:template match="remark[@role = 'help-manual']">
<xsl:apply-templates/>
</xsl:template>
<!-- help-copy-synopsis - used in refsect2 to copy synopsis from the refsynopsisdiv. -->
<xsl:template match="remark[@role = 'help-copy-synopsis']">
<xsl:if test="not(parent::refsect2)">
<xsl:message terminate="yes">The help-copy-synopsis remark is only applicable in refsect2.</xsl:message>
</xsl:if>
<xsl:variable name="sSrcId" select="concat('synopsis-',../@id)"/>
<xsl:if test="not(/refentry/refsynopsisdiv/cmdsynopsis[@id = $sSrcId])">
<xsl:message terminate="yes">Could not find any cmdsynopsis with id=<xsl:value-of select="$sSrcId"/> in refsynopsisdiv.</xsl:message>
</xsl:if>
<xsl:element name="cmdsynopsis">
<xsl:copy-of select="/refentry/refsynopsisdiv/cmdsynopsis[@id = $sSrcId]/node()"/>
</xsl:element>
</xsl:template>
<!--
Captializes the given text.
-->
<xsl:template name="capitalize">
<xsl:param name="text"/>
<xsl:call-template name="str:to-upper">
<xsl:with-param name="text" select="substring($text,1,1)"/>
</xsl:call-template>
<xsl:value-of select="substring($text,2)"/>
</xsl:template>
</xsl:stylesheet>
|