VirtualBox

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

Last change on this file since 92824 was 92824, checked in by vboxsync, 3 years ago

Main: bugref:1909: Added handling built-in docbook help for languages other than en_US in the VBoxManage

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