0da97ca237d8dc253cb668f77e4ad094302ed92e
[pub/USBasp.git] / LUFA / StudioIntegration / HV1 / lufa_docbook_transform.xsl
1 <?xml version="1.0" encoding="UTF-8"?>
2
3 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
4 <xsl:import href="transform_base.xsl"/>
5
6 <xsl:output method="xml" indent="yes"/>
7
8 <xsl:param name="keyword.namespace" select="'Atmel.Language.C'"/>
9
10 <xsl:template name="generate.book.title">
11 <xsl:text>LUFA Library</xsl:text>
12 </xsl:template>
13
14 <xsl:template name="generate.book.id">
15 <xsl:param name="book.title"/>
16 <xsl:choose>
17 <xsl:when test="@id">
18 <xsl:value-of select="@id"/>
19 </xsl:when>
20 <xsl:otherwise>
21 <xsl:value-of select="translate($book.title, ' ','')"/>
22 </xsl:otherwise>
23 </xsl:choose>
24 </xsl:template>
25
26 <xsl:template match="doxygen">
27 <xsl:variable name="book.title">
28 <xsl:call-template name="generate.book.title"/>
29 </xsl:variable>
30 <xsl:variable name="book.id">
31 <xsl:call-template name="generate.book.id">
32 <xsl:with-param name="book.title" select="$book.title"/>
33 </xsl:call-template>
34 </xsl:variable>
35
36 <book name="{$book.id}">
37 <title>
38 <xsl:value-of select="$book.title"/>
39 </title>
40
41 <xsl:call-template name="generate.top.level.page">
42 <xsl:with-param name="top.level.page" select="compounddef[@kind = 'page' and contains(@id, 'index')]"/>
43 </xsl:call-template>
44
45 <xsl:for-each select="compounddef[@kind = 'page' and not(contains(@id, 'index'))]">
46 <xsl:if test="not(//innerpage[@refid = current()/@id])">
47 <xsl:call-template name="generate.top.level.page">
48 <xsl:with-param name="top.level.page" select="current()"/>
49 </xsl:call-template>
50 </xsl:if>
51 </xsl:for-each>
52 </book>
53 </xsl:template>
54
55 <xsl:template name="generate.top.level.page">
56 <xsl:param name="top.level.page"/>
57
58 <chapter id="{$top.level.page/@id}">
59 <title>
60 <xsl:value-of select="$top.level.page/title"/>
61 </title>
62 <xsl:apply-templates select="$top.level.page/detaileddescription"/>
63
64 <xsl:for-each select="$top.level.page/innerpage">
65 <xsl:apply-templates select="ancestor::*/compounddef[@kind = 'page' and @id = current()/@refid]"/>
66 </xsl:for-each>
67 </chapter>
68 </xsl:template>
69
70 <xsl:template match="compounddef[@kind = 'page']">
71 <section id="{@id}">
72 <title>
73 <xsl:value-of select="title"/>
74 </title>
75 <xsl:apply-templates select="detaileddescription"/>
76
77 <xsl:for-each select="innerpage">
78 <xsl:apply-templates select="ancestor::*/compounddef[@kind = 'page' and @id = current()/@refid]"/>
79 </xsl:for-each>
80 </section>
81 </xsl:template>
82
83 <xsl:template match="linebreak">
84 <xsl:text>&#10;</xsl:text>
85 </xsl:template>
86
87 <xsl:template match="image">
88 <figure>
89 <title>
90 <xsl:value-of select="."/>
91 </title>
92
93 <mediaobject>
94 <imageobject>
95 <imagedata>
96 <xsl:attribute name="fileref">images/<xsl:value-of select="@name"/></xsl:attribute>
97 </imagedata>
98 </imageobject>
99 </mediaobject>
100 </figure>
101 </xsl:template>
102
103 <xsl:template match="detaileddescription">
104 <xsl:apply-templates/>
105 </xsl:template>
106
107 <xsl:template match="sect1 | sect2 | sect3 | sect4 | sect5 | sect6 | sect7 | sect8 | sect9">
108 <section>
109 <xsl:if test="@id">
110 <xsl:attribute name="id">
111 <xsl:value-of select="@id"/>
112 </xsl:attribute>
113 </xsl:if>
114
115 <title>
116 <xsl:value-of select="title"/>
117 </title>
118
119 <xsl:apply-templates/>
120 </section>
121 </xsl:template>
122
123 <xsl:template match="anchor">
124 <xsl:if test="@id">
125 <indexterm id="{@id}"/>
126 </xsl:if>
127 </xsl:template>
128
129 <xsl:template match="compoundname"/>
130
131 <xsl:template match="title"/>
132
133 <xsl:template match="indexterm"/>
134
135 <xsl:template match="indexentry">
136 <xsl:variable name="prim">
137 <xsl:choose>
138 <xsl:when test="contains(primaryie, ',')">
139 <xsl:value-of select="normalize-space(substring-before(primaryie, ','))"/>
140 </xsl:when>
141 <xsl:otherwise>
142 <xsl:value-of select="primaryie"/>
143 </xsl:otherwise>
144 </xsl:choose>
145 </xsl:variable>
146
147 <xsl:variable name="sec">
148 <xsl:choose>
149 <xsl:when test="contains(primaryie, ',')">
150 <xsl:value-of select="normalize-space(substring-after(primaryie, ','))"/>
151 </xsl:when>
152 <xsl:when test="seondariye">
153 <xsl:value-of select="secondaryie"/>
154 </xsl:when>
155 <xsl:otherwise/>
156 </xsl:choose>
157 </xsl:variable>
158
159 <xsl:variable name="tert">
160 <xsl:choose>
161 <xsl:when test="contains(primaryie, ',')">
162 <xsl:choose>
163 <xsl:when test="secondaryie">
164 <xsl:value-of select="secondaryie"/>
165 </xsl:when>
166 </xsl:choose>
167 </xsl:when>
168 <xsl:when test="tertiaryie">
169 <xsl:value-of select="tertiaryie"/>
170 </xsl:when>
171 <xsl:otherwise/>
172 </xsl:choose>
173 </xsl:variable>
174
175 <indexterm>
176 <xsl:if test="@id">
177 <xsl:attribute name="id">
178 <xsl:value-of select="@id"/>
179 </xsl:attribute>
180 </xsl:if>
181 <xsl:if test="$prim">
182 <primary>
183 <xsl:value-of select="$prim"/>
184 </primary>
185 </xsl:if>
186 <xsl:if test="$sec">
187 <secondary>
188 <xsl:value-of select="$sec"/>
189 </secondary>
190 </xsl:if>
191 <xsl:if test="$tert">
192 <tertiary>
193 <xsl:value-of select="$tert"/>
194 </tertiary>
195 </xsl:if>
196 </indexterm>
197 </xsl:template>
198 </xsl:stylesheet>