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"> 4 <!-- 5 Copyright (c) 2009 Daniel Elstner <daniel.kitta@gmail.com> 6 7 XSL transformation from a Doxygen tag file to DevHelp 2 format. 8 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. 13 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. 18 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/>. 21 --> 22 <xsl:strip-space elements="*"/> 23 <xsl:output method="xml" version="1.0" indent="yes" encoding="UTF-8"/> 24 25 <xsl:param name="book_title"/> 26 <xsl:param name="book_name"/> 27 <xsl:param name="book_base"/> 28 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']" 33 use="class"/> 34 35 <xsl:template match="/"> 36 <book title="{$book_title}" name="{$book_name}" base="{$book_base}" 37 link="index.html" version="2" language="c++"> 38 <chapters> 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))]" 44 mode="module-list"> 45 <xsl:sort lang="en" select="title"/> 46 </xsl:apply-templates> 47 </sub> 48 </xsl:if> 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}"/> 56 </xsl:for-each> 57 </sub> 58 </xsl:if> 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))]" 63 mode="class-list"> 64 <xsl:sort lang="en" case-order="upper-first" select="name"/> 65 </xsl:apply-templates> 66 </sub> 67 </xsl:if> 68 </chapters> 69 <functions> 70 <xsl:apply-templates select="tagfile/compound" mode="keyword-list"/> 71 </functions> 72 </book> 73 </xsl:template> 74 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]" 80 mode="module-list"> 81 <xsl:sort lang="en" select="title"/> 82 </xsl:apply-templates> 83 </sub> 84 </xsl:template> 85 86 <xsl:template match="compound[@kind='namespace' or @kind='class' or @kind='struct' or @kind='union']" 87 mode="class-list"> 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> 98 </sub> 99 </xsl:template> 100 <!-- Ignore any other kind of compound --> 101 <xsl:template match="*" mode="class-list"/> 102 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"/> 106 </xsl:template> 107 <xsl:template match="compound[@kind='class' or @kind='struct' or @kind='union']" 108 mode="keyword-list"> 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"/> 112 </xsl:template> 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"/> 116 </xsl:template> 117 <xsl:template match="member[@kind='function' or @kind='friend']" mode="keyword-list"> 118 <keyword type="function" xsl:use-attribute-sets="keyword-member"/> 119 </xsl:template> 120 <xsl:template match="member[@kind='enumeration']" mode="keyword-list"> 121 <keyword type="enum" xsl:use-attribute-sets="keyword-member"/> 122 </xsl:template> 123 <xsl:template match="member[@kind='enumvalue' or @kind='define']" mode="keyword-list"> 124 <keyword type="macro" xsl:use-attribute-sets="keyword-member"/> 125 </xsl:template> 126 <!-- Ignore unknown keyword types --> 127 <xsl:template match="*" mode="keyword-list"/> 128 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)"/> 133 </xsl:attribute> 134 <xsl:attribute name="link"> 135 <xsl:value-of select="concat(anchorfile, '#', anchor)"/> 136 </xsl:attribute> 137 </xsl:attribute-set> 138 139</xsl:stylesheet> 140