[56192] | 1 | <?xml version="1.0"?>
|
---|
| 2 | <!--
|
---|
| 3 | docbook-refentry-to-manual-sect1.xsl:
|
---|
| 4 | XSLT stylesheet for nicking the refsynopsisdiv bit of a
|
---|
| 5 | refentry (manpage) for use in the command overview section
|
---|
| 6 | in the user manual.
|
---|
[96300] | 7 | -->
|
---|
| 8 | <!--
|
---|
[98103] | 9 | Copyright (C) 2006-2023 Oracle and/or its affiliates.
|
---|
[56192] | 10 |
|
---|
[96407] | 11 | This file is part of VirtualBox base platform packages, as
|
---|
| 12 | available from https://www.virtualbox.org.
|
---|
| 13 |
|
---|
| 14 | This program is free software; you can redistribute it and/or
|
---|
| 15 | modify it under the terms of the GNU General Public License
|
---|
| 16 | as published by the Free Software Foundation, in version 3 of the
|
---|
| 17 | License.
|
---|
| 18 |
|
---|
| 19 | This program is distributed in the hope that it will be useful, but
|
---|
| 20 | WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 21 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
| 22 | General Public License for more details.
|
---|
| 23 |
|
---|
| 24 | You should have received a copy of the GNU General Public License
|
---|
| 25 | along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
| 26 |
|
---|
| 27 | SPDX-License-Identifier: GPL-3.0-only
|
---|
[56192] | 28 | -->
|
---|
| 29 |
|
---|
| 30 | <xsl:stylesheet
|
---|
| 31 | version="1.0"
|
---|
| 32 | xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
---|
[56208] | 33 | xmlns:str="http://xsltsl.org/string"
|
---|
[56192] | 34 | >
|
---|
| 35 |
|
---|
[73276] | 36 | <xsl:import href="string.xsl"/>
|
---|
| 37 | <xsl:import href="common-formatcfg.xsl"/>
|
---|
[56208] | 38 |
|
---|
| 39 | <xsl:output method="text" version="1.0" encoding="utf-8" indent="yes"/>
|
---|
[56192] | 40 | <xsl:strip-space elements="*"/>
|
---|
| 41 |
|
---|
[56568] | 42 | <xsl:param name="g_fDebugText" select="0"/>
|
---|
| 43 |
|
---|
[56565] | 44 | <xsl:variable name="g_sUnderlineRefSect1">
|
---|
| 45 | <xsl:text>===================================================================================================================</xsl:text>
|
---|
| 46 | </xsl:variable>
|
---|
| 47 | <xsl:variable name="g_sUnderlineRefSect2">
|
---|
| 48 | <xsl:text>-------------------------------------------------------------------------------------------------------------------</xsl:text>
|
---|
| 49 | </xsl:variable>
|
---|
[98098] | 50 | <xsl:variable name="g_sNewLine"><xsl:value-of select="' '" /></xsl:variable>
|
---|
[56192] | 51 |
|
---|
[77882] | 52 | <!-- Sub-command style command (true) or single command (false). -->
|
---|
| 53 | <xsl:variable name="g_fSubCommands" select="not(not(//refsect2[@id]))" />
|
---|
[56565] | 54 |
|
---|
[92824] | 55 | <!-- Translatable strings -->
|
---|
| 56 | <xsl:variable name="sUsage" select="'Usage'"/>
|
---|
| 57 | <xsl:variable name="sUsageUnderscore" select="'====='"/>
|
---|
| 58 |
|
---|
| 59 |
|
---|
[56208] | 60 | <!-- Default action, do nothing. -->
|
---|
| 61 | <xsl:template match="node()|@*"/>
|
---|
[56192] | 62 |
|
---|
[56208] | 63 | <!--
|
---|
| 64 | main() - because we need to order the output in a specific manner
|
---|
| 65 | that is contrary to the data flow in the refentry, this is
|
---|
| 66 | going to look a bit more like a C program than a stylesheet.
|
---|
| 67 | -->
|
---|
| 68 | <xsl:template match="refentry">
|
---|
| 69 | <!-- Assert refetry expectations. -->
|
---|
[56466] | 70 | <xsl:if test="not(./refsynopsisdiv)">
|
---|
[68872] | 71 | <xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>refentry must have a refsynopsisdiv</xsl:message>
|
---|
[56466] | 72 | </xsl:if>
|
---|
| 73 | <xsl:if test="not(./refentryinfo/title)">
|
---|
[68872] | 74 | <xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>refentry must have a refentryinfo with title</xsl:message>
|
---|
[56466] | 75 | </xsl:if>
|
---|
| 76 | <xsl:if test="not(./refmeta/refentrytitle)">
|
---|
[68872] | 77 | <xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>refentry must have a refentryinfo with title</xsl:message>
|
---|
[56466] | 78 | </xsl:if>
|
---|
| 79 | <xsl:if test="./refmeta/refentrytitle != ./refnamediv/refname">
|
---|
[68872] | 80 | <xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>The refmeta/refentrytitle and the refnamediv/refname must be identical</xsl:message>
|
---|
[56466] | 81 | </xsl:if>
|
---|
| 82 | <xsl:if test="not(./refsect1/title)">
|
---|
[68872] | 83 | <xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>refentry must have a refsect1 with title</xsl:message>
|
---|
[56466] | 84 | </xsl:if>
|
---|
| 85 | <xsl:if test="not(@id) or @id = ''">
|
---|
[68872] | 86 | <xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>refentry must have an id attribute</xsl:message>
|
---|
[56466] | 87 | </xsl:if>
|
---|
[56192] | 88 |
|
---|
[56208] | 89 | <!-- variables -->
|
---|
| 90 | <xsl:variable name="sBaseId" select="@id"/>
|
---|
| 91 | <xsl:variable name="sDataBaseSym" select="concat('g_', translate(@id, '-', '_'))"/>
|
---|
[56192] | 92 |
|
---|
[56231] | 93 |
|
---|
[56208] | 94 | <!--
|
---|
| 95 | Convert the refsynopsisdiv into REFENTRY::Synopsis data.
|
---|
| 96 | -->
|
---|
| 97 | <xsl:text>
|
---|
[56192] | 98 |
|
---|
[68860] | 99 | static const RTMSGREFENTRYSTR </xsl:text><xsl:value-of select="$sDataBaseSym"/><xsl:text>_synopsis[] =
|
---|
[56208] | 100 | {</xsl:text>
|
---|
| 101 | <xsl:for-each select="./refsynopsisdiv/cmdsynopsis">
|
---|
| 102 | <!-- Assert synopsis expectations -->
|
---|
| 103 | <xsl:if test="not(@id) or substring-before(@id, '-') != 'synopsis'">
|
---|
[68872] | 104 | <xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>The refsynopsisdiv/cmdsynopsis elements must have an id starting with 'synopsis-'.</xsl:message>
|
---|
[56208] | 105 | </xsl:if>
|
---|
[56344] | 106 | <xsl:if test="not(starts-with(substring-after(@id, '-'), $sBaseId))">
|
---|
[68872] | 107 | <xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>The refsynopsisdiv/cmdsynopsis elements @id is expected to include the refentry @id.</xsl:message>
|
---|
[56344] | 108 | </xsl:if>
|
---|
[77882] | 109 | <xsl:if test="not(../../refsect1/refsect2[@id=./@id]) and $g_fSubCommands">
|
---|
[68872] | 110 | <xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>No refsect2 with id="<xsl:value-of select="@id"/>" found.</xsl:message>
|
---|
[56208] | 111 | </xsl:if>
|
---|
| 112 |
|
---|
| 113 | <!-- Do the work. -->
|
---|
[56231] | 114 | <xsl:apply-templates select="."/>
|
---|
| 115 |
|
---|
| 116 | </xsl:for-each>
|
---|
| 117 | <xsl:text>
|
---|
| 118 | };</xsl:text>
|
---|
| 119 |
|
---|
| 120 |
|
---|
| 121 | <!--
|
---|
| 122 | Convert the whole manpage to help text.
|
---|
| 123 | -->
|
---|
| 124 | <xsl:text>
|
---|
[68860] | 125 | static const RTMSGREFENTRYSTR </xsl:text><xsl:value-of select="$sDataBaseSym"/><xsl:text>_full_help[] =
|
---|
[56231] | 126 | {</xsl:text>
|
---|
| 127 | <!-- We start by combining the refentry title and the refpurpose into a short description. -->
|
---|
| 128 | <xsl:text>
|
---|
[56344] | 129 | { </xsl:text><xsl:call-template name="calc-scope-for-refentry"/><xsl:text>,
|
---|
[56208] | 130 | "</xsl:text>
|
---|
[56231] | 131 | <xsl:apply-templates select="./refentryinfo/title/node()"/>
|
---|
| 132 | <xsl:text> -- </xsl:text>
|
---|
| 133 | <xsl:call-template name="capitalize">
|
---|
| 134 | <xsl:with-param name="text">
|
---|
| 135 | <xsl:apply-templates select="./refnamediv/refpurpose/node()"/>
|
---|
| 136 | </xsl:with-param>
|
---|
| 137 | </xsl:call-template>
|
---|
| 138 | <xsl:text>." },
|
---|
[68860] | 139 | { RTMSGREFENTRYSTR_SCOPE_SAME, "" },</xsl:text>
|
---|
[56231] | 140 |
|
---|
| 141 | <!-- The follows the usage (synopsis) section. -->
|
---|
| 142 | <xsl:text>
|
---|
[68860] | 143 | { RTMSGREFENTRYSTR_SCOPE_GLOBAL,
|
---|
[92824] | 144 | "</xsl:text><xsl:value-of select="$sUsage"/><xsl:text>" },
|
---|
[68860] | 145 | { RTMSGREFENTRYSTR_SCOPE_SAME,
|
---|
[92824] | 146 | "</xsl:text><xsl:value-of select="$sUsageUnderscore"/><xsl:text>" },</xsl:text>
|
---|
[56231] | 147 | <xsl:apply-templates select="./refsynopsisdiv/node()"/>
|
---|
| 148 |
|
---|
| 149 | <!-- Then comes the description and other refsect1 -->
|
---|
| 150 | <xsl:for-each select="./refsect1">
|
---|
[99513] | 151 | <!-- assertions -->
|
---|
[68872] | 152 | <xsl:if test="name(*[1]) != 'title'"><xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>Expected title as the first element in refsect1.</xsl:message></xsl:if>
|
---|
| 153 | <xsl:if test="text()"><xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>No text supported in refsect1.</xsl:message></xsl:if>
|
---|
[99513] | 154 | <xsl:if test="not(@id)"><xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>refsect1 must have an @id attribute.</xsl:message></xsl:if>
|
---|
| 155 | <xsl:if test="not(starts-with(@id, concat(../@id, '-')))"><xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>Wrong @id refsect1 prefix: '<xsl:value-of select="@id"/>', expected it to start with '<xsl:value-of select="../@id"/>-'</xsl:message></xsl:if>
|
---|
| 156 |
|
---|
| 157 | <!-- .... -->
|
---|
[56231] | 158 | <xsl:if test="not(./remark[@role='help-skip'])">
|
---|
[56565] | 159 | <xsl:variable name="sTitle">
|
---|
| 160 | <xsl:apply-templates select="./title/node()"/>
|
---|
| 161 | </xsl:variable>
|
---|
[56231] | 162 | <xsl:text>
|
---|
| 163 | { </xsl:text><xsl:call-template name="calc-scope-refsect1"/><xsl:text>, "" },
|
---|
[68860] | 164 | { RTMSGREFENTRYSTR_SCOPE_SAME,
|
---|
[56565] | 165 | "</xsl:text><xsl:value-of select="$sTitle"/><xsl:text>" },
|
---|
[68860] | 166 | { RTMSGREFENTRYSTR_SCOPE_SAME,
|
---|
[56565] | 167 | "</xsl:text>
|
---|
| 168 | <xsl:value-of select="substring($g_sUnderlineRefSect1, 1, string-length($sTitle))"/>
|
---|
| 169 | <xsl:text>" },</xsl:text>
|
---|
| 170 |
|
---|
| 171 | <xsl:apply-templates select="./*[name() != 'title']"/>
|
---|
[68872] | 172 |
|
---|
| 173 | <xsl:text>
|
---|
| 174 | { RTMSGREFENTRYSTR_SCOPE_SAME, "" },</xsl:text>
|
---|
[56231] | 175 | </xsl:if>
|
---|
[56208] | 176 | </xsl:for-each>
|
---|
[56231] | 177 |
|
---|
[56208] | 178 | <xsl:text>
|
---|
[56231] | 179 | };</xsl:text>
|
---|
| 180 |
|
---|
| 181 | <!--
|
---|
| 182 | Generate the refentry structure.
|
---|
| 183 | -->
|
---|
| 184 | <xsl:text>
|
---|
[68860] | 185 | static const RTMSGREFENTRY </xsl:text><xsl:value-of select="$sDataBaseSym"/><xsl:text> =
|
---|
[56231] | 186 | {
|
---|
[56344] | 187 | /* .idInternal = */ HELP_CMD_</xsl:text>
|
---|
[68860] | 188 | <xsl:choose>
|
---|
| 189 | <xsl:when test="contains(@id, '-')">
|
---|
| 190 | <xsl:call-template name="str:to-upper"> <!-- Multi level command. -->
|
---|
| 191 | <xsl:with-param name="text" select="translate(substring-after(@id, '-'), '-', '_')"/>
|
---|
| 192 | </xsl:call-template>
|
---|
| 193 | </xsl:when>
|
---|
| 194 | <xsl:otherwise>
|
---|
| 195 | <xsl:call-template name="str:to-upper"> <!-- Simple command. -->
|
---|
| 196 | <xsl:with-param name="text" select="@id"/>
|
---|
| 197 | </xsl:call-template>
|
---|
| 198 | </xsl:otherwise>
|
---|
| 199 | </xsl:choose>
|
---|
[56231] | 200 | <xsl:text>,
|
---|
[56344] | 201 | /* .Synopsis = */ { RT_ELEMENTS(</xsl:text>
|
---|
| 202 | <xsl:value-of select="$sDataBaseSym"/><xsl:text>_synopsis), 0, </xsl:text>
|
---|
| 203 | <xsl:value-of select="$sDataBaseSym"/><xsl:text>_synopsis },
|
---|
| 204 | /* .Help = */ { RT_ELEMENTS(</xsl:text>
|
---|
| 205 | <xsl:value-of select="$sDataBaseSym"/><xsl:text>_full_help), 0, </xsl:text>
|
---|
| 206 | <xsl:value-of select="$sDataBaseSym"/><xsl:text>_full_help },
|
---|
[56231] | 207 | /* pszBrief = */ "</xsl:text>
|
---|
| 208 | <xsl:apply-templates select="./refnamediv/refpurpose/node()"/>
|
---|
[56344] | 209 | <!-- TODO: Add the command name too. -->
|
---|
[56231] | 210 | <xsl:text>"
|
---|
[56208] | 211 | };
|
---|
| 212 | </xsl:text>
|
---|
| 213 | </xsl:template>
|
---|
| 214 |
|
---|
| 215 |
|
---|
| 216 | <!--
|
---|
[56231] | 217 | Convert command synopsis to text.
|
---|
| 218 | -->
|
---|
| 219 | <xsl:template match="cmdsynopsis">
|
---|
[68872] | 220 | <xsl:if test="text()"><xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>cmdsynopsis with text is not supported.</xsl:message></xsl:if>
|
---|
[68873] | 221 | <xsl:if test="position() = 1">
|
---|
| 222 | <xsl:text>
|
---|
[91006] | 223 | { </xsl:text><xsl:call-template name="calc-scope-cmdsynopsis"/><xsl:text> | RTMSGREFENTRYSTR_FLAGS_SYNOPSIS, "" },</xsl:text>
|
---|
[68873] | 224 | </xsl:if>
|
---|
[56231] | 225 | <xsl:text>
|
---|
[68860] | 226 | { </xsl:text><xsl:call-template name="calc-scope-cmdsynopsis"/><xsl:text> | RTMSGREFENTRYSTR_FLAGS_SYNOPSIS,
|
---|
[56231] | 227 | "</xsl:text><xsl:call-template name="emit-indentation"/><xsl:apply-templates select="*|@*"/><xsl:text>" },</xsl:text>
|
---|
| 228 | </xsl:template>
|
---|
| 229 |
|
---|
| 230 | <xsl:template match="sbr">
|
---|
| 231 | <xsl:text>" },
|
---|
[68860] | 232 | { RTMSGREFENTRYSTR_SCOPE_SAME | RTMSGREFENTRYSTR_FLAGS_SYNOPSIS,
|
---|
[56533] | 233 | " </xsl:text><xsl:call-template name="emit-indentation"/> <!-- hardcoded in VBoxManageHelp.cpp too -->
|
---|
[56231] | 234 | </xsl:template>
|
---|
| 235 |
|
---|
[56533] | 236 | <xsl:template match="cmdsynopsis/command">
|
---|
| 237 | <xsl:text>" },
|
---|
[68860] | 238 | { RTMSGREFENTRYSTR_SCOPE_SAME | RTMSGREFENTRYSTR_FLAGS_SYNOPSIS,
|
---|
[56533] | 239 | "</xsl:text><xsl:call-template name="emit-indentation"/>
|
---|
| 240 | <xsl:apply-templates select="node()|@*"/>
|
---|
| 241 | </xsl:template>
|
---|
| 242 |
|
---|
| 243 | <xsl:template match="cmdsynopsis/command[1]" priority="2">
|
---|
| 244 | <xsl:apply-templates select="node()|@*"/>
|
---|
| 245 | </xsl:template>
|
---|
| 246 |
|
---|
[93802] | 247 | <xsl:template match="command|option|computeroutput|literal|emphasis|filename|citetitle|note">
|
---|
[56231] | 248 | <xsl:apply-templates select="node()|@*"/>
|
---|
| 249 | </xsl:template>
|
---|
| 250 |
|
---|
[93802] | 251 | <xsl:template match="ulink">
|
---|
| 252 | <xsl:value-of select="@url"/>
|
---|
| 253 | </xsl:template>
|
---|
| 254 |
|
---|
[56231] | 255 | <xsl:template match="replaceable">
|
---|
[56565] | 256 | <xsl:choose>
|
---|
[68872] | 257 | <xsl:when test="ancestor::arg">
|
---|
[56565] | 258 | <xsl:apply-templates />
|
---|
| 259 | </xsl:when>
|
---|
| 260 | <xsl:otherwise>
|
---|
| 261 | <xsl:text><</xsl:text>
|
---|
| 262 | <xsl:apply-templates />
|
---|
| 263 | <xsl:text>></xsl:text>
|
---|
| 264 | </xsl:otherwise>
|
---|
| 265 | </xsl:choose>
|
---|
[56231] | 266 | </xsl:template>
|
---|
| 267 |
|
---|
[56565] | 268 | <!-- duplicated in docbook2latex.xsl -->
|
---|
[56231] | 269 | <xsl:template match="arg|group">
|
---|
| 270 | <!-- separator char if we're not the first child -->
|
---|
| 271 | <xsl:if test="position() > 1">
|
---|
[99116] | 272 | <!--<xsl:value-of select="concat('*',name(),'=', position(),'#')"/>-->
|
---|
[56231] | 273 | <xsl:choose>
|
---|
[99116] | 274 | <xsl:when test="parent::group and ancestor::*[@role='compact']"><xsl:value-of select="$arg.or.sep.compact"/></xsl:when>
|
---|
[56565] | 275 | <xsl:when test="parent::group"><xsl:value-of select="$arg.or.sep"/></xsl:when>
|
---|
[99118] | 276 | <xsl:when test="ancestor::*[@role='compact']"></xsl:when>
|
---|
[99116] | 277 | <xsl:when test="ancestor::*/@sepchar"><xsl:value-of select="ancestor::*/@sepchar"/></xsl:when>
|
---|
[56231] | 278 | <xsl:otherwise><xsl:text> </xsl:text></xsl:otherwise>
|
---|
| 279 | </xsl:choose>
|
---|
| 280 | </xsl:if>
|
---|
[77177] | 281 |
|
---|
[56231] | 282 | <!-- open wrapping -->
|
---|
[77177] | 283 | <xsl:variable name="fWrappers" select="not(ancestor::group)"/>
|
---|
| 284 | <xsl:if test="$fWrappers">
|
---|
| 285 | <xsl:choose>
|
---|
| 286 | <xsl:when test="not(@choice) or @choice = ''"> <xsl:value-of select="$arg.choice.def.open.str"/></xsl:when>
|
---|
| 287 | <xsl:when test="@choice = 'opt'"> <xsl:value-of select="$arg.choice.opt.open.str"/></xsl:when>
|
---|
| 288 | <xsl:when test="@choice = 'req'"> <xsl:value-of select="$arg.choice.req.open.str"/></xsl:when>
|
---|
| 289 | <xsl:when test="@choice = 'plain'"/>
|
---|
| 290 | <xsl:otherwise><xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>Invalid arg choice: "<xsl:value-of select="@choice"/>"</xsl:message></xsl:otherwise>
|
---|
| 291 | </xsl:choose>
|
---|
| 292 | </xsl:if>
|
---|
[56565] | 293 |
|
---|
[56231] | 294 | <!-- render the arg (TODO: may need to do more work here) -->
|
---|
[56565] | 295 | <xsl:apply-templates />
|
---|
| 296 |
|
---|
[56231] | 297 | <!-- repeat wrapping -->
|
---|
| 298 | <xsl:choose>
|
---|
| 299 | <xsl:when test="@rep = 'norepeat' or not(@rep) or @rep = ''"/>
|
---|
[79609] | 300 | <xsl:when test="@rep = 'repeat'"> <xsl:value-of select="$arg.rep.repeat.str"/></xsl:when>
|
---|
[68872] | 301 | <xsl:otherwise><xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>Invalid rep choice: "<xsl:value-of select="@rep"/>"</xsl:message></xsl:otherwise>
|
---|
[56231] | 302 | </xsl:choose>
|
---|
[77177] | 303 |
|
---|
[56231] | 304 | <!-- close wrapping -->
|
---|
[77177] | 305 | <xsl:if test="$fWrappers">
|
---|
| 306 | <xsl:choose>
|
---|
| 307 | <xsl:when test="not(@choice) or @choice = ''"> <xsl:value-of select="$arg.choice.def.close.str"/></xsl:when>
|
---|
| 308 | <xsl:when test="@choice = 'opt'"> <xsl:value-of select="$arg.choice.opt.close.str"/></xsl:when>
|
---|
| 309 | <xsl:when test="@choice = 'req'"> <xsl:value-of select="$arg.choice.req.close.str"/></xsl:when>
|
---|
| 310 | </xsl:choose>
|
---|
[99118] | 311 | <!-- Add a space padding if we're the last element in a repeating arg or group -->
|
---|
| 312 | <!-- 2023-03-22 bird: This is incorrectly written. Fix as needed...
|
---|
| 313 | <xsl:if test="(parent::arg or parent::group) and not(following-sibiling) and not(ancestor::*[@role='compact'])">
|
---|
| 314 | <xsl:text> </xsl:text>
|
---|
| 315 | </xsl:if>
|
---|
| 316 | -->
|
---|
[77177] | 317 | </xsl:if>
|
---|
[56231] | 318 | </xsl:template>
|
---|
| 319 |
|
---|
| 320 |
|
---|
| 321 | <!--
|
---|
| 322 | refsect2
|
---|
| 323 | -->
|
---|
| 324 | <xsl:template match="refsect2">
|
---|
| 325 | <!-- assertions -->
|
---|
[68872] | 326 | <xsl:if test="text()"><xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>refsect2 shouldn't contain text</xsl:message></xsl:if>
|
---|
| 327 | <xsl:if test="count(./title) != 1"><xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>refsect2 requires a title (<xsl:value-of select="ancestor-or-self::*[@id][1]/@id"/>)</xsl:message></xsl:if>
|
---|
[99513] | 328 | <xsl:if test="not(@id)"><xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>refsect2 must have an @id attribute.</xsl:message></xsl:if>
|
---|
| 329 | <xsl:if test="not(starts-with(@id, concat(../../@id, '-')))"><xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>Wrong @id refsect2 prefix: '<xsl:value-of select="@id"/>', expected it to start with '<xsl:value-of select="../../@id"/>-'</xsl:message></xsl:if>
|
---|
[56231] | 330 |
|
---|
| 331 | <!-- title / command synopsis - sets the scope. -->
|
---|
[56565] | 332 | <xsl:variable name="sTitle">
|
---|
| 333 | <xsl:apply-templates select="./title/text()"/>
|
---|
| 334 | </xsl:variable>
|
---|
[56231] | 335 | <xsl:text>
|
---|
[56344] | 336 | { </xsl:text><xsl:call-template name="calc-scope-refsect2"/><xsl:text>, "" },
|
---|
[68860] | 337 | { RTMSGREFENTRYSTR_SCOPE_SAME,
|
---|
[56231] | 338 | "</xsl:text><xsl:call-template name="emit-indentation"/>
|
---|
[56565] | 339 | <xsl:value-of select="$sTitle"/>
|
---|
| 340 | <xsl:text>" },
|
---|
[68860] | 341 | { RTMSGREFENTRYSTR_SCOPE_SAME,
|
---|
[56565] | 342 | "</xsl:text><xsl:call-template name="emit-indentation"/>
|
---|
| 343 | <xsl:value-of select="substring($g_sUnderlineRefSect2, 1, string-length($sTitle))"/>
|
---|
[68873] | 344 | <xsl:text>" },</xsl:text>
|
---|
[56231] | 345 |
|
---|
[68873] | 346 | <!-- <xsl:if test="./*[name() != 'title']/following::
|
---|
| 347 | { RTMSGREFENTRYSTR_SCOPE_SAME, "y" },</xsl:text> cmdsynopsis -->
|
---|
| 348 |
|
---|
[56231] | 349 | <!-- Format the text in the section -->
|
---|
[56466] | 350 | <xsl:for-each select="./*[name() != 'title']">
|
---|
[56533] | 351 | <xsl:apply-templates select="."/>
|
---|
[56466] | 352 | </xsl:for-each>
|
---|
[56231] | 353 |
|
---|
[56344] | 354 | <!-- Add two blank lines, unless we're the last element in this refsect1. -->
|
---|
[56231] | 355 | <xsl:if test="position() != last()">
|
---|
| 356 | <xsl:text>
|
---|
[68860] | 357 | { RTMSGREFENTRYSTR_SCOPE_SAME, "" },</xsl:text>
|
---|
[56231] | 358 | </xsl:if>
|
---|
| 359 | </xsl:template>
|
---|
| 360 |
|
---|
| 361 |
|
---|
| 362 | <!--
|
---|
| 363 | para
|
---|
| 364 | -->
|
---|
| 365 | <xsl:template match="para">
|
---|
| 366 | <xsl:if test="position() != 1 or not(parent::listitem)">
|
---|
| 367 | <xsl:text>
|
---|
[68860] | 368 | { RTMSGREFENTRYSTR_SCOPE_SAME, "" },</xsl:text>
|
---|
[56231] | 369 | </xsl:if>
|
---|
| 370 | <xsl:call-template name="process-mixed"/>
|
---|
| 371 | </xsl:template>
|
---|
| 372 |
|
---|
| 373 |
|
---|
| 374 | <!--
|
---|
| 375 | variablelist
|
---|
| 376 | -->
|
---|
| 377 | <xsl:template match="variablelist">
|
---|
| 378 | <xsl:if test="*[not(self::varlistentry)]|text()">
|
---|
[68872] | 379 | <xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>Only varlistentry elements are supported in variablelist </xsl:message>
|
---|
[56231] | 380 | </xsl:if>
|
---|
| 381 | <xsl:for-each select="./varlistentry">
|
---|
[68860] | 382 | <xsl:if test="not(term) or not(listitem) or count(listitem) > 1">
|
---|
[68872] | 383 | <xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>Expected one or more term members and exactly one listentry member in varlistentry element.</xsl:message>
|
---|
[56231] | 384 | </xsl:if>
|
---|
[68872] | 385 | <xsl:if test="(not(@spacing) or @spacing != 'compact') and (position() > 1 or (count(../preceding-sibling::*) - count(../preceding-sibling::title) > 0))">
|
---|
[56565] | 386 | <xsl:text>
|
---|
[68860] | 387 | { RTMSGREFENTRYSTR_SCOPE_SAME, "" },</xsl:text>
|
---|
[56565] | 388 | </xsl:if>
|
---|
[56231] | 389 | <xsl:apply-templates select="*"/>
|
---|
| 390 | </xsl:for-each>
|
---|
| 391 | </xsl:template>
|
---|
| 392 |
|
---|
| 393 | <xsl:template match="varlistentry/term">
|
---|
| 394 | <xsl:call-template name="process-mixed"/>
|
---|
| 395 | </xsl:template>
|
---|
| 396 |
|
---|
| 397 | <xsl:template match="varlistentry/listitem">
|
---|
[56586] | 398 | <xsl:call-template name="check-children">
|
---|
[94216] | 399 | <xsl:with-param name="UnsupportedNodes" select="*[not(self::para or self::itemizedlist or self::orderedlist or self::variablelist or self::note)]|text()"/>
|
---|
| 400 | <xsl:with-param name="SupportedNames">para, itemizedlist, orderedlist and note</xsl:with-param>
|
---|
[56586] | 401 | </xsl:call-template>
|
---|
[56570] | 402 |
|
---|
[56231] | 403 | <xsl:apply-templates select="*"/>
|
---|
| 404 | </xsl:template>
|
---|
| 405 |
|
---|
| 406 |
|
---|
| 407 | <!--
|
---|
[56568] | 408 | itemizedlist and orderedlist
|
---|
[56565] | 409 | -->
|
---|
[56568] | 410 | <xsl:template match="itemizedlist|orderedlist">
|
---|
[56565] | 411 | <xsl:if test="*[not(self::listitem)]|text()">
|
---|
[56571] | 412 | <xsl:message terminate="yes">
|
---|
[68872] | 413 | <xsl:call-template name="error-prefix"/>Only listitem elements are supported in <xsl:value-of select="name()"/>:
|
---|
[56571] | 414 | <xsl:call-template name="list-nodes">
|
---|
| 415 | <xsl:with-param name="Nodes" select="*[not(self::listitem)]|text()"/>
|
---|
| 416 | </xsl:call-template>
|
---|
| 417 | </xsl:message>
|
---|
[56565] | 418 | </xsl:if>
|
---|
| 419 | <xsl:if test="parent::para">
|
---|
[56568] | 420 | <xsl:message terminate="yes"><xsl:value-of select="name()"/> inside a para is current not supported. <!-- no newline
|
---|
[56565] | 421 | -->Close the para before the list, it makes no difference to html and latex/pdf output.</xsl:message>
|
---|
| 422 | </xsl:if>
|
---|
| 423 | <xsl:if test="position() != 1 and (not(@spacing) or @spacing != 'compact')">
|
---|
| 424 | <xsl:text>
|
---|
[68860] | 425 | { RTMSGREFENTRYSTR_SCOPE_SAME, "" },</xsl:text>
|
---|
[56565] | 426 | </xsl:if>
|
---|
| 427 | <xsl:for-each select="./listitem">
|
---|
| 428 | <xsl:apply-templates select="*"/>
|
---|
| 429 | </xsl:for-each>
|
---|
| 430 | </xsl:template>
|
---|
| 431 |
|
---|
[56568] | 432 | <xsl:template match="itemizedlist/listitem|orderedlist/listitem">
|
---|
[56571] | 433 | <xsl:if test="*[not(self::para)]|text()">
|
---|
| 434 | <xsl:message terminate="yes">
|
---|
[68872] | 435 | <xsl:call-template name="error-prefix"/>Expected <xsl:value-of select="name()"/>/listitem to only contain para elements:
|
---|
[56571] | 436 | <xsl:call-template name="list-nodes">
|
---|
| 437 | <xsl:with-param name="Nodes" select="*[not(self::para)]|text()"/>
|
---|
| 438 | </xsl:call-template>
|
---|
| 439 | </xsl:message>
|
---|
[56565] | 440 | </xsl:if>
|
---|
[56571] | 441 |
|
---|
[56565] | 442 | <xsl:if test="position() != 1 and @spaceing != 'compact'">
|
---|
| 443 | <xsl:text>
|
---|
[68860] | 444 | { RTMSGREFENTRYSTR_SCOPE_SAME, "" },</xsl:text>
|
---|
[56565] | 445 | </xsl:if>
|
---|
| 446 | <xsl:apply-templates select="*"/>
|
---|
| 447 | </xsl:template>
|
---|
| 448 |
|
---|
| 449 |
|
---|
| 450 | <!--
|
---|
[56367] | 451 | Screen
|
---|
| 452 | -->
|
---|
| 453 | <xsl:template match="screen">
|
---|
| 454 | <xsl:if test="ancestor::para">
|
---|
| 455 | <xsl:text>" },</xsl:text>
|
---|
| 456 | </xsl:if>
|
---|
| 457 |
|
---|
| 458 | <xsl:text>
|
---|
[68860] | 459 | { RTMSGREFENTRYSTR_SCOPE_SAME,
|
---|
[56367] | 460 | "</xsl:text>
|
---|
| 461 |
|
---|
| 462 | <xsl:for-each select="node()">
|
---|
| 463 | <xsl:choose>
|
---|
| 464 | <xsl:when test="name() = ''">
|
---|
| 465 | <xsl:call-template name="screen_text_line">
|
---|
| 466 | <xsl:with-param name="sText" select="."/>
|
---|
| 467 | </xsl:call-template>
|
---|
| 468 | </xsl:when>
|
---|
| 469 | <xsl:otherwise>
|
---|
| 470 | <xsl:if test="*">
|
---|
[68872] | 471 | <xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>Support for elements under screen has not been implemented: <xsl:value-of select="name()"/></xsl:message>
|
---|
[56367] | 472 | </xsl:if>
|
---|
| 473 | </xsl:otherwise>
|
---|
| 474 | </xsl:choose>
|
---|
| 475 | </xsl:for-each>
|
---|
| 476 |
|
---|
| 477 | <xsl:if test="not(ancestor::para)">
|
---|
| 478 | <xsl:text>" },</xsl:text>
|
---|
| 479 | </xsl:if>
|
---|
| 480 | </xsl:template>
|
---|
| 481 |
|
---|
| 482 | <xsl:template name="screen_text_line">
|
---|
| 483 | <xsl:param name="sText"/>
|
---|
| 484 |
|
---|
[85665] | 485 | <xsl:choose>
|
---|
| 486 | <xsl:when test="contains($sText, '
')">
|
---|
| 487 | <xsl:call-template name="escape_fixed_text">
|
---|
| 488 | <xsl:with-param name="sText" select="substring-before($sText,'
')"/>
|
---|
| 489 | </xsl:call-template>
|
---|
| 490 |
|
---|
| 491 | <xsl:if test="substring-after($sText,'
')">
|
---|
| 492 | <xsl:text>" },
|
---|
| 493 | { RTMSGREFENTRYSTR_SCOPE_SAME,
|
---|
| 494 | "</xsl:text>
|
---|
| 495 | <xsl:call-template name="screen_text_line">
|
---|
| 496 | <xsl:with-param name="sText" select="substring-after($sText,'
')"/>
|
---|
| 497 | </xsl:call-template>
|
---|
| 498 | </xsl:if>
|
---|
| 499 | </xsl:when>
|
---|
| 500 |
|
---|
| 501 | <xsl:otherwise> <!-- no newline, so use the whole string -->
|
---|
| 502 | <xsl:call-template name="escape_fixed_text">
|
---|
| 503 | <xsl:with-param name="sText" select="$sText"/>
|
---|
| 504 | </xsl:call-template>
|
---|
| 505 | </xsl:otherwise>
|
---|
| 506 | </xsl:choose>
|
---|
[56367] | 507 | </xsl:template>
|
---|
| 508 |
|
---|
[98098] | 509 | <!-- Normalizes the current text node taking tailing and leading spaces
|
---|
| 510 | into account (unlike normalize-space which strips them mercilessly). -->
|
---|
| 511 | <xsl:template name="my-normalize-space-current">
|
---|
| 512 | <!-- <xsl:message>dbg0: position=<xsl:value-of select="position()"/> last=<xsl:value-of select="last()"/> .=|<xsl:value-of select="."/>|</xsl:message> -->
|
---|
| 513 | <xsl:if test="(starts-with(.,' ') or starts-with(., $g_sNewLine)) and position() != 1">
|
---|
| 514 | <xsl:value-of select="' '"/>
|
---|
| 515 | </xsl:if>
|
---|
| 516 | <xsl:value-of select="normalize-space(.)"/>
|
---|
| 517 | <xsl:if test="((substring(.,string-length(.)) = ' ') or (substring(.,string-length(.)) = $g_sNewLine)) and position() != last()">
|
---|
| 518 | <xsl:value-of select="' '"/>
|
---|
| 519 | </xsl:if>
|
---|
| 520 | </xsl:template>
|
---|
[56367] | 521 |
|
---|
| 522 | <!--
|
---|
[56231] | 523 | Text escaping for C.
|
---|
| 524 | -->
|
---|
| 525 | <xsl:template match="text()" name="escape_text">
|
---|
[56568] | 526 | <!-- Leading whitespace hack! -->
|
---|
[98098] | 527 | <xsl:if test="(starts-with(.,' ') or starts-with(.,$g_sNewLine)) and position() != 1">
|
---|
[56568] | 528 | <xsl:text> </xsl:text>
|
---|
| 529 | <xsl:if test="boolean($g_fDebugText)">
|
---|
[98098] | 530 | <xsl:message>text: add lead space</xsl:message>
|
---|
[56568] | 531 | </xsl:if>
|
---|
| 532 | </xsl:if>
|
---|
| 533 |
|
---|
| 534 | <!-- Body of text -->
|
---|
[56231] | 535 | <xsl:choose>
|
---|
| 536 |
|
---|
| 537 | <xsl:when test="contains(., '\') or contains(., '"')">
|
---|
| 538 | <xsl:variable name="sTmp">
|
---|
| 539 | <xsl:call-template name="str:subst">
|
---|
| 540 | <xsl:with-param name="text" select="normalize-space(.)"/>
|
---|
| 541 | <xsl:with-param name="replace" select="'\'"/>
|
---|
| 542 | <xsl:with-param name="with" select="'\\'"/>
|
---|
| 543 | <xsl:with-param name="disable-output-escaping" select="yes"/>
|
---|
| 544 | </xsl:call-template>
|
---|
| 545 | </xsl:variable>
|
---|
[56568] | 546 | <xsl:variable name="sTmp2">
|
---|
| 547 | <xsl:call-template name="str:subst">
|
---|
| 548 | <xsl:with-param name="text" select="$sTmp"/>
|
---|
| 549 | <xsl:with-param name="replace" select="'"'"/>
|
---|
| 550 | <xsl:with-param name="with" select="'\"'"/>
|
---|
| 551 | <xsl:with-param name="disable-output-escaping" select="yes"/>
|
---|
| 552 | </xsl:call-template>
|
---|
| 553 | </xsl:variable>
|
---|
| 554 | <xsl:value-of select="$sTmp2"/>
|
---|
| 555 | <xsl:if test="boolean($g_fDebugText)">
|
---|
[98098] | 556 | <xsl:message>text: |<xsl:value-of select="$sTmp2"/>|(1)</xsl:message>
|
---|
[56568] | 557 | </xsl:if>
|
---|
[56231] | 558 | </xsl:when>
|
---|
| 559 |
|
---|
| 560 | <xsl:otherwise>
|
---|
| 561 | <xsl:value-of select="normalize-space(.)"/>
|
---|
[56568] | 562 | <xsl:if test="boolean($g_fDebugText)">
|
---|
[98098] | 563 | <xsl:message>text: |<xsl:value-of select="normalize-space(.)"/>|(2)</xsl:message>
|
---|
[56568] | 564 | </xsl:if>
|
---|
[56231] | 565 | </xsl:otherwise>
|
---|
| 566 | </xsl:choose>
|
---|
[56565] | 567 |
|
---|
[56568] | 568 | <!-- Trailing whitespace hack! -->
|
---|
[98098] | 569 | <xsl:if test="(substring(.,string-length(.)) = ' ' or substring(.,string-length(.)) = $g_sNewLine) and position() != last() and string-length(.) != 1">
|
---|
[56565] | 570 | <xsl:text> </xsl:text>
|
---|
[56568] | 571 | <xsl:if test="boolean($g_fDebugText)">
|
---|
[98098] | 572 | <xsl:message>text: add tail space</xsl:message>
|
---|
[56568] | 573 | </xsl:if>
|
---|
[56565] | 574 | </xsl:if>
|
---|
| 575 |
|
---|
[56231] | 576 | </xsl:template>
|
---|
| 577 |
|
---|
| 578 | <!-- Elements producing non-breaking strings (single line). -->
|
---|
[85665] | 579 | <xsl:template match="command/text()|option/text()|computeroutput/text()|arg/text()|filename/text()" name="escape_fixed_text">
|
---|
[98098] | 580 | <xsl:param name="sText"><xsl:call-template name="my-normalize-space-current"/></xsl:param>
|
---|
[56231] | 581 | <xsl:choose>
|
---|
| 582 |
|
---|
[56367] | 583 | <xsl:when test="contains($sText, '\') or contains($sText, '"')">
|
---|
[56231] | 584 | <xsl:variable name="sTmp1">
|
---|
| 585 | <xsl:call-template name="str:subst">
|
---|
[56367] | 586 | <xsl:with-param name="text" select="$sText"/>
|
---|
[56231] | 587 | <xsl:with-param name="replace" select="'\'"/>
|
---|
| 588 | <xsl:with-param name="with" select="'\\'"/>
|
---|
| 589 | <xsl:with-param name="disable-output-escaping" select="yes"/>
|
---|
| 590 | </xsl:call-template>
|
---|
| 591 | </xsl:variable>
|
---|
| 592 | <xsl:variable name="sTmp2">
|
---|
| 593 | <xsl:call-template name="str:subst">
|
---|
| 594 | <xsl:with-param name="text" select="$sTmp1"/>
|
---|
| 595 | <xsl:with-param name="replace" select="'"'"/>
|
---|
| 596 | <xsl:with-param name="with" select="'\"'"/>
|
---|
| 597 | <xsl:with-param name="disable-output-escaping" select="yes"/>
|
---|
| 598 | </xsl:call-template>
|
---|
| 599 | </xsl:variable>
|
---|
[56568] | 600 | <xsl:variable name="sTmp3">
|
---|
| 601 | <xsl:call-template name="str:subst">
|
---|
| 602 | <xsl:with-param name="text" select="$sTmp2"/>
|
---|
| 603 | <xsl:with-param name="replace" select="' '"/>
|
---|
| 604 | <xsl:with-param name="with" select="'\b'"/>
|
---|
| 605 | <xsl:with-param name="disable-output-escaping" select="yes"/>
|
---|
| 606 | </xsl:call-template>
|
---|
| 607 | </xsl:variable>
|
---|
| 608 | <xsl:value-of select="$sTmp3"/>
|
---|
| 609 | <xsl:if test="boolean($g_fDebugText)">
|
---|
| 610 | <xsl:message>text! |<xsl:value-of select="$sTmp3"/>|</xsl:message>
|
---|
| 611 | </xsl:if>
|
---|
[56231] | 612 | </xsl:when>
|
---|
| 613 |
|
---|
[56367] | 614 | <xsl:when test="contains($sText, ' ')">
|
---|
[56568] | 615 | <xsl:variable name="sTmp">
|
---|
| 616 | <xsl:call-template name="str:subst">
|
---|
| 617 | <xsl:with-param name="text" select="$sText"/>
|
---|
| 618 | <xsl:with-param name="replace" select="' '"/>
|
---|
| 619 | <xsl:with-param name="with" select="'\b'"/>
|
---|
| 620 | <xsl:with-param name="disable-output-escaping" select="yes"/>
|
---|
| 621 | </xsl:call-template>
|
---|
| 622 | </xsl:variable>
|
---|
| 623 | <xsl:value-of select="$sTmp"/>
|
---|
| 624 | <xsl:if test="boolean($g_fDebugText)">
|
---|
| 625 | <xsl:message>text! |<xsl:value-of select="$sTmp"/>|</xsl:message>
|
---|
| 626 | </xsl:if>
|
---|
[56231] | 627 | </xsl:when>
|
---|
| 628 |
|
---|
| 629 | <xsl:otherwise>
|
---|
[56367] | 630 | <xsl:value-of select="$sText"/>
|
---|
[56568] | 631 | <xsl:if test="boolean($g_fDebugText)">
|
---|
| 632 | <xsl:message>text! |<xsl:value-of select="$sText"/>|</xsl:message>
|
---|
| 633 | </xsl:if>
|
---|
[56231] | 634 | </xsl:otherwise>
|
---|
| 635 | </xsl:choose>
|
---|
| 636 | </xsl:template>
|
---|
| 637 |
|
---|
| 638 |
|
---|
| 639 | <!--
|
---|
| 640 | Unsupported elements and elements handled directly.
|
---|
| 641 | -->
|
---|
| 642 | <xsl:template match="synopfragment|synopfragmentref|title|refsect1">
|
---|
[68872] | 643 | <xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>The <xsl:value-of select="name()"/> element is not supported</xsl:message>
|
---|
[56231] | 644 | </xsl:template>
|
---|
| 645 |
|
---|
[93802] | 646 | <xsl:template match="xref">
|
---|
| 647 | <xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>The <xsl:value-of select="name()"/> element is not supported, most likely the linkend is not defined or incorrectly processed by docbook-refentry-link-replacement-xsl-gen.xsl</xsl:message>
|
---|
| 648 | </xsl:template>
|
---|
| 649 |
|
---|
[56231] | 650 | <!--
|
---|
| 651 | Fail on misplaced scoping remarks.
|
---|
| 652 | -->
|
---|
| 653 | <xsl:template match="remark[@role = 'help-scope']">
|
---|
| 654 | <xsl:choose>
|
---|
| 655 | <xsl:when test="parent::refsect1"/>
|
---|
| 656 | <xsl:when test="parent::refsect2"/>
|
---|
| 657 | <xsl:when test="parent::cmdsynopsis and ancestor::refsynopsisdiv"/>
|
---|
| 658 | <xsl:otherwise>
|
---|
[68872] | 659 | <xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>Misplaced remark/@role=help-scope element.
|
---|
[56231] | 660 | Only supported on: refsect1, refsect2, refsynopsisdiv/cmdsynopsis</xsl:message>
|
---|
| 661 | </xsl:otherwise>
|
---|
| 662 | </xsl:choose>
|
---|
| 663 | </xsl:template>
|
---|
| 664 |
|
---|
| 665 | <!--
|
---|
[56533] | 666 | Execute synopsis copy remark (avoids duplication for complicated xml).
|
---|
[56466] | 667 | -->
|
---|
| 668 | <xsl:template match="remark[@role = 'help-copy-synopsis']">
|
---|
[68872] | 669 | <xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>remark/@role=help-copy-synopsis is not supported by this stylesheet. Must preprocess input!</xsl:message>
|
---|
[56466] | 670 | </xsl:template>
|
---|
| 671 |
|
---|
| 672 | <!--
|
---|
[56231] | 673 | Warn about unhandled elements
|
---|
| 674 | -->
|
---|
| 675 | <xsl:template match="*">
|
---|
[56466] | 676 | <xsl:message terminate="no">Warning: Unhandled element: <!-- no newline -->
|
---|
| 677 | <xsl:for-each select="ancestor-or-self::*">
|
---|
| 678 | <xsl:text>/</xsl:text>
|
---|
| 679 | <xsl:value-of select="name(.)"/>
|
---|
| 680 | <xsl:if test="@id">
|
---|
| 681 | <xsl:value-of select="concat('[id=', @id ,']')"/>
|
---|
| 682 | </xsl:if>
|
---|
| 683 | </xsl:for-each>
|
---|
| 684 | </xsl:message>
|
---|
[56231] | 685 | </xsl:template>
|
---|
| 686 |
|
---|
| 687 |
|
---|
| 688 | <!--
|
---|
[56208] | 689 | Functions
|
---|
| 690 | Functions
|
---|
| 691 | Functions
|
---|
| 692 | -->
|
---|
| 693 |
|
---|
[56231] | 694 | <!--
|
---|
| 695 | Processes mixed children, i.e. both text and regular elements.
|
---|
| 696 | Normalizes whitespace. -->
|
---|
| 697 | <xsl:template name="process-mixed">
|
---|
| 698 | <xsl:text>
|
---|
[68860] | 699 | { RTMSGREFENTRYSTR_SCOPE_SAME,
|
---|
[56231] | 700 | "</xsl:text><xsl:call-template name="emit-indentation"/>
|
---|
| 701 |
|
---|
| 702 | <xsl:for-each select="node()[not(self::remark)]">
|
---|
| 703 | <xsl:choose>
|
---|
| 704 | <xsl:when test="name() = ''">
|
---|
| 705 | <xsl:call-template name="escape_text"/>
|
---|
| 706 | </xsl:when>
|
---|
| 707 | <xsl:otherwise>
|
---|
| 708 | <xsl:apply-templates select="."/>
|
---|
| 709 | </xsl:otherwise>
|
---|
| 710 | </xsl:choose>
|
---|
| 711 | </xsl:for-each>
|
---|
| 712 |
|
---|
| 713 | <xsl:text>" },</xsl:text>
|
---|
| 714 | </xsl:template>
|
---|
| 715 |
|
---|
| 716 |
|
---|
[56344] | 717 | <!--
|
---|
| 718 | Element specific scoping.
|
---|
| 719 | -->
|
---|
| 720 |
|
---|
| 721 | <xsl:template name="calc-scope-for-refentry">
|
---|
[68860] | 722 | <xsl:text>HELP_SCOPE_</xsl:text>
|
---|
| 723 | <xsl:choose>
|
---|
| 724 | <xsl:when test="contains(@id, '-')"> <!-- Multi level command. -->
|
---|
| 725 | <xsl:call-template name="str:to-upper">
|
---|
| 726 | <xsl:with-param name="text" select="translate(substring-after(@id, '-'), '-', '_')"/>
|
---|
| 727 | </xsl:call-template>
|
---|
| 728 | </xsl:when>
|
---|
| 729 | <xsl:otherwise> <!-- Single command. -->
|
---|
| 730 | <xsl:call-template name="str:to-upper">
|
---|
| 731 | <xsl:with-param name="text" select="@id"/>
|
---|
| 732 | </xsl:call-template>
|
---|
| 733 | </xsl:otherwise>
|
---|
| 734 | </xsl:choose>
|
---|
[56344] | 735 | </xsl:template>
|
---|
| 736 |
|
---|
[56231] | 737 | <!-- Figures out the scope of a refsect1 element. -->
|
---|
| 738 | <xsl:template name="calc-scope-refsect1">
|
---|
| 739 | <xsl:choose>
|
---|
[99513] | 740 | <xsl:when test="contains(@id, '-description') or title[text() = 'Description']">
|
---|
[68860] | 741 | <xsl:text>RTMSGREFENTRYSTR_SCOPE_GLOBAL</xsl:text>
|
---|
[56231] | 742 | </xsl:when>
|
---|
[99513] | 743 | <xsl:when test="(@id and not(contains(@id, '-see-also')) and not(contains(@id, '-examples'))) or remark[@role='help-scope']">
|
---|
[56367] | 744 | <xsl:call-template name="calc-scope-from-remark-or-id"/>
|
---|
| 745 | </xsl:when>
|
---|
[56231] | 746 | <xsl:otherwise>
|
---|
[68860] | 747 | <xsl:text>RTMSGREFENTRYSTR_SCOPE_GLOBAL</xsl:text>
|
---|
[56231] | 748 | </xsl:otherwise>
|
---|
| 749 | </xsl:choose>
|
---|
| 750 | </xsl:template>
|
---|
| 751 |
|
---|
| 752 | <!-- Figures out the scope of a refsect2 element. -->
|
---|
| 753 | <xsl:template name="calc-scope-refsect2">
|
---|
| 754 | <xsl:choose>
|
---|
[99513] | 755 | <xsl:when test="(@id and not(contains(@id, '-see-also')) and not(contains(@id, '-examples'))) or remark[@role='help-scope']">
|
---|
[56344] | 756 | <xsl:call-template name="calc-scope-from-remark-or-id"/>
|
---|
[56231] | 757 | </xsl:when>
|
---|
| 758 | <xsl:otherwise>
|
---|
[68860] | 759 | <xsl:text>RTMSGREFENTRYSTR_SCOPE_SAME</xsl:text>
|
---|
[56231] | 760 | </xsl:otherwise>
|
---|
| 761 | </xsl:choose>
|
---|
| 762 | </xsl:template>
|
---|
| 763 |
|
---|
| 764 | <!-- Figures out the scope of a refsect1 element. -->
|
---|
| 765 | <xsl:template name="calc-scope-cmdsynopsis">
|
---|
| 766 | <xsl:choose>
|
---|
| 767 | <xsl:when test="ancestor::refsynopsisdiv">
|
---|
[56344] | 768 | <xsl:call-template name="calc-scope-from-remark-or-id">
|
---|
| 769 | <xsl:with-param name="sId" select="substring-after(@id, '-')"/>
|
---|
| 770 | </xsl:call-template>
|
---|
[56231] | 771 | </xsl:when>
|
---|
| 772 | <xsl:otherwise>
|
---|
[68860] | 773 | <xsl:text>RTMSGREFENTRYSTR_SCOPE_SAME</xsl:text>
|
---|
[56231] | 774 | </xsl:otherwise>
|
---|
| 775 | </xsl:choose>
|
---|
| 776 | </xsl:template>
|
---|
| 777 |
|
---|
[56208] | 778 |
|
---|
[56344] | 779 | <!--
|
---|
| 780 | Scoping worker functions.
|
---|
| 781 | -->
|
---|
| 782 |
|
---|
| 783 | <!-- Calculates the current scope from the scope remark or @id. -->
|
---|
| 784 | <xsl:template name="calc-scope-from-remark-or-id">
|
---|
| 785 | <xsl:param name="sId" select="@id"/>
|
---|
[56208] | 786 | <xsl:choose>
|
---|
[56344] | 787 | <xsl:when test="remark[@role='help-scope']">
|
---|
| 788 | <xsl:call-template name="calc-scope-consts-from-remark"/>
|
---|
[56208] | 789 | </xsl:when>
|
---|
[56344] | 790 | <xsl:when test="$sId != ''">
|
---|
| 791 | <xsl:call-template name="calc-scope-const-from-id">
|
---|
| 792 | <xsl:with-param name="sId" select="$sId"/>
|
---|
[56208] | 793 | </xsl:call-template>
|
---|
| 794 | </xsl:when>
|
---|
| 795 | <xsl:otherwise>
|
---|
[68872] | 796 | <xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>expected remark child or id attribute.</xsl:message>
|
---|
[56208] | 797 | </xsl:otherwise>
|
---|
| 798 | </xsl:choose>
|
---|
| 799 | </xsl:template>
|
---|
| 800 |
|
---|
[56344] | 801 | <!-- Turns a @id into a scope constant.
|
---|
| 802 | Some woodoo taking place here here that chops the everything up to and
|
---|
| 803 | including the first refentry/@id word from all IDs before turning them into
|
---|
| 804 | constants (word delimiter '-'). -->
|
---|
| 805 | <xsl:template name="calc-scope-const-from-id">
|
---|
[56208] | 806 | <xsl:param name="sId" select="@id"/>
|
---|
[68860] | 807 | <xsl:param name="sAncestorId" select="ancestor::refentry/@id"/>
|
---|
[56231] | 808 | <xsl:text>HELP_SCOPE_</xsl:text>
|
---|
[68860] | 809 | <xsl:choose>
|
---|
| 810 | <xsl:when test="not($sAncestorId)"> <!-- Sanity check. -->
|
---|
[68872] | 811 | <xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>calc-scope-const-from-id is invoked without an refentry ancestor with a id. <xsl:call-template name="get-node-path"/> </xsl:message>
|
---|
[68860] | 812 | </xsl:when>
|
---|
| 813 |
|
---|
| 814 | <xsl:when test="contains($sAncestorId, '-')"> <!-- Multi level command. -->
|
---|
| 815 | <xsl:variable name="sPrefix" select="concat(substring-before($sAncestorId, '-'), '-')"/>
|
---|
| 816 | <xsl:if test="not(contains($sId, $sPrefix))">
|
---|
[68872] | 817 | <xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>Expected sId (<xsl:value-of select="$sId"/>) to contain <xsl:value-of select="$sPrefix"/></xsl:message>
|
---|
[68860] | 818 | </xsl:if>
|
---|
| 819 | <xsl:call-template name="str:to-upper">
|
---|
| 820 | <xsl:with-param name="text" select="translate(substring-after($sId, $sPrefix), '-', '_')"/>
|
---|
| 821 | </xsl:call-template>
|
---|
| 822 | </xsl:when>
|
---|
| 823 |
|
---|
| 824 | <xsl:otherwise> <!-- Single command. -->
|
---|
| 825 | <xsl:call-template name="str:to-upper">
|
---|
| 826 | <xsl:with-param name="text" select="translate($sId, '-', '_')"/>
|
---|
| 827 | </xsl:call-template>
|
---|
| 828 | </xsl:otherwise>
|
---|
| 829 | </xsl:choose>
|
---|
[56208] | 830 | </xsl:template>
|
---|
| 831 |
|
---|
[68860] | 832 | <!-- Turns a remark into one or more scope constants. -->
|
---|
[56344] | 833 | <xsl:template name="calc-scope-consts-from-remark">
|
---|
| 834 | <xsl:param name="sCondition" select="remark/@condition"/>
|
---|
[56368] | 835 | <xsl:variable name="sNormalized" select="concat(normalize-space(translate($sCondition, ',;:|', ' ')), ' ')"/>
|
---|
| 836 | <xsl:if test="$sNormalized = ' ' or $sNormalized = ''">
|
---|
[68872] | 837 | <xsl:message terminate="yes"><xsl:call-template name="error-prefix"/>Empty @condition for help-scope remark.</xsl:message>
|
---|
[56344] | 838 | </xsl:if>
|
---|
[56444] | 839 | <xsl:choose>
|
---|
| 840 | <xsl:when test="substring-before($sNormalized, ' ') = 'GLOBAL'">
|
---|
[68860] | 841 | <xsl:text>RTMSGREFENTRYSTR_SCOPE_GLOBAL</xsl:text>
|
---|
[56444] | 842 | </xsl:when>
|
---|
| 843 | <xsl:otherwise>
|
---|
| 844 | <xsl:text>HELP_SCOPE_</xsl:text><xsl:value-of select="substring-before($sNormalized, ' ')"/>
|
---|
| 845 | </xsl:otherwise>
|
---|
| 846 | </xsl:choose>
|
---|
[56344] | 847 | <xsl:call-template name="calc-scope-const-from-remark-worker">
|
---|
| 848 | <xsl:with-param name="sList" select="substring-after($sNormalized, ' ')"/>
|
---|
| 849 | </xsl:call-template>
|
---|
| 850 | </xsl:template>
|
---|
| 851 |
|
---|
| 852 | <xsl:template name="calc-scope-const-from-remark-worker">
|
---|
| 853 | <xsl:param name="sList"/>
|
---|
[56368] | 854 | <xsl:if test="$sList != ''">
|
---|
[56444] | 855 | <xsl:choose>
|
---|
| 856 | <xsl:when test="substring-before($sList, ' ') = 'GLOBAL'">
|
---|
[68860] | 857 | <xsl:text>| RTMSGREFENTRYSTR_SCOPE_GLOBAL</xsl:text>
|
---|
[56444] | 858 | </xsl:when>
|
---|
| 859 | <xsl:otherwise>
|
---|
| 860 | <xsl:text> | HELP_SCOPE_</xsl:text><xsl:value-of select="substring-before($sList, ' ')"/>
|
---|
| 861 | </xsl:otherwise>
|
---|
| 862 | </xsl:choose>
|
---|
[56344] | 863 | <xsl:call-template name="calc-scope-const-from-remark-worker">
|
---|
| 864 | <xsl:with-param name="sList" select="substring-after($sList, ' ')"/>
|
---|
| 865 | </xsl:call-template>
|
---|
| 866 | </xsl:if>
|
---|
| 867 | </xsl:template>
|
---|
| 868 |
|
---|
| 869 |
|
---|
| 870 | <!--
|
---|
[56565] | 871 | Calculates and emits indentation list markup.
|
---|
[56344] | 872 | -->
|
---|
[56231] | 873 | <xsl:template name="emit-indentation">
|
---|
[56565] | 874 | <xsl:variable name="iDepth" select="count(ancestor-or-self::*)"/>
|
---|
| 875 | <xsl:for-each select="ancestor-or-self::*">
|
---|
| 876 | <xsl:choose>
|
---|
[56568] | 877 |
|
---|
[56565] | 878 | <xsl:when test="self::refsect1
|
---|
| 879 | | self::refsect2
|
---|
| 880 | | self::refsect3
|
---|
| 881 | | self::refsynopsisdiv">
|
---|
| 882 | <xsl:text> </xsl:text>
|
---|
| 883 | </xsl:when>
|
---|
[56568] | 884 |
|
---|
| 885 | <xsl:when test="self::term">
|
---|
| 886 | <!-- currently no indent. -->
|
---|
[56565] | 887 | </xsl:when>
|
---|
[56568] | 888 |
|
---|
| 889 | <!-- Evidence here (especially with orderedlist) that doing list by for-each
|
---|
| 890 | listitem in the template matching the list type would be easier... -->
|
---|
[56565] | 891 | <xsl:when test="self::listitem and parent::itemizedlist and (position() + 1) = $iDepth">
|
---|
[56568] | 892 | <xsl:text> - </xsl:text>
|
---|
[56565] | 893 | </xsl:when>
|
---|
[56568] | 894 |
|
---|
| 895 | <xsl:when test="self::listitem and parent::orderedlist and (position() + 1) = $iDepth">
|
---|
| 896 | <xsl:variable name="iNumber" select="count(preceding-sibling::listitem) + 1"/>
|
---|
| 897 | <xsl:if test="$iNumber <= 9">
|
---|
| 898 | <xsl:text> </xsl:text>
|
---|
| 899 | </xsl:if>
|
---|
| 900 | <xsl:value-of select="$iNumber"/>
|
---|
| 901 | <xsl:text>. </xsl:text>
|
---|
| 902 | </xsl:when>
|
---|
| 903 |
|
---|
| 904 | <xsl:when test="self::listitem">
|
---|
[56565] | 905 | <xsl:text> </xsl:text>
|
---|
| 906 | </xsl:when>
|
---|
[56568] | 907 |
|
---|
[56565] | 908 | </xsl:choose>
|
---|
| 909 | </xsl:for-each>
|
---|
[56208] | 910 | </xsl:template>
|
---|
| 911 |
|
---|
[56344] | 912 | <!--
|
---|
| 913 | Captializes the given text.
|
---|
| 914 | -->
|
---|
[56231] | 915 | <xsl:template name="capitalize">
|
---|
| 916 | <xsl:param name="text"/>
|
---|
| 917 | <xsl:call-template name="str:to-upper">
|
---|
| 918 | <xsl:with-param name="text" select="substring($text,1,1)"/>
|
---|
[56208] | 919 | </xsl:call-template>
|
---|
[56231] | 920 | <xsl:value-of select="substring($text,2)"/>
|
---|
[56208] | 921 | </xsl:template>
|
---|
| 922 |
|
---|
[56571] | 923 |
|
---|
| 924 | <!--
|
---|
| 925 | Debug/Diagnostics: Return the path to the specified node (by default the current).
|
---|
| 926 | -->
|
---|
| 927 | <xsl:template name="get-node-path">
|
---|
| 928 | <xsl:param name="Node" select="."/>
|
---|
| 929 | <xsl:for-each select="$Node">
|
---|
| 930 | <xsl:for-each select="ancestor-or-self::node()">
|
---|
| 931 | <xsl:choose>
|
---|
| 932 | <xsl:when test="name(.) = ''">
|
---|
| 933 | <xsl:text>text()</xsl:text>
|
---|
| 934 | </xsl:when>
|
---|
| 935 | <xsl:otherwise>
|
---|
| 936 | <xsl:value-of select="concat('/', name(.))"/>
|
---|
[68872] | 937 | <xsl:choose>
|
---|
| 938 | <xsl:when test="@id">
|
---|
| 939 | <xsl:text>[@id=</xsl:text>
|
---|
| 940 | <xsl:value-of select="@id"/>
|
---|
| 941 | <xsl:text>]</xsl:text>
|
---|
| 942 | </xsl:when>
|
---|
| 943 | <xsl:when test="position() > 1">
|
---|
| 944 | <xsl:text>[</xsl:text><xsl:value-of select="position()"/><xsl:text>]</xsl:text>
|
---|
| 945 | </xsl:when>
|
---|
| 946 | </xsl:choose>
|
---|
[56571] | 947 | </xsl:otherwise>
|
---|
| 948 | </xsl:choose>
|
---|
| 949 | </xsl:for-each>
|
---|
| 950 | </xsl:for-each>
|
---|
| 951 | </xsl:template>
|
---|
| 952 |
|
---|
| 953 | <!--
|
---|
[68872] | 954 | Debug/Diagnostics: Return error message prefix.
|
---|
| 955 | -->
|
---|
| 956 | <xsl:template name="error-prefix">
|
---|
| 957 | <xsl:param name="Node" select="."/>
|
---|
| 958 | <xsl:text>error: </xsl:text>
|
---|
| 959 | <xsl:call-template name="get-node-path">
|
---|
| 960 | <xsl:with-param name="Node" select="$Node"/>
|
---|
| 961 | </xsl:call-template>
|
---|
| 962 | <xsl:text>: </xsl:text>
|
---|
| 963 | </xsl:template>
|
---|
| 964 |
|
---|
| 965 | <!--
|
---|
[56571] | 966 | Debug/Diagnostics: Print list of nodes (by default all children of current node).
|
---|
| 967 | -->
|
---|
| 968 | <xsl:template name="list-nodes">
|
---|
| 969 | <xsl:param name="Nodes" select="node()"/>
|
---|
[77887] | 970 | <xsl:for-each select="$Nodes">
|
---|
| 971 | <xsl:if test="position() != 1">
|
---|
[56571] | 972 | <xsl:text>, </xsl:text>
|
---|
| 973 | </xsl:if>
|
---|
| 974 | <xsl:choose>
|
---|
| 975 | <xsl:when test="name(.) = ''">
|
---|
[77887] | 976 | <xsl:text>text:text()</xsl:text>
|
---|
[56571] | 977 | </xsl:when>
|
---|
| 978 | <xsl:otherwise>
|
---|
| 979 | <xsl:value-of select="name(.)"/>
|
---|
| 980 | <xsl:if test="@id">
|
---|
| 981 | <xsl:text>[@id=</xsl:text>
|
---|
| 982 | <xsl:value-of select="@id"/>
|
---|
| 983 | <xsl:text>]</xsl:text>
|
---|
| 984 | </xsl:if>
|
---|
| 985 | </xsl:otherwise>
|
---|
| 986 | </xsl:choose>
|
---|
[77887] | 987 | </xsl:for-each>
|
---|
[56571] | 988 | </xsl:template>
|
---|
| 989 |
|
---|
[56586] | 990 | <xsl:template name="check-children">
|
---|
| 991 | <xsl:param name="Node" select="."/>
|
---|
| 992 | <xsl:param name="UnsupportedNodes" select="*"/>
|
---|
| 993 | <xsl:param name="SupportedNames" select="'none'"/>
|
---|
| 994 | <xsl:if test="count($UnsupportedNodes) != 0">
|
---|
| 995 | <xsl:message terminate="yes">
|
---|
| 996 | <xsl:call-template name="get-node-path">
|
---|
| 997 | <xsl:with-param name="Node" select="$Node"/>
|
---|
| 998 | </xsl:call-template>
|
---|
| 999 | <!-- -->: error: Only <xsl:value-of select="$SupportedNames"/> are supported as children to <!-- -->
|
---|
| 1000 | <xsl:value-of select="name($Node)"/>
|
---|
[77887] | 1001 | <!-- -->
|
---|
| 1002 | Unsupported children: <!-- -->
|
---|
[56586] | 1003 | <xsl:call-template name="list-nodes">
|
---|
| 1004 | <xsl:with-param name="Nodes" select="$UnsupportedNodes"/>
|
---|
| 1005 | </xsl:call-template>
|
---|
| 1006 | </xsl:message>
|
---|
| 1007 | </xsl:if>
|
---|
| 1008 | </xsl:template>
|
---|
| 1009 |
|
---|
[56192] | 1010 | </xsl:stylesheet>
|
---|
| 1011 |
|
---|