VirtualBox

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

Last change on this file since 96316 was 96300, checked in by vboxsync, 2 years ago

doc: comment fixing

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.8 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-2020 Oracle Corporation
9
10 This file is part of VirtualBox Open Source Edition (OSE), as
11 available from http://www.virtualbox.org. This file is free software;
12 you can redistribute it and/or modify it under the terms of the GNU
13 General Public License (GPL) as published by the Free Software
14 Foundation, in version 2 as it comes in the "COPYING" file of the
15 VirtualBox OSE distribution. VirtualBox OSE is distributed in the
16 hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
17-->
18
19<xsl:stylesheet
20 version="1.0"
21 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
22 >
23
24 <xsl:output method="text" version="1.0" encoding="utf-8" indent="yes"/>
25 <xsl:strip-space elements="*"/>
26
27<xsl:param name="g_sMode" select="not-specified"/>
28
29 <!-- Translatable strings -->
30 <xsl:variable name="sChapter" select="'chapter'"/>
31 <xsl:variable name="sSection" select="'section'"/>
32 <xsl:variable name="sOfManual" select="'of the user manual'"/>
33 <xsl:variable name="sInManual" select="'in the user manual'"/>
34
35
36<!-- Default operation is to supress output -->
37<xsl:template match="node()|@*">
38 <xsl:apply-templates/>
39</xsl:template>
40
41
42<!-- Remove all remarks. -->
43<xsl:template match="remark"/>
44
45<!--
46Output header and footer.
47-->
48<xsl:template match="/">
49 <xsl:if test="$g_sMode = 'first'">
50 <xsl:text>&lt;?xml version="1.0"?&gt;
51&lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" &gt;
52&lt;xsl:output method="xml" version="1.0" encoding="utf-8" indent="yes" /&gt;
53&lt;xsl:template match="node()|@*"&gt;
54 &lt;xsl:copy&gt;
55 &lt;xsl:apply-templates select="node()|@*"/&gt;
56 &lt;/xsl:copy&gt;
57&lt;/xsl:template&gt;
58
59</xsl:text>
60 </xsl:if>
61 <xsl:apply-templates/>
62 <xsl:if test="$g_sMode = 'last'">
63 <xsl:text>
64&lt;/xsl:stylesheet&gt;
65</xsl:text>
66 </xsl:if>
67</xsl:template>
68
69
70<!--
71Produce the transformation templates:
72-->
73<xsl:template match="chapter[@id]/title">
74 <xsl:text>
75&lt;xsl:template match="xref[@linkend='</xsl:text>
76 <xsl:value-of select="../@id"/><xsl:text>']"&gt;
77 &lt;xsl:text&gt;</xsl:text><xsl:value-of select="$sChapter"/><xsl:text> </xsl:text>
78 <xsl:value-of select="count(../preceding-sibling::chapter) + 1"/><xsl:text> &quot;</xsl:text>
79 <xsl:value-of select="normalize-space()"/>
80 <xsl:text>&quot; </xsl:text><xsl:value-of select="$sInManual"/><xsl:text>&lt;/xsl:text&gt;
81&lt;/xsl:template&gt;
82</xsl:text>
83 <xsl:apply-templates/>
84</xsl:template>
85
86<xsl:template match="sect1[@id]/title">
87 <xsl:text>&lt;xsl:template match="xref[@linkend='</xsl:text>
88 <xsl:value-of select="../@id"/><xsl:text>']"&gt;
89 &lt;xsl:text&gt;</xsl:text><xsl:value-of select="$sSection"/><xsl:text> </xsl:text>
90 <xsl:value-of select="count(../../preceding-sibling::chapter) + 1"/><xsl:text>.</xsl:text>
91 <xsl:value-of select="count(../preceding-sibling::sect1) + 1"/>
92 <xsl:text> &quot;</xsl:text>
93 <xsl:value-of select="normalize-space()"/><xsl:text>&quot; </xsl:text>
94 <xsl:value-of select="$sOfManual"/><xsl:text>&lt;/xsl:text&gt;
95&lt;/xsl:template&gt;
96</xsl:text>
97 <xsl:apply-templates/>
98</xsl:template>
99
100<xsl:template match="sect2[@id]/title">
101 <xsl:text>&lt;xsl:template match="xref[@linkend='</xsl:text>
102 <xsl:value-of select="../@id"/><xsl:text>']"&gt;
103 &lt;xsl:text&gt;</xsl:text><xsl:value-of select="$sSection"/><xsl:text> </xsl:text>
104 <xsl:value-of select="count(../../../preceding-sibling::chapter) + 1"/><xsl:text>.</xsl:text>
105 <xsl:value-of select="count(../../preceding-sibling::sect1) + 1"/><xsl:text>.</xsl:text>
106 <xsl:value-of select="count(../preceding-sibling::sect2) + 1"/>
107 <xsl:text> &quot;</xsl:text>
108 <xsl:value-of select="normalize-space()"/><xsl:text>&quot; </xsl:text>
109 <xsl:value-of select="$sOfManual"/><xsl:text>&lt;/xsl:text&gt;
110&lt;/xsl:template&gt;
111</xsl:text>
112 <xsl:apply-templates/>
113</xsl:template>
114
115<xsl:template match="sect3[@id]/title">
116 <xsl:text>&lt;xsl:template match="xref[@linkend='</xsl:text>
117 <xsl:value-of select="../@id"/><xsl:text>']"&gt;
118 &lt;xsl:text&gt;</xsl:text><xsl:value-of select="$sSection"/><xsl:text> </xsl:text>
119 <xsl:value-of select="count(../../../../preceding-sibling::chapter) + 1"/><xsl:text>.</xsl:text>
120 <xsl:value-of select="count(../../../preceding-sibling::sect1) + 1"/><xsl:text>.</xsl:text>
121 <xsl:value-of select="count(../../preceding-sibling::sect2) + 1"/><xsl:text>.</xsl:text>
122 <xsl:value-of select="count(../preceding-sibling::sect3) + 1"/>
123 <xsl:text> &quot;</xsl:text>
124 <xsl:value-of select="normalize-space()"/><xsl:text>&quot; </xsl:text>
125 <xsl:value-of select="$sOfManual"/><xsl:text>&lt;/xsl:text&gt;
126&lt;/xsl:template&gt;
127</xsl:text>
128 <xsl:apply-templates/>
129</xsl:template>
130
131<xsl:template match="preface[@id]/title">
132 <xsl:text>&lt;xsl:template match="xref[@linkend='</xsl:text>
133 <xsl:value-of select="../@id"/><xsl:text>']"&gt;
134 &lt;xsl:text&gt;&quot;</xsl:text>
135 <xsl:value-of select="normalize-space()"/><xsl:text>&quot; </xsl:text>
136 <xsl:value-of select="$sOfManual"/><xsl:text>&lt;/xsl:text&gt;
137&lt;/xsl:template&gt;
138</xsl:text>
139 <xsl:apply-templates/>
140</xsl:template>
141
142<xsl:template match="refentry[@id]/refentryinfo/title">
143 <xsl:text>&lt;xsl:template match="xref[@linkend='</xsl:text>
144 <xsl:value-of select="../../@id"/><xsl:text>']"&gt;
145 &lt;xsl:text&gt; &quot;</xsl:text>
146 <xsl:value-of select="normalize-space()"/><xsl:text>&quot;&lt;/xsl:text&gt;
147&lt;/xsl:template&gt;
148</xsl:text>
149 <xsl:apply-templates/>
150</xsl:template>
151
152<xsl:template match="refsect2[@id]/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
163<!--
164 Debug/Diagnostics: Return the path to the specified node (by default the current).
165 -->
166<xsl:template name="get-node-path">
167 <xsl:param name="Node" select="."/>
168 <xsl:for-each select="$Node">
169 <xsl:for-each select="ancestor-or-self::node()">
170 <xsl:choose>
171 <xsl:when test="name(.) = ''">
172 <xsl:text>text()</xsl:text>
173 </xsl:when>
174 <xsl:otherwise>
175 <xsl:value-of select="concat('/', name(.))"/>
176 <xsl:choose>
177 <xsl:when test="@id">
178 <xsl:text>[@id=</xsl:text>
179 <xsl:value-of select="@id"/>
180 <xsl:text>]</xsl:text>
181 </xsl:when>
182 <xsl:when test="position() > 1">
183 <xsl:text>[</xsl:text><xsl:value-of select="position()"/><xsl:text>]</xsl:text>
184 </xsl:when>
185 </xsl:choose>
186 </xsl:otherwise>
187 </xsl:choose>
188 </xsl:for-each>
189 </xsl:for-each>
190</xsl:template>
191
192</xsl:stylesheet>
193
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