1 <xsl:stylesheet xmlns:
xsl=
"http://www.w3.org/1999/XSL/Transform" version=
"1.0">
4 This template changed a XML document that has already been processed by docutils
5 with the filed names template to docbook.
10 <xsl:output method='xml' doctype-system='/home/paul/Documents/data/dtds/docbookx.dtd'
/>
13 <xsl:template match =
"document">
16 <xsl:apply-templates select =
"/document/docinfo/author"/>
18 <xsl:when test='/document/title'
>
19 <xsl:apply-templates select = '/document/title' mode = 'keep'
/>
21 <xsl:when test = '/document/docinfo/title'
>
22 <xsl:apply-templates select = '/document/docinfo/title'
/>
27 <xsl:if test =
"/document/docinfo/revision">
29 <xsl:apply-templates select =
"/document/docinfo/revision"/>
35 <xsl:apply-templates/>
40 <xsl:template match =
"/document/docinfo/author">
42 <xsl:apply-templates/>
46 <xsl:template match =
"/document/docinfo/author/firstname|/document/docinfo/author/first">
48 <xsl:apply-templates/>
53 <xsl:template match =
"/document/docinfo/author/surname">
55 <xsl:apply-templates/>
59 <xsl:template match =
"/document/docinfo/author/address|/document/docinfo/author/email">
61 <xsl:apply-templates/>
65 <xsl:template match =
"/document/docinfo/author/firstname/paragraph|/document/docinfo/author/surname/paragraph|document/docinfo/author/address/paragraph|/document/docinfo/author/first/paragraph|/document/docinfo/author/email/paragraph|/document/docinfo/author/address/pararaph">
66 <xsl:apply-templates/>
70 <xsl:template match =
"/document/docinfo/author/email/paragraph/reference|/document/docinfo/author/address/reference">
71 <xsl:apply-templates/>
74 <xsl:template match =
"/document/docinfo/revision">
76 <xsl:apply-templates/>
80 <xsl:template match =
"revremark/paragraph">
81 <xsl:apply-templates/>
87 <xsl:template match =
"docinfo"/>
88 <xsl:template match =
"/document/title"/>
89 <xsl:template match =
"system_message"/>
90 <xsl:template match =
"literal"/>
91 <xsl:template match =
"substitution_definition"/>
92 <xsl:template match =
"transition"/>
93 <xsl:template match =
"substitution_definition"/>
94 <xsl:template match =
"system_warning"/>
97 <!--Info to get rid of paragraph tags-->
98 <xsl:template match =
"p/paragraph|foreName/paragraph|surname/paragraph">
99 <xsl:apply-templates/>
102 <xsl:template match =
"/document/docinfo/author">
104 <xsl:apply-templates/>
108 <xsl:template match =
"/document/docinfo/revnumber">
110 <xsl:apply-templates/>
114 <xsl:template match =
"/document/docinfo/revision/revnumber/paragraph">
115 <xsl:apply-templates/>
118 <xsl:template match =
"/document/docinfo/revision/date">
120 <xsl:apply-templates/>
125 <xsl:template match =
"document/docinfo/revision/date/paragraph">
126 <xsl:apply-templates/>
129 <xsl:template match =
"/document/docinfo/revision/date_bogus">
130 <xsl:call-template name = 'my-date'
/>
133 <xsl:apply-templates/>
137 <resp>written by
</resp>
143 <xsl:template match =
"/document/docinfo/item">
145 <xsl:apply-templates/>
149 <xsl:template match =
"paragraph">
151 <xsl:when test =
"preceding-sibling::*[1]/self::transition">
154 <xsl:when test = "name(preceding-sibling::*[1])='transition'">
156 <para role=
"transition">
157 <xsl:apply-templates/>
162 <xsl:apply-templates/>
168 <xsl:template match = 'l/paragraph'
>
169 <xsl:apply-templates/>
174 <xsl:template match =
"example[@program]">
176 <xsl:apply-templates/>
179 <xsl:template match =
"example/title/paragraph">
180 <xsl:apply-templates/>
183 <xsl:template match =
"example[@program]/literal_block">
185 <xsl:apply-templates/>
189 <xsl:template match =
"literal_block">
191 <xsl:apply-templates/>
196 <xsl:template match =
"/document/docinfo/title|/document/title" mode = 'keep'
>
198 <xsl:apply-templates/>
202 <xsl:template match =
"section">
203 <xsl:element name =
"sect1">
204 <xsl:attribute name = 'id'
>
205 <xsl:value-of select = '@id'
/>
207 <xsl:apply-templates/>
212 <xsl:template match =
"section/section">
213 <xsl:element name =
"sect2">
214 <xsl:attribute name = 'id'
>
215 <xsl:value-of select = '@id'
/>
217 <xsl:attribute name =
"type">
218 <xsl:value-of select =
"@name"/>
220 <xsl:apply-templates/>
224 <xsl:template match =
"section/section/section">
225 <xsl:element name =
"sect3">
226 <xsl:attribute name = 'id'
>
227 <xsl:value-of select = '@id'
/>
229 <xsl:attribute name =
"type">
230 <xsl:value-of select =
"@name"/>
232 <xsl:apply-templates/>
236 <xsl:template match =
"section/section/section/section">
237 <xsl:element name =
"sect4">
238 <xsl:attribute name = 'id'
>
239 <xsl:value-of select = '@id'
/>
241 <xsl:attribute name =
"type">
242 <xsl:value-of select =
"@name"/>
244 <xsl:apply-templates/>
248 <xsl:template match =
"section/section/section/section/section">
249 <xsl:element name =
"sect5">
250 <xsl:attribute name = 'id'
>
251 <xsl:value-of select = '@id'
/>
253 <xsl:attribute name =
"type">
254 <xsl:value-of select =
"@name"/>
256 <xsl:apply-templates/>
260 <xsl:template match=
"section/title">
262 <xsl:apply-templates/>
266 <xsl:template match = 'reference'
>
267 <xsl:element name =
"ref">
268 <xsl:attribute name =
"target">
269 <xsl:value-of select =
"@refid"/>
271 <xsl:apply-templates/>
275 <xsl:template match = 'target'
>
276 <xsl:element name=
"anchor">
277 <xsl:attribute name =
"id">
278 <xsl:value-of select =
"@id"/>
281 <xsl:apply-templates/>
284 <xsl:template match =
"instant">
287 <xsl:value-of select =
"substring(.,0,11)"/>
289 <xsl:element name =
"time">
290 <xsl:attribute name =
"value">
291 <xsl:value-of select =
"substring(.,12,8)"/>
293 <xsl:attribute name = 'zone'
>
295 <xsl:when test = 'substring(normalize-space(.),
20,
6)'
>
296 <xsl:value-of select = 'substring(normalize-space(.),
20,
6)'
/>
299 <xsl:text>-
05:
00</xsl:text>
303 <xsl:attribute name =
"type">
304 <xsl:text>24hour
</xsl:text>
310 <xsl:template name =
"my-date">
311 <xsl:element name = 'date'
>
312 <xsl:attribute name = 'value'
>
313 <xsl:value-of select =
"substring(normalize-space(.),0,11)"/>
318 <!--This is just and example of how to parse time?-->
319 <xsl:template name =
"my-time">
321 <xsl:value-of select='normalize-space(.)'
/>
323 <xsl:element name = 'date'
>
324 <xsl:attribute name = 'value'
>
325 <xsl:value-of select =
"substring(normalize-space(.),0,11)"/>
327 <xsl:attribute name = 'zone'
>
329 <xsl:when test = 'substring(normalize-space(.),
12,
13)'
>
330 <xsl:value-of select = 'substring(normalize-space(.),
12,
5)'
/>
333 <xsl:text>-
05:
00</xsl:text>
337 <xsl:attribute name =
"type">
338 <xsl:text>24hour
</xsl:text>
342 <xsl:template match = 'body'
>
345 <xsl:apply-templates/>
350 <xsl:template match = 'block_quote'
>
352 <xsl:apply-templates/>
356 <xsl:template match =
"comment">
358 <xsl:value-of select =
"."/>
362 <xsl:template match =
"emphasis">
364 <xsl:apply-templates/>
368 <xsl:template match =
"enumerated_list">
369 <list type=
"ordered">
370 <xsl:apply-templates/>
374 <xsl:template match =
"list_item">
376 <xsl:apply-templates/>
381 <xsl:template match=
"@*|node()">
383 <xsl:apply-templates select=
"@*|node()"/>