VirtualBox

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

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

doc/manual: Fixed dangling links in refentries to other refentries, causing xmllint to barf and VBoxManage build to fail.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.8 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<!-- Default operation is to supress output -->
29<xsl:template match="node()|@*">
30 <xsl:apply-templates/>
31</xsl:template>
32
33
34<!-- Remove all remarks. -->
35<xsl:template match="remark"/>
36
37<!--
38Output header and footer.
39-->
40<xsl:template match="/">
41 <xsl:if test="$g_sMode = 'first'">
42 <xsl:text>&lt;?xml version="1.0"?&gt;
43&lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" &gt;
44&lt;xsl:output method="xml" version="1.0" encoding="utf-8" indent="yes" /&gt;
45&lt;xsl:template match="node()|@*"&gt;
46 &lt;xsl:copy&gt;
47 &lt;xsl:apply-templates select="node()|@*"/&gt;
48 &lt;/xsl:copy&gt;
49&lt;/xsl:template&gt;
50
51</xsl:text>
52 </xsl:if>
53 <xsl:apply-templates/>
54 <xsl:if test="$g_sMode = 'last'">
55 <xsl:text>
56&lt;/xsl:stylesheet&gt;
57</xsl:text>
58 </xsl:if>
59</xsl:template>
60
61
62<!--
63Produce the transformation templates:
64-->
65<xsl:template match="chapter[@id]/title">
66 <xsl:text>
67&lt;xsl:template match="xref[@linkend='</xsl:text>
68 <xsl:value-of select="../@id"/><xsl:text>']"&gt;
69 &lt;xsl:text&gt;chapter </xsl:text><xsl:value-of select="count(../preceding-sibling::chapter) + 1"/><xsl:text> &quot;</xsl:text>
70 <xsl:value-of select="normalize-space()"/>
71 <xsl:text>&quot; in the user manual&lt;/xsl:text&gt;
72&lt;/xsl:template&gt;
73</xsl:text>
74 <xsl:apply-templates/>
75</xsl:template>
76
77<xsl:template match="sect1[@id]/title">
78 <xsl:text>&lt;xsl:template match="xref[@linkend='</xsl:text>
79 <xsl:value-of select="../@id"/><xsl:text>']"&gt;
80 &lt;xsl:text&gt;section </xsl:text>
81 <xsl:value-of select="count(../../preceding-sibling::chapter) + 1"/><xsl:text>.</xsl:text>
82 <xsl:value-of select="count(../preceding-sibling::sect1) + 1"/>
83 <xsl:text> &quot;</xsl:text>
84 <xsl:value-of select="normalize-space()"/><xsl:text>&quot; of the user manual&lt;/xsl:text&gt;
85&lt;/xsl:template&gt;
86</xsl:text>
87 <xsl:apply-templates/>
88</xsl:template>
89
90<xsl:template match="sect2[@id]/title">
91 <xsl:text>&lt;xsl:template match="xref[@linkend='</xsl:text>
92 <xsl:value-of select="../@id"/><xsl:text>']"&gt;
93 &lt;xsl:text&gt;section </xsl:text>
94 <xsl:value-of select="count(../../../preceding-sibling::chapter) + 1"/><xsl:text>.</xsl:text>
95 <xsl:value-of select="count(../../preceding-sibling::sect1) + 1"/><xsl:text>.</xsl:text>
96 <xsl:value-of select="count(../preceding-sibling::sect2) + 1"/>
97 <xsl:text> &quot;</xsl:text>
98 <xsl:value-of select="normalize-space()"/><xsl:text>&quot; of the user manual&lt;/xsl:text&gt;
99&lt;/xsl:template&gt;
100</xsl:text>
101 <xsl:apply-templates/>
102</xsl:template>
103
104<xsl:template match="sect3[@id]/title">
105 <xsl:text>&lt;xsl:template match="xref[@linkend='</xsl:text>
106 <xsl:value-of select="../@id"/><xsl:text>']"&gt;
107 &lt;xsl:text&gt;section </xsl:text>
108 <xsl:value-of select="count(../../../../preceding-sibling::chapter) + 1"/><xsl:text>.</xsl:text>
109 <xsl:value-of select="count(../../../preceding-sibling::sect1) + 1"/><xsl:text>.</xsl:text>
110 <xsl:value-of select="count(../../preceding-sibling::sect2) + 1"/><xsl:text>.</xsl:text>
111 <xsl:value-of select="count(../preceding-sibling::sect3) + 1"/>
112 <xsl:text> &quot;</xsl:text>
113 <xsl:value-of select="normalize-space()"/><xsl:text>&quot; of the user manual&lt;/xsl:text&gt;
114&lt;/xsl:template&gt;
115</xsl:text>
116 <xsl:apply-templates/>
117</xsl:template>
118
119<xsl:template match="preface[@id]/title">
120 <xsl:text>&lt;xsl:template match="xref[@linkend='</xsl:text>
121 <xsl:value-of select="../@id"/><xsl:text>']"&gt;
122 &lt;xsl:text&gt;&quot;</xsl:text>
123 <xsl:value-of select="normalize-space()"/><xsl:text>&quot; of the user manual&lt;/xsl:text&gt;
124&lt;/xsl:template&gt;
125</xsl:text>
126 <xsl:apply-templates/>
127</xsl:template>
128
129<xsl:template match="refentry[@id]/refentryinfo/title">
130 <xsl:text>&lt;xsl:template match="xref[@linkend='</xsl:text>
131 <xsl:value-of select="../../@id"/><xsl:text>']"&gt;
132 &lt;xsl:text&gt; &quot;</xsl:text>
133 <xsl:value-of select="normalize-space()"/><xsl:text>&quot;&lt;/xsl:text&gt;
134&lt;/xsl:template&gt;
135</xsl:text>
136 <xsl:apply-templates/>
137</xsl:template>
138
139
140<!--
141 Debug/Diagnostics: Return the path to the specified node (by default the current).
142 -->
143<xsl:template name="get-node-path">
144 <xsl:param name="Node" select="."/>
145 <xsl:for-each select="$Node">
146 <xsl:for-each select="ancestor-or-self::node()">
147 <xsl:choose>
148 <xsl:when test="name(.) = ''">
149 <xsl:text>text()</xsl:text>
150 </xsl:when>
151 <xsl:otherwise>
152 <xsl:value-of select="concat('/', name(.))"/>
153 <xsl:choose>
154 <xsl:when test="@id">
155 <xsl:text>[@id=</xsl:text>
156 <xsl:value-of select="@id"/>
157 <xsl:text>]</xsl:text>
158 </xsl:when>
159 <xsl:when test="position() > 1">
160 <xsl:text>[</xsl:text><xsl:value-of select="position()"/><xsl:text>]</xsl:text>
161 </xsl:when>
162 </xsl:choose>
163 </xsl:otherwise>
164 </xsl:choose>
165 </xsl:for-each>
166 </xsl:for-each>
167</xsl:template>
168
169</xsl:stylesheet>
170
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