1 <?xml version="1.0" encoding="UTF-8"?>
2 <xsl:stylesheet version="1.0" xmlns="http://www.devhelp.net/book"
3 xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
5 Copyright (c) 2009 Daniel Elstner <daniel.kitta@gmail.com>
7 XSL transformation from a Doxygen tag file to DevHelp 2 format.
9 This script is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published
11 by the Free Software Foundation, either version 2 of the License,
12 or (at your option) any later version.
14 This script is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this script. If not, see <http://www.gnu.org/licenses/>.
22 <xsl:strip-space elements="*"/>
23 <xsl:output method="xml" version="1.0" indent="yes" encoding="UTF-8"/>
25 <xsl:param name="book_title"/>
26 <xsl:param name="book_name"/>
27 <xsl:param name="book_base"/>
29 <!-- Define keys to filter compounds that are members of other compounds -->
30 <xsl:key name="nested-group" match="compound[@kind='group']" use="subgroup"/>
31 <xsl:key name="nested-scope" match="compound[@kind='namespace']" use="namespace|class"/>
32 <xsl:key name="nested-scope" match="compound[@kind='class' or @kind='struct' or @kind='union']"
35 <xsl:template match="/">
36 <book title="{$book_title}" name="{$book_name}" base="{$book_base}"
37 link="index.html" version="2" language="c++">
39 <xsl:variable name="modules" select="tagfile/compound[@kind='group']"/>
40 <xsl:if test="$modules">
41 <sub name="Modules" link="modules.html">
42 <!-- Select the top-level group compounds -->
43 <xsl:apply-templates select="$modules[not(key('nested-group', name))]"
45 <xsl:sort lang="en" select="title"/>
46 </xsl:apply-templates>
49 <xsl:variable name="namespaces" select="tagfile/compound[@kind='namespace']"/>
50 <xsl:if test="$namespaces">
51 <sub name="Namespaces" link="namespaces.html">
52 <!-- Generate a flat list of fully qualified namespaces -->
53 <xsl:for-each select="$namespaces">
54 <xsl:sort lang="en" case-order="upper-first" select="name"/>
55 <sub name="{name}" link="{filename}"/>
59 <xsl:if test="tagfile/compound[@kind='class' or @kind='struct' or @kind='union']">
60 <sub name="Classes" link="classes.html">
61 <!-- Select the top-level C++ compounds -->
62 <xsl:apply-templates select="tagfile/compound[not(key('nested-scope', name))]"
64 <xsl:sort lang="en" case-order="upper-first" select="name"/>
65 </xsl:apply-templates>
70 <xsl:apply-templates select="tagfile/compound" mode="keyword-list"/>
75 <xsl:template match="compound" mode="module-list">
76 <xsl:variable name="children" select="subgroup"/>
77 <sub name="{title}" link="{filename}">
78 <!-- Select any subgroup compounds by name -->
79 <xsl:apply-templates select="../compound[@kind='group' and name=$children]"
81 <xsl:sort lang="en" select="title"/>
82 </xsl:apply-templates>
86 <xsl:template match="compound[@kind='namespace' or @kind='class' or @kind='struct' or @kind='union']"
88 <!-- The scope prefix to strip from the name -->
89 <xsl:param name="scope"/>
90 <xsl:variable name="fullname" select="name"/>
91 <xsl:variable name="children" select="namespace|class"/>
92 <sub name="{substring-after($fullname, $scope)}" link="{filename}">
93 <!-- Select any nested C++ compounds by name -->
94 <xsl:apply-templates select="../compound[name=$children]" mode="class-list">
95 <xsl:sort lang="en" case-order="upper-first" select="name"/>
96 <xsl:with-param name="scope" select="concat($fullname, '::')"/>
97 </xsl:apply-templates>
100 <!-- Ignore any other kind of compound -->
101 <xsl:template match="*" mode="class-list"/>
103 <xsl:template match="compound[@kind='namespace']" mode="keyword-list">
104 <!-- Process members, but do not list the namespace itself as a keyword -->
105 <xsl:apply-templates select="member" mode="keyword-list"/>
107 <xsl:template match="compound[@kind='class' or @kind='struct' or @kind='union']"
109 <!-- List the compound type itself as a keyword and process its members -->
110 <keyword type="struct" name="{name}" link="{filename}"/>
111 <xsl:apply-templates select="member" mode="keyword-list"/>
113 <!-- Match leaf compound members -->
114 <xsl:template match="member[@kind='typedef']" mode="keyword-list">
115 <keyword type="typedef" xsl:use-attribute-sets="keyword-member"/>
117 <xsl:template match="member[@kind='function' or @kind='friend']" mode="keyword-list">
118 <keyword type="function" xsl:use-attribute-sets="keyword-member"/>
120 <xsl:template match="member[@kind='enumeration']" mode="keyword-list">
121 <keyword type="enum" xsl:use-attribute-sets="keyword-member"/>
123 <xsl:template match="member[@kind='enumvalue' or @kind='define']" mode="keyword-list">
124 <keyword type="macro" xsl:use-attribute-sets="keyword-member"/>
126 <!-- Ignore unknown keyword types -->
127 <xsl:template match="*" mode="keyword-list"/>
129 <!-- Qualify member name and link anchor -->
130 <xsl:attribute-set name="keyword-member">
131 <xsl:attribute name="name">
132 <xsl:value-of select="concat(../name, '::', name)"/>
134 <xsl:attribute name="link">
135 <xsl:value-of select="concat(anchorfile, '#', anchor)"/>