1 | <?xml version="1.0"?>
|
---|
2 | <!--
|
---|
3 | Copyright (C) 2020-2022 Oracle and/or its affiliates.
|
---|
4 |
|
---|
5 | This file is part of VirtualBox base platform packages, as
|
---|
6 | available from https://www.virtualbox.org.
|
---|
7 |
|
---|
8 | This program is free software; you can redistribute it and/or
|
---|
9 | modify it under the terms of the GNU General Public License
|
---|
10 | as published by the Free Software Foundation, in version 3 of the
|
---|
11 | License.
|
---|
12 |
|
---|
13 | This program is distributed in the hope that it will be useful, but
|
---|
14 | WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
16 | General Public License for more details.
|
---|
17 |
|
---|
18 | You should have received a copy of the GNU General Public License
|
---|
19 | along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
20 |
|
---|
21 | SPDX-License-Identifier: GPL-3.0-only
|
---|
22 | -->
|
---|
23 | <xsl:stylesheet version="1.0"
|
---|
24 | xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
---|
25 | xmlns:xhtml="http://www.w3.org/1999/xhtml">
|
---|
26 | <xsl:output method="xml" omit-xml-declaration="no"/>
|
---|
27 | <!-- Don't include non matching elements in output -->
|
---|
28 | <xsl:template match="text()"/>
|
---|
29 | <xsl:strip-space elements="*"/>
|
---|
30 |
|
---|
31 | <!-- maybe a bit nicer way of adding a new line to the output -->
|
---|
32 | <xsl:variable name="newline"><xsl:text>
|
---|
33 | </xsl:text></xsl:variable>
|
---|
34 |
|
---|
35 | <xsl:variable name="inputFileName">
|
---|
36 | <xsl:text>UserManual.xhtml</xsl:text>
|
---|
37 | </xsl:variable>
|
---|
38 |
|
---|
39 | <xsl:template match="/">
|
---|
40 | <xsl:element name="QtHelpProject">
|
---|
41 | <xsl:attribute name="version">
|
---|
42 | <xsl:value-of select="format-number(1, '.0')" />
|
---|
43 | </xsl:attribute>
|
---|
44 | <xsl:value-of select="$newline" />
|
---|
45 | <xsl:element name="namespace">org.virtualbox</xsl:element>
|
---|
46 | <xsl:value-of select="$newline" />
|
---|
47 | <xsl:element name="virtualFolder">manual</xsl:element>
|
---|
48 | <xsl:value-of select="$newline" />
|
---|
49 | <xsl:element name="filterSection">
|
---|
50 | <xsl:value-of select="$newline" />
|
---|
51 | <xsl:element name="toc">
|
---|
52 | <xsl:apply-templates select="//xhtml:div[@class='toc']//xhtml:span[@class='chapter'] | //xhtml:div[@class='toc']//xhtml:span[@class='preface']"/>
|
---|
53 | </xsl:element><!-- toc -->
|
---|
54 | <xsl:value-of select="$newline" />
|
---|
55 | <!-- <xsl:element name="keywords"></xsl:element> -->
|
---|
56 | <xsl:value-of select="$newline" />
|
---|
57 | <xsl:element name="files">
|
---|
58 | <!-- ======================input html file(s)============================= -->
|
---|
59 | <xsl:value-of select="$newline" />
|
---|
60 | <!-- ====================chunked html input files========================== -->
|
---|
61 | <!-- Process div tag with class='toc'. For each space with class='chapter' -->
|
---|
62 | <!-- add a <file>ch(position()).html</file> assuming our docbook chunked html -->
|
---|
63 | <!-- files are named in this fashion. -->
|
---|
64 | <!-- <xsl:apply-templates select="//xhtml:div[@class='toc']//xhtml:span[@class='chapter']"/> -->
|
---|
65 | <!-- ====================single html input file========================== -->
|
---|
66 | <xsl:element name="file">
|
---|
67 | <xsl:value-of select="$inputFileName" />
|
---|
68 | </xsl:element>
|
---|
69 | <xsl:value-of select="$newline" />
|
---|
70 | <!-- ===================================================================== -->
|
---|
71 | <!-- ===================image files======================================= -->
|
---|
72 | <xsl:apply-templates select="//xhtml:img"/>
|
---|
73 | <!-- ===================================================================== -->
|
---|
74 |
|
---|
75 | </xsl:element>
|
---|
76 | <xsl:value-of select="$newline" />
|
---|
77 | </xsl:element>
|
---|
78 | <xsl:value-of select="$newline" />
|
---|
79 | </xsl:element>
|
---|
80 | </xsl:template>
|
---|
81 |
|
---|
82 | <!-- ===================toc related template(s)====================== -->
|
---|
83 | <xsl:template match="xhtml:span[@class='chapter'] | xhtml:span[@class='preface']">
|
---|
84 | <xsl:element name="section">
|
---|
85 | <xsl:attribute name="title">
|
---|
86 | <xsl:value-of select="*" />
|
---|
87 | </xsl:attribute>
|
---|
88 | <xsl:attribute name="ref">
|
---|
89 | <xsl:value-of select="$inputFileName" /><xsl:value-of select="xhtml:a/@href" />
|
---|
90 | </xsl:attribute>
|
---|
91 | </xsl:element>
|
---|
92 | <xsl:value-of select="$newline" />
|
---|
93 | </xsl:template>
|
---|
94 | <!-- ============================================================== -->
|
---|
95 |
|
---|
96 | <xsl:template match="//xhtml:img">
|
---|
97 | <xsl:element name="file">
|
---|
98 | <xsl:value-of select="@src"/>
|
---|
99 | </xsl:element>
|
---|
100 | <xsl:value-of select="$newline" />
|
---|
101 | </xsl:template>
|
---|
102 |
|
---|
103 |
|
---|
104 | </xsl:stylesheet>
|
---|