1 | <?xml version="1.0"?>
|
---|
2 | <!--
|
---|
3 | docbook-refentry-to-manpage-preprocessing.xsl:
|
---|
4 | XSLT stylesheet preprocessing remarks elements before
|
---|
5 | turning a refentry (manpage) into a unix manual page and
|
---|
6 | VBoxManage built-in help.
|
---|
7 | -->
|
---|
8 | <!--
|
---|
9 | Copyright (C) 2006-2020 Oracle Corporation
|
---|
10 |
|
---|
11 | This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
12 | available from http://www.virtualbox.org. This file is free software;
|
---|
13 | you can redistribute it and/or modify it under the terms of the GNU
|
---|
14 | General Public License (GPL) as published by the Free Software
|
---|
15 | Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
16 | VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
17 | hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
18 | -->
|
---|
19 |
|
---|
20 | <xsl:stylesheet
|
---|
21 | version="1.0"
|
---|
22 | xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
---|
23 | xmlns:str="http://xsltsl.org/string"
|
---|
24 | >
|
---|
25 |
|
---|
26 | <xsl:output method="xml" version="1.0" encoding="utf-8" indent="no"/>
|
---|
27 |
|
---|
28 | <!--
|
---|
29 | The default action is to copy everything.
|
---|
30 | -->
|
---|
31 | <xsl:template match="node()|@*">
|
---|
32 | <xsl:copy>
|
---|
33 | <xsl:apply-templates select="node()|@*"/>
|
---|
34 | </xsl:copy>
|
---|
35 | </xsl:template>
|
---|
36 |
|
---|
37 | <!--
|
---|
38 | Execute synopsis copy remark (avoids duplication for complicated xml).
|
---|
39 | We strip the attributes off it.
|
---|
40 | -->
|
---|
41 | <xsl:template match="remark[@role = 'help-copy-synopsis']">
|
---|
42 | <xsl:choose>
|
---|
43 | <xsl:when test="parent::refsect2"/>
|
---|
44 | <xsl:otherwise>
|
---|
45 | <xsl:message terminate="yes">Misplaced remark/@role=help-copy-synopsis element.
|
---|
46 | Only supported on: refsect2</xsl:message>
|
---|
47 | </xsl:otherwise>
|
---|
48 | </xsl:choose>
|
---|
49 | <xsl:variable name="sSrcId">
|
---|
50 | <xsl:choose>
|
---|
51 | <xsl:when test="@condition"><xsl:value-of select="concat('synopsis-', @condition)"/></xsl:when>
|
---|
52 | <xsl:otherwise><xsl:value-of select="concat('synopsis-', ../@id)"/></xsl:otherwise>
|
---|
53 | </xsl:choose>
|
---|
54 | </xsl:variable>
|
---|
55 | <xsl:variable name="CmdSynopsis" select="/refentry/refsynopsisdiv/cmdsynopsis[@id = $sSrcId]"/>
|
---|
56 | <xsl:if test="not($CmdSynopsis)">
|
---|
57 | <xsl:message terminate="yes">Could not find any cmdsynopsis with id=<xsl:value-of select="$sSrcId"/> in refsynopsisdiv.</xsl:message>
|
---|
58 | </xsl:if>
|
---|
59 |
|
---|
60 | <xsl:element name="cmdsynopsis">
|
---|
61 | <xsl:apply-templates select="$CmdSynopsis/node()"/>
|
---|
62 | </xsl:element>
|
---|
63 |
|
---|
64 | </xsl:template>
|
---|
65 |
|
---|
66 | <!--
|
---|
67 | Remove bits only intended for the manual.
|
---|
68 | -->
|
---|
69 | <xsl:template match="remark[@role='help-manual']"/>
|
---|
70 |
|
---|
71 | <!--
|
---|
72 | Remove remarks without a role.
|
---|
73 | These are used for leaving questions and such while working with the documentation team.
|
---|
74 | -->
|
---|
75 | <xsl:template match="remark[not(@role)]"/>
|
---|
76 |
|
---|
77 |
|
---|
78 | </xsl:stylesheet>
|
---|
79 |
|
---|