[77354] | 1 | <?xml version="1.0"?>
|
---|
| 2 | <!--
|
---|
[93801] | 3 | docbook-refentry-link-replacement-xsl-gen.xsl:
|
---|
[77354] | 4 | XSLT stylesheet for generate a stylesheet that replaces links
|
---|
| 5 | to the user manual in the manpages.
|
---|
[96300] | 6 | -->
|
---|
| 7 | <!--
|
---|
[98103] | 8 | Copyright (C) 2006-2023 Oracle and/or its affiliates.
|
---|
[77354] | 9 |
|
---|
[96407] | 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
|
---|
[77354] | 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 |
|
---|
[92084] | 37 | <xsl:param name="g_sMode" select="not-specified"/>
|
---|
[77354] | 38 |
|
---|
[92824] | 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 |
|
---|
[77354] | 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 | <!--
|
---|
| 56 | Output header and footer.
|
---|
| 57 | -->
|
---|
| 58 | <xsl:template match="/">
|
---|
[92084] | 59 | <xsl:if test="$g_sMode = 'first'">
|
---|
| 60 | <xsl:text><?xml version="1.0"?>
|
---|
[77354] | 61 | <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
|
---|
| 62 | <xsl:output method="xml" version="1.0" encoding="utf-8" indent="yes" />
|
---|
| 63 | <xsl:template match="node()|@*">
|
---|
| 64 | <xsl:copy>
|
---|
| 65 | <xsl:apply-templates select="node()|@*"/>
|
---|
| 66 | </xsl:copy>
|
---|
| 67 | </xsl:template>
|
---|
| 68 |
|
---|
| 69 | </xsl:text>
|
---|
[92084] | 70 | </xsl:if>
|
---|
[77354] | 71 | <xsl:apply-templates/>
|
---|
[92084] | 72 | <xsl:if test="$g_sMode = 'last'">
|
---|
| 73 | <xsl:text>
|
---|
[77354] | 74 | </xsl:stylesheet>
|
---|
| 75 | </xsl:text>
|
---|
[92084] | 76 | </xsl:if>
|
---|
[77354] | 77 | </xsl:template>
|
---|
| 78 |
|
---|
| 79 |
|
---|
| 80 | <!--
|
---|
| 81 | Produce the transformation templates:
|
---|
| 82 | -->
|
---|
| 83 | <xsl:template match="chapter[@id]/title">
|
---|
| 84 | <xsl:text>
|
---|
| 85 | <xsl:template match="xref[@linkend='</xsl:text>
|
---|
| 86 | <xsl:value-of select="../@id"/><xsl:text>']">
|
---|
[92824] | 87 | <xsl:text></xsl:text><xsl:value-of select="$sChapter"/><xsl:text> </xsl:text>
|
---|
| 88 | <xsl:value-of select="count(../preceding-sibling::chapter) + 1"/><xsl:text> "</xsl:text>
|
---|
[77354] | 89 | <xsl:value-of select="normalize-space()"/>
|
---|
[92824] | 90 | <xsl:text>" </xsl:text><xsl:value-of select="$sInManual"/><xsl:text></xsl:text>
|
---|
[77354] | 91 | </xsl:template>
|
---|
| 92 | </xsl:text>
|
---|
| 93 | <xsl:apply-templates/>
|
---|
| 94 | </xsl:template>
|
---|
| 95 |
|
---|
| 96 | <xsl:template match="sect1[@id]/title">
|
---|
| 97 | <xsl:text><xsl:template match="xref[@linkend='</xsl:text>
|
---|
| 98 | <xsl:value-of select="../@id"/><xsl:text>']">
|
---|
[92824] | 99 | <xsl:text></xsl:text><xsl:value-of select="$sSection"/><xsl:text> </xsl:text>
|
---|
[77354] | 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> "</xsl:text>
|
---|
[92824] | 103 | <xsl:value-of select="normalize-space()"/><xsl:text>" </xsl:text>
|
---|
| 104 | <xsl:value-of select="$sOfManual"/><xsl:text></xsl:text>
|
---|
[77354] | 105 | </xsl:template>
|
---|
| 106 | </xsl:text>
|
---|
| 107 | <xsl:apply-templates/>
|
---|
| 108 | </xsl:template>
|
---|
| 109 |
|
---|
| 110 | <xsl:template match="sect2[@id]/title">
|
---|
| 111 | <xsl:text><xsl:template match="xref[@linkend='</xsl:text>
|
---|
| 112 | <xsl:value-of select="../@id"/><xsl:text>']">
|
---|
[92824] | 113 | <xsl:text></xsl:text><xsl:value-of select="$sSection"/><xsl:text> </xsl:text>
|
---|
[77354] | 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> "</xsl:text>
|
---|
[92824] | 118 | <xsl:value-of select="normalize-space()"/><xsl:text>" </xsl:text>
|
---|
| 119 | <xsl:value-of select="$sOfManual"/><xsl:text></xsl:text>
|
---|
[77354] | 120 | </xsl:template>
|
---|
| 121 | </xsl:text>
|
---|
| 122 | <xsl:apply-templates/>
|
---|
| 123 | </xsl:template>
|
---|
| 124 |
|
---|
| 125 | <xsl:template match="sect3[@id]/title">
|
---|
| 126 | <xsl:text><xsl:template match="xref[@linkend='</xsl:text>
|
---|
| 127 | <xsl:value-of select="../@id"/><xsl:text>']">
|
---|
[92824] | 128 | <xsl:text></xsl:text><xsl:value-of select="$sSection"/><xsl:text> </xsl:text>
|
---|
[77354] | 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> "</xsl:text>
|
---|
[92824] | 134 | <xsl:value-of select="normalize-space()"/><xsl:text>" </xsl:text>
|
---|
| 135 | <xsl:value-of select="$sOfManual"/><xsl:text></xsl:text>
|
---|
[77354] | 136 | </xsl:template>
|
---|
| 137 | </xsl:text>
|
---|
| 138 | <xsl:apply-templates/>
|
---|
| 139 | </xsl:template>
|
---|
| 140 |
|
---|
| 141 | <xsl:template match="preface[@id]/title">
|
---|
| 142 | <xsl:text><xsl:template match="xref[@linkend='</xsl:text>
|
---|
| 143 | <xsl:value-of select="../@id"/><xsl:text>']">
|
---|
| 144 | <xsl:text>"</xsl:text>
|
---|
[92824] | 145 | <xsl:value-of select="normalize-space()"/><xsl:text>" </xsl:text>
|
---|
| 146 | <xsl:value-of select="$sOfManual"/><xsl:text></xsl:text>
|
---|
[77354] | 147 | </xsl:template>
|
---|
| 148 | </xsl:text>
|
---|
| 149 | <xsl:apply-templates/>
|
---|
| 150 | </xsl:template>
|
---|
| 151 |
|
---|
[92084] | 152 | <xsl:template match="refentry[@id]/refentryinfo/title">
|
---|
| 153 | <xsl:text><xsl:template match="xref[@linkend='</xsl:text>
|
---|
| 154 | <xsl:value-of select="../../@id"/><xsl:text>']">
|
---|
| 155 | <xsl:text> "</xsl:text>
|
---|
| 156 | <xsl:value-of select="normalize-space()"/><xsl:text>"</xsl:text>
|
---|
| 157 | </xsl:template>
|
---|
| 158 | </xsl:text>
|
---|
| 159 | <xsl:apply-templates/>
|
---|
| 160 | </xsl:template>
|
---|
| 161 |
|
---|
[93801] | 162 | <xsl:template match="refsect2[@id]/title">
|
---|
| 163 | <xsl:text><xsl:template match="xref[@linkend='</xsl:text>
|
---|
| 164 | <xsl:value-of select="../@id"/><xsl:text>']">
|
---|
| 165 | <xsl:text>"</xsl:text>
|
---|
| 166 | <xsl:value-of select="normalize-space()"/><xsl:text>"</xsl:text>
|
---|
| 167 | </xsl:template>
|
---|
| 168 | </xsl:text>
|
---|
| 169 | <xsl:apply-templates/>
|
---|
| 170 | </xsl:template>
|
---|
[92084] | 171 |
|
---|
[93801] | 172 |
|
---|
[77354] | 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 |
|
---|