VirtualBox

source: vbox/trunk/doc/manual/docbook-refentry-link-replacement-xsl-gen.xsl

Last change on this file was 98103, checked in by vboxsync, 16 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: 7.1 KB
Line 
1<?xml version="1.0"?>
2<!--
3 docbook-refentry-link-replacement-xsl-gen.xsl:
4 XSLT stylesheet for generate a stylesheet that replaces links
5 to the user manual in the manpages.
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 >
33
34 <xsl:output method="text" version="1.0" encoding="utf-8" indent="yes"/>
35 <xsl:strip-space elements="*"/>
36
37<xsl:param name="g_sMode" select="not-specified"/>
38
39 <!-- Translatable strings -->
40 <xsl:variable name="sChapter" select="'chapter'"/>
41 <xsl:variable name="sSection" select="'section'"/>
42 <xsl:variable name="sOfManual" select="'of the user manual'"/>
43 <xsl:variable name="sInManual" select="'in the user manual'"/>
44
45
46<!-- Default operation is to supress output -->
47<xsl:template match="node()|@*">
48 <xsl:apply-templates/>
49</xsl:template>
50
51
52<!-- Remove all remarks. -->
53<xsl:template match="remark"/>
54
55<!--
56Output header and footer.
57-->
58<xsl:template match="/">
59 <xsl:if test="$g_sMode = 'first'">
60 <xsl:text>&lt;?xml version="1.0"?&gt;
61&lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" &gt;
62&lt;xsl:output method="xml" version="1.0" encoding="utf-8" indent="yes" /&gt;
63&lt;xsl:template match="node()|@*"&gt;
64 &lt;xsl:copy&gt;
65 &lt;xsl:apply-templates select="node()|@*"/&gt;
66 &lt;/xsl:copy&gt;
67&lt;/xsl:template&gt;
68
69</xsl:text>
70 </xsl:if>
71 <xsl:apply-templates/>
72 <xsl:if test="$g_sMode = 'last'">
73 <xsl:text>
74&lt;/xsl:stylesheet&gt;
75</xsl:text>
76 </xsl:if>
77</xsl:template>
78
79
80<!--
81Produce the transformation templates:
82-->
83<xsl:template match="chapter[@id]/title">
84 <xsl:text>
85&lt;xsl:template match="xref[@linkend='</xsl:text>
86 <xsl:value-of select="../@id"/><xsl:text>']"&gt;
87 &lt;xsl:text&gt;</xsl:text><xsl:value-of select="$sChapter"/><xsl:text> </xsl:text>
88 <xsl:value-of select="count(../preceding-sibling::chapter) + 1"/><xsl:text> &quot;</xsl:text>
89 <xsl:value-of select="normalize-space()"/>
90 <xsl:text>&quot; </xsl:text><xsl:value-of select="$sInManual"/><xsl:text>&lt;/xsl:text&gt;
91&lt;/xsl:template&gt;
92</xsl:text>
93 <xsl:apply-templates/>
94</xsl:template>
95
96<xsl:template match="sect1[@id]/title">
97 <xsl:text>&lt;xsl:template match="xref[@linkend='</xsl:text>
98 <xsl:value-of select="../@id"/><xsl:text>']"&gt;
99 &lt;xsl:text&gt;</xsl:text><xsl:value-of select="$sSection"/><xsl:text> </xsl:text>
100 <xsl:value-of select="count(../../preceding-sibling::chapter) + 1"/><xsl:text>.</xsl:text>
101 <xsl:value-of select="count(../preceding-sibling::sect1) + 1"/>
102 <xsl:text> &quot;</xsl:text>
103 <xsl:value-of select="normalize-space()"/><xsl:text>&quot; </xsl:text>
104 <xsl:value-of select="$sOfManual"/><xsl:text>&lt;/xsl:text&gt;
105&lt;/xsl:template&gt;
106</xsl:text>
107 <xsl:apply-templates/>
108</xsl:template>
109
110<xsl:template match="sect2[@id]/title">
111 <xsl:text>&lt;xsl:template match="xref[@linkend='</xsl:text>
112 <xsl:value-of select="../@id"/><xsl:text>']"&gt;
113 &lt;xsl:text&gt;</xsl:text><xsl:value-of select="$sSection"/><xsl:text> </xsl:text>
114 <xsl:value-of select="count(../../../preceding-sibling::chapter) + 1"/><xsl:text>.</xsl:text>
115 <xsl:value-of select="count(../../preceding-sibling::sect1) + 1"/><xsl:text>.</xsl:text>
116 <xsl:value-of select="count(../preceding-sibling::sect2) + 1"/>
117 <xsl:text> &quot;</xsl:text>
118 <xsl:value-of select="normalize-space()"/><xsl:text>&quot; </xsl:text>
119 <xsl:value-of select="$sOfManual"/><xsl:text>&lt;/xsl:text&gt;
120&lt;/xsl:template&gt;
121</xsl:text>
122 <xsl:apply-templates/>
123</xsl:template>
124
125<xsl:template match="sect3[@id]/title">
126 <xsl:text>&lt;xsl:template match="xref[@linkend='</xsl:text>
127 <xsl:value-of select="../@id"/><xsl:text>']"&gt;
128 &lt;xsl:text&gt;</xsl:text><xsl:value-of select="$sSection"/><xsl:text> </xsl:text>
129 <xsl:value-of select="count(../../../../preceding-sibling::chapter) + 1"/><xsl:text>.</xsl:text>
130 <xsl:value-of select="count(../../../preceding-sibling::sect1) + 1"/><xsl:text>.</xsl:text>
131 <xsl:value-of select="count(../../preceding-sibling::sect2) + 1"/><xsl:text>.</xsl:text>
132 <xsl:value-of select="count(../preceding-sibling::sect3) + 1"/>
133 <xsl:text> &quot;</xsl:text>
134 <xsl:value-of select="normalize-space()"/><xsl:text>&quot; </xsl:text>
135 <xsl:value-of select="$sOfManual"/><xsl:text>&lt;/xsl:text&gt;
136&lt;/xsl:template&gt;
137</xsl:text>
138 <xsl:apply-templates/>
139</xsl:template>
140
141<xsl:template match="preface[@id]/title">
142 <xsl:text>&lt;xsl:template match="xref[@linkend='</xsl:text>
143 <xsl:value-of select="../@id"/><xsl:text>']"&gt;
144 &lt;xsl:text&gt;&quot;</xsl:text>
145 <xsl:value-of select="normalize-space()"/><xsl:text>&quot; </xsl:text>
146 <xsl:value-of select="$sOfManual"/><xsl:text>&lt;/xsl:text&gt;
147&lt;/xsl:template&gt;
148</xsl:text>
149 <xsl:apply-templates/>
150</xsl:template>
151
152<xsl:template match="refentry[@id]/refentryinfo/title">
153 <xsl:text>&lt;xsl:template match="xref[@linkend='</xsl:text>
154 <xsl:value-of select="../../@id"/><xsl:text>']"&gt;
155 &lt;xsl:text&gt; &quot;</xsl:text>
156 <xsl:value-of select="normalize-space()"/><xsl:text>&quot;&lt;/xsl:text&gt;
157&lt;/xsl:template&gt;
158</xsl:text>
159 <xsl:apply-templates/>
160</xsl:template>
161
162<xsl:template match="refsect2[@id]/title">
163 <xsl:text>&lt;xsl:template match="xref[@linkend='</xsl:text>
164 <xsl:value-of select="../@id"/><xsl:text>']"&gt;
165 &lt;xsl:text&gt;&quot;</xsl:text>
166 <xsl:value-of select="normalize-space()"/><xsl:text>&quot;&lt;/xsl:text&gt;
167&lt;/xsl:template&gt;
168</xsl:text>
169 <xsl:apply-templates/>
170</xsl:template>
171
172
173<!--
174 Debug/Diagnostics: Return the path to the specified node (by default the current).
175 -->
176<xsl:template name="get-node-path">
177 <xsl:param name="Node" select="."/>
178 <xsl:for-each select="$Node">
179 <xsl:for-each select="ancestor-or-self::node()">
180 <xsl:choose>
181 <xsl:when test="name(.) = ''">
182 <xsl:text>text()</xsl:text>
183 </xsl:when>
184 <xsl:otherwise>
185 <xsl:value-of select="concat('/', name(.))"/>
186 <xsl:choose>
187 <xsl:when test="@id">
188 <xsl:text>[@id=</xsl:text>
189 <xsl:value-of select="@id"/>
190 <xsl:text>]</xsl:text>
191 </xsl:when>
192 <xsl:when test="position() > 1">
193 <xsl:text>[</xsl:text><xsl:value-of select="position()"/><xsl:text>]</xsl:text>
194 </xsl:when>
195 </xsl:choose>
196 </xsl:otherwise>
197 </xsl:choose>
198 </xsl:for-each>
199 </xsl:for-each>
200</xsl:template>
201
202</xsl:stylesheet>
203
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use