VirtualBox

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

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

doc/manual: Unify translation file handling for the manpage link replacement generation.

  • 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 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<xsl:template match="refsect2[@id]/title">
152 <xsl:text>&lt;xsl:template match="xref[@linkend='</xsl:text>
153 <xsl:value-of select="../@id"/><xsl:text>']"&gt;
154 &lt;xsl:text&gt;&quot;</xsl:text>
155 <xsl:value-of select="normalize-space()"/><xsl:text>&quot;&lt;/xsl:text&gt;
156&lt;/xsl:template&gt;
157</xsl:text>
158 <xsl:apply-templates/>
159</xsl:template>
160
161
162<!--
163 Debug/Diagnostics: Return the path to the specified node (by default the current).
164 -->
165<xsl:template name="get-node-path">
166 <xsl:param name="Node" select="."/>
167 <xsl:for-each select="$Node">
168 <xsl:for-each select="ancestor-or-self::node()">
169 <xsl:choose>
170 <xsl:when test="name(.) = ''">
171 <xsl:text>text()</xsl:text>
172 </xsl:when>
173 <xsl:otherwise>
174 <xsl:value-of select="concat('/', name(.))"/>
175 <xsl:choose>
176 <xsl:when test="@id">
177 <xsl:text>[@id=</xsl:text>
178 <xsl:value-of select="@id"/>
179 <xsl:text>]</xsl:text>
180 </xsl:when>
181 <xsl:when test="position() > 1">
182 <xsl:text>[</xsl:text><xsl:value-of select="position()"/><xsl:text>]</xsl:text>
183 </xsl:when>
184 </xsl:choose>
185 </xsl:otherwise>
186 </xsl:choose>
187 </xsl:for-each>
188 </xsl:for-each>
189</xsl:template>
190
191</xsl:stylesheet>
192
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