VirtualBox

source: vbox/trunk/doc/manual/docbook-refentry-to-manual-sect1.xsl@ 104729

Last change on this file since 104729 was 98103, checked in by vboxsync, 23 months ago

Copyright year updates by scm.

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

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette