~ubuntu-branches/ubuntu/karmic/calibre/karmic

« back to all changes in this revision

Viewing changes to src/calibre/ebooks/lrf/rtf/xsl.py

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2009-07-30 12:49:41 UTC
  • mto: This revision was merged to the branch mainline in revision 13.
  • Revision ID: james.westby@ubuntu.com-20090730124941-kviipg9ypwgppulc
Tags: upstream-0.6.3+dfsg
ImportĀ upstreamĀ versionĀ 0.6.3+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#########################################################################
2
 
#                                                                       #
3
 
#                                                                       #
4
 
#   copyright 2002 Paul Henry Tremblay                                  #
5
 
#                                                                       #
6
 
#   This program is distributed in the hope that it will be useful,     #
7
 
#   but WITHOUT ANY WARRANTY; without even the implied warranty of      #
8
 
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU    #
9
 
#   General Public License for more details.                            #
10
 
#                                                                       #
11
 
#   You should have received a copy of the GNU General Public License   #
12
 
#   along with this program; if not, write to the Free Software         #
13
 
#   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA            #
14
 
#   02111-1307 USA                                                      #
15
 
#                                                                       #
16
 
#                                                                       #
17
 
#########################################################################
18
 
 
19
 
xhtml = '''\
20
 
<?xml version="1.0"?>
21
 
<xsl:stylesheet version="1.0" 
22
 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
23
 
    xmlns:html="http://www.w3.org/1999/xhtml"
24
 
    xmlns:rtf="http://rtf2xml.sourceforge.net/"
25
 
    exclude-result-prefixes="rtf"    
26
 
>
27
 
 
28
 
    <xsl:template match = "rtf:para">
29
 
        <xsl:choose>
30
 
            <xsl:when test = "parent::rtf:paragraph-definition[@name='heading 1']|
31
 
                              parent::rtf:paragraph-definition[@name='heading 2']|
32
 
                              parent::rtf:paragraph-definition[@name='heading 3']|
33
 
                              parent::rtf:paragraph-definition[@name='heading 4']|
34
 
                              parent::rtf:paragraph-definition[@name='heading 5']|
35
 
                              parent::rtf:paragraph-definition[@name='heading 6']|
36
 
                              parent::rtf:paragraph-definition[@name='heading 7']|
37
 
                              parent::rtf:paragraph-definition[@name='heading 8']|
38
 
                              parent::rtf:paragraph-definition[@name='heading 9']
39
 
            
40
 
            ">
41
 
                <xsl:variable name="head-number" select="substring(parent::rtf:paragraph-definition/@name, 9)"/>
42
 
                <xsl:element name="h{$head-number}">
43
 
                    <xsl:apply-templates/>
44
 
                </xsl:element>
45
 
            </xsl:when>
46
 
            <xsl:otherwise>
47
 
                <xsl:call-template name = "para"/>
48
 
            </xsl:otherwise>
49
 
        </xsl:choose>
50
 
    </xsl:template>
51
 
 
52
 
    <xsl:template match="rtf:style-group">
53
 
        <xsl:apply-templates/>
54
 
    </xsl:template>
55
 
 
56
 
    <xsl:template match="rtf:paragraph-definition">
57
 
        <xsl:choose>
58
 
            <xsl:when test = "parent::rtf:paragraph-definition[@name='heading 1']|
59
 
                              parent::rtf:paragraph-definition[@name='heading 2']|
60
 
                              parent::rtf:paragraph-definition[@name='heading 3']|
61
 
                              parent::rtf:paragraph-definition[@name='heading 4']|
62
 
                              parent::rtf:paragraph-definition[@name='heading 5']|
63
 
                              parent::rtf:paragraph-definition[@name='heading 6']|
64
 
                              parent::rtf:paragraph-definition[@name='heading 7']|
65
 
                              parent::rtf:paragraph-definition[@name='heading 8']|
66
 
                              parent::rtf:paragraph-definition[@name='heading 9']
67
 
            
68
 
            ">
69
 
                <xsl:apply-templates/>
70
 
            </xsl:when>
71
 
            <xsl:otherwise>
72
 
                <xsl:element name="div">
73
 
                    <xsl:attribute name="class">
74
 
                        <xsl:value-of select="@style-number"/>
75
 
                    </xsl:attribute>
76
 
                    <xsl:apply-templates/>
77
 
                </xsl:element>
78
 
            </xsl:otherwise>
79
 
        </xsl:choose>
80
 
    </xsl:template>
81
 
 
82
 
    <xsl:template name = "para">
83
 
        <xsl:if test = "normalize-space(.) or child::*">
84
 
            <xsl:element name = "p">
85
 
                <xsl:call-template name = "para-content"/>
86
 
            </xsl:element>
87
 
        </xsl:if>
88
 
    </xsl:template>
89
 
 
90
 
    <xsl:template name = "para_off">
91
 
        <xsl:if test = "normalize-space(.) or child::*">
92
 
            <xsl:element name = "p">
93
 
                <xsl:attribute name = "class">
94
 
                    <xsl:value-of select = "../@style-number"/>
95
 
                </xsl:attribute>
96
 
                <xsl:call-template name = "para-content"/>
97
 
            </xsl:element>
98
 
        </xsl:if>
99
 
    </xsl:template>
100
 
 
101
 
 
102
 
    <xsl:template name = "para-content">
103
 
        <xsl:apply-templates/>
104
 
    </xsl:template>
105
 
 
106
 
    <xsl:template name = "para-content_off">
107
 
        <xsl:choose>
108
 
            <xsl:when test = "@italics = 'true' ">
109
 
               <emph rend = "paragraph-emph-italics">
110
 
                    <xsl:apply-templates/>
111
 
               </emph> 
112
 
            </xsl:when>
113
 
            <xsl:when test = "@bold = 'true' ">
114
 
               <emph rend = "paragraph-emph-bold">
115
 
                    <xsl:apply-templates/>
116
 
               </emph> 
117
 
            </xsl:when>
118
 
            <xsl:when test = "@underlined">
119
 
               <emph rend = "paragraph-emph-underlined">
120
 
                    <xsl:apply-templates/>
121
 
               </emph> 
122
 
            </xsl:when>
123
 
            <xsl:when test = "(@strike-through = 'true')
124
 
                or (@double-strike-through = 'true')
125
 
                or (@emboss = 'true')
126
 
                or (@engrave = 'true')
127
 
                or (@small-caps = 'true')
128
 
                or (@shadow = 'true')
129
 
                or (@hidden = 'true')
130
 
                or (@outline = 'true')
131
 
            
132
 
                ">
133
 
               <emph rend = "paragraph-emph">
134
 
                    <xsl:apply-templates/>
135
 
               </emph> 
136
 
            </xsl:when>
137
 
            <xsl:otherwise>
138
 
                <xsl:apply-templates/>
139
 
            </xsl:otherwise>
140
 
        </xsl:choose>
141
 
    </xsl:template>
142
 
    
143
 
    <xsl:template name="make-header">
144
 
        <head>
145
 
            <xsl:element name="meta">
146
 
                <xsl:attribute name="name">
147
 
                    <xsl:text>generator</xsl:text>
148
 
                </xsl:attribute>
149
 
                <xsl:attribute name="content">
150
 
                    <xsl:text>http://rtf2xml.sourceforge.net/</xsl:text>
151
 
                </xsl:attribute>
152
 
            </xsl:element>
153
 
            
154
 
            <xsl:choose>
155
 
                <xsl:when test="/rtf:doc/rtf:preamble/rtf:doc-information">
156
 
                    <xsl:apply-templates select="/rtf:doc/rtf:preamble/rtf:doc-information" mode="header"/>
157
 
                </xsl:when>
158
 
                <xsl:otherwise>
159
 
                    <xsl:call-template name="html-head"/>
160
 
                </xsl:otherwise>
161
 
            </xsl:choose>
162
 
        </head>
163
 
    </xsl:template>
164
 
 
165
 
    <xsl:template match="rtf:doc-information"/>
166
 
 
167
 
    <xsl:template match="rtf:doc-information" mode="header">
168
 
          <link rel="stylesheet" type="text/css" href="styles.css"/>
169
 
          <xsl:if test="not(rtf:title)">
170
 
              <title>unamed</title>
171
 
          </xsl:if>
172
 
        <xsl:apply-templates/>
173
 
    </xsl:template>
174
 
 
175
 
    <xsl:template match="rtf:creation-time|rtf:doc-notes|rtf:author|rtf:revision-time">
176
 
        <xsl:element name="meta">
177
 
            <xsl:attribute name="name">
178
 
                <xsl:value-of select="name(.)"/>
179
 
            </xsl:attribute>
180
 
            <xsl:attribute name="content">
181
 
                <xsl:apply-templates/>
182
 
            </xsl:attribute>
183
 
        </xsl:element>
184
 
    </xsl:template>
185
 
 
186
 
    <xsl:template match="rtf:creation-time|rtf:revision-time">
187
 
        <xsl:element name="meta">
188
 
            <xsl:attribute name="name">
189
 
                <xsl:value-of select="name(.)"/>
190
 
            </xsl:attribute>
191
 
            <xsl:attribute name="content">
192
 
                <xsl:value-of select="@year"/>
193
 
                <xsl:text>-</xsl:text>
194
 
                <xsl:value-of select="@month"/>
195
 
                <xsl:text>-</xsl:text>
196
 
                <xsl:value-of select="@day"/>
197
 
            </xsl:attribute>
198
 
        </xsl:element>
199
 
    </xsl:template>
200
 
 
201
 
    <xsl:template match="rtf:operator|rtf:editing-time|rtf:number-of-pages|rtf:number-of-words|rtf:number-of-characters"/>
202
 
 
203
 
 
204
 
    <xsl:template match="rtf:title">
205
 
        <xsl:element name="title">
206
 
            <xsl:apply-templates/>
207
 
        </xsl:element>
208
 
    </xsl:template>
209
 
 
210
 
 
211
 
    <xsl:template name="html-head">
212
 
        <title>unnamed</title>
213
 
          <link rel="stylesheet" type="text/css" href="styles.css"/>
214
 
    </xsl:template>
215
 
 
216
 
    <xsl:template name="make-css-stylesheet">
217
 
        <xsl:document href="styles.css" method="text">
218
 
            <xsl:for-each select="//rtf:paragraph-definition">
219
 
                <xsl:if test = "generate-id(.) = generate-id(key('style-types', @style-number))">
220
 
                    <xsl:text>div.</xsl:text>
221
 
                    <xsl:value-of select="@style-number"/>
222
 
                    <xsl:text>{</xsl:text>
223
 
                    <xsl:call-template name="parse-styles-attrs"/>
224
 
                    <xsl:text>}&#xA;</xsl:text>
225
 
                </xsl:if>
226
 
            </xsl:for-each>
227
 
            <xsl:text>span.italic{font-style:italic}&#xA;</xsl:text>
228
 
            <xsl:text>span.no-italic{font-style:normal}&#xA;</xsl:text>
229
 
            <xsl:text>span.bold{font-weight:bold}&#xA;</xsl:text>
230
 
            <xsl:text>span.no-bold{font-weight:normal}&#xA;</xsl:text>
231
 
            <xsl:text>span.underline{text-decoration:underline}&#xA;</xsl:text>
232
 
            <xsl:text>span.no-underline{text-decoration:none}&#xA;</xsl:text>
233
 
            <xsl:text>span.italic-bold{font-style:italic;font-weight:bold}&#xA;</xsl:text>
234
 
            <xsl:text>span.italic-underline{font-style:italic;text-decoration:underline}&#xA;</xsl:text>
235
 
            <xsl:text>span.bold-underline{font-weight:bold;text-decoration:underline}&#xA;</xsl:text>
236
 
            <xsl:for-each select="//rtf:inline">
237
 
                <xsl:call-template name="parse-inline"/>
238
 
            </xsl:for-each>
239
 
        </xsl:document>
240
 
    </xsl:template>
241
 
 
242
 
    <xsl:template name="parse-styles-attrs">
243
 
        <xsl:text>position:relative;</xsl:text>
244
 
        <xsl:if test="@space-before">
245
 
            <xsl:text>padding-top:</xsl:text>
246
 
            <xsl:value-of select="@space-before"/>
247
 
            <xsl:text>pt;</xsl:text>
248
 
        </xsl:if>
249
 
        <xsl:if test="@space-after">
250
 
            <xsl:text>padding-bottom:</xsl:text>
251
 
            <xsl:value-of select="@space-after"/>
252
 
            <xsl:text>pt;</xsl:text>
253
 
        </xsl:if>
254
 
        <xsl:if test="@left-indent">
255
 
            <xsl:text>padding-left:</xsl:text>
256
 
            <xsl:value-of select="@left-indent"/>
257
 
            <xsl:text>pt;</xsl:text>
258
 
        </xsl:if>
259
 
        <xsl:if test="@right-indent">
260
 
            <xsl:text>padding-right:</xsl:text>
261
 
            <xsl:value-of select="@right-indent"/>
262
 
            <xsl:text>pt;</xsl:text>
263
 
        </xsl:if>
264
 
        <xsl:if test="@first-line-indent">
265
 
            <xsl:text>text-indent:</xsl:text>
266
 
            <xsl:value-of select="@first-line-indent"/>
267
 
            <xsl:text>pt;</xsl:text>
268
 
        </xsl:if>
269
 
        <xsl:if test="@bold='true'">
270
 
            <xsl:text>font-weight:</xsl:text>
271
 
            <xsl:value-of select="'bold'"/>
272
 
            <xsl:text>;</xsl:text>
273
 
        </xsl:if>
274
 
        <xsl:if test="@italics='true'">
275
 
            <xsl:text>font-style:</xsl:text>
276
 
            <xsl:value-of select="'italic'"/>
277
 
            <xsl:text>;</xsl:text>
278
 
        </xsl:if>
279
 
        <xsl:if test="@underline and @underline != 'false'">
280
 
            <xsl:text>text-decoration:underline</xsl:text>
281
 
            <xsl:text>;</xsl:text>
282
 
        </xsl:if>
283
 
        <xsl:if test="@line-spacing">
284
 
            <xsl:text>line-height:</xsl:text>
285
 
            <xsl:value-of select="@line-height"/>
286
 
            <xsl:text>pt;</xsl:text>
287
 
        </xsl:if>
288
 
    </xsl:template>
289
 
 
290
 
    <xsl:template name="parse-inline">
291
 
        <xsl:variable name="num-attrs" select="count(@*)"/>
292
 
        <xsl:choose>
293
 
            <xsl:when test="$num-attrs = 1 and @italics"/>
294
 
            <xsl:when test="$num-attrs = 1 and @bold"/>
295
 
            <xsl:when test="$num-attrs = 1 and @underline"/>
296
 
            <xsl:when test="$num-attrs = 2 and @italics and @bold"/>
297
 
            <xsl:when test="$num-attrs = 2 and @italcs and @underline"/>
298
 
            <xsl:when test="$num-attrs = 2 and @bold and @underline"/>
299
 
            <xsl:otherwise>
300
 
                <xsl:text>span.</xsl:text>
301
 
                <xsl:value-of select="generate-id(.)"/>
302
 
                <xsl:text>{</xsl:text>
303
 
                <xsl:if test="@italics = 'true'">
304
 
                    <xsl:text>font-style:italic;</xsl:text>
305
 
                </xsl:if>
306
 
                <xsl:if test="@italics = 'false'">
307
 
                    <xsl:text>font-style:normal;</xsl:text>
308
 
                </xsl:if>
309
 
                <xsl:if test="@bold = 'true'">
310
 
                    <xsl:text>font-weight:bold;</xsl:text>
311
 
                </xsl:if>
312
 
                <xsl:if test="@bold = 'false'">
313
 
                    <xsl:text>font-weight:normal;</xsl:text>
314
 
                </xsl:if>
315
 
                <xsl:if test="@underline and @underline != 'false'">
316
 
                    <xsl:text>text-decoration:underline;</xsl:text>
317
 
                </xsl:if>
318
 
                <xsl:if test="@underline= 'false'">
319
 
                    <xsl:text>text-decoration:none;</xsl:text>
320
 
                </xsl:if>
321
 
                <xsl:if test="@strike-through = 'true'">
322
 
                    <xsl:text>text-decoration:line-through;</xsl:text>
323
 
                </xsl:if>
324
 
                <xsl:if test="@strike-through = 'false'">
325
 
                    <xsl:text>text-decoration:none;</xsl:text>
326
 
                </xsl:if>
327
 
                <xsl:if test="@font-size">
328
 
                    <xsl:text>font-size:</xsl:text>
329
 
                        <xsl:value-of select="@font-size"/>
330
 
                        <xsl:text>pt;</xsl:text>
331
 
                </xsl:if>
332
 
                <xsl:text>}</xsl:text>
333
 
            </xsl:otherwise>
334
 
        </xsl:choose>
335
 
    </xsl:template>
336
 
    
337
 
    <xsl:template match="rtf:inline">
338
 
        <xsl:variable name="num-attrs" select="count(@*)"/>
339
 
        <xsl:choose>
340
 
            <xsl:when test="@footnote-marker">
341
 
                <xsl:text>[</xsl:text>
342
 
                <xsl:value-of select="count(preceding::rtf:footnote) + 1"/>
343
 
                <xsl:text>]</xsl:text>
344
 
            </xsl:when>
345
 
            <xsl:otherwise>
346
 
                <xsl:element name="span">
347
 
                    <xsl:attribute name="class">
348
 
                        <xsl:choose>
349
 
                            <xsl:when test="$num-attrs=1 and @italics='true'">
350
 
                                <xsl:text>italic</xsl:text>
351
 
                            </xsl:when>
352
 
                            <xsl:when test="$num-attrs=1 and @italics='false'">
353
 
                                <xsl:text>no-italic</xsl:text>
354
 
                            </xsl:when>
355
 
                            <xsl:when test="$num-attrs=1 and @bold='true'">
356
 
                                <xsl:text>bold</xsl:text>
357
 
                            </xsl:when>
358
 
                            <xsl:when test="$num-attrs=1 and @bold='true'">
359
 
                                <xsl:text>bold</xsl:text>
360
 
                            </xsl:when>
361
 
                            <xsl:when test="$num-attrs=1 and @bold='false'">
362
 
                                <xsl:text>no-bold</xsl:text>
363
 
                            </xsl:when>
364
 
                            <xsl:when test="$num-attrs=1 and @underlined">
365
 
                                <xsl:choose>
366
 
                                    <xsl:when test="not(@underlined='false')">
367
 
                                        <xsl:text>underline</xsl:text>
368
 
                                    </xsl:when>
369
 
                                    <xsl:otherwise>
370
 
                                        <xsl:text>no-underline</xsl:text>
371
 
                                    </xsl:otherwise>
372
 
                                </xsl:choose>
373
 
                            </xsl:when>
374
 
                            <xsl:when test="$num-attrs=2 and @bold='true' and @italics='true'">
375
 
                                <xsl:text>italic-bold</xsl:text>
376
 
                            </xsl:when>
377
 
                            <xsl:when test="$num-attrs=2 and @italics='true' and @underline and @underline != 'false'">
378
 
                                <xsl:text>italic-underline</xsl:text>
379
 
                            </xsl:when>
380
 
                            <xsl:when test="$num-attrs=2 and @bold='true' and @underline and @underline != 'false'">
381
 
                                <xsl:text>bold-underline</xsl:text>
382
 
                            </xsl:when>
383
 
                            <xsl:otherwise>
384
 
                                <xsl:value-of select="generate-id(.)"/>
385
 
                            </xsl:otherwise>
386
 
                        </xsl:choose>
387
 
                    </xsl:attribute>
388
 
                    <xsl:apply-templates/>
389
 
                </xsl:element>
390
 
                
391
 
            </xsl:otherwise>
392
 
        </xsl:choose>
393
 
    </xsl:template>
394
 
 
395
 
    <xsl:template match="rtf:footnote"/>
396
 
 
397
 
    <xsl:template match="rtf:footnote" mode="bottom">
398
 
        <xsl:element name="div">
399
 
            <xsl:attribute name="class">
400
 
                <xsl:text>footnote</xsl:text>
401
 
            </xsl:attribute>
402
 
            <xsl:apply-templates/>
403
 
        </xsl:element>
404
 
        
405
 
    </xsl:template>
406
 
    
407
 
       <xsl:template match="rtf:list[@list-type='unordered']">
408
 
       <xsl:element name="ul">
409
 
           <xsl:apply-templates/>
410
 
       </xsl:element>
411
 
   </xsl:template>
412
 
 
413
 
   <xsl:template match="rtf:list[@list-type='ordered']">
414
 
       <xsl:element name="ol">
415
 
           <xsl:apply-templates/>
416
 
       </xsl:element>
417
 
   </xsl:template>
418
 
 
419
 
   <xsl:template match="rtf:item">
420
 
       <xsl:element name="li">
421
 
           <xsl:apply-templates/>
422
 
       </xsl:element>
423
 
   </xsl:template>
424
 
 
425
 
   <xsl:template match="rtf:item/rtf:style-group/rtf:paragraph-definition/rtf:para" priority="2">
426
 
       <xsl:apply-templates/>
427
 
   </xsl:template>
428
 
 
429
 
       <xsl:template match="rtf:table">
430
 
        <xsl:element name="table">
431
 
            <xsl:attribute name="id">
432
 
                <xsl:value-of select="generate-id(.)"/>
433
 
            </xsl:attribute>
434
 
            <xsl:apply-templates/>
435
 
        </xsl:element>
436
 
    </xsl:template>
437
 
 
438
 
    <xsl:template match="rtf:row">
439
 
        <xsl:element name="row">
440
 
            <xsl:apply-templates/>
441
 
        </xsl:element>
442
 
    </xsl:template>
443
 
 
444
 
    <xsl:template match="rtf:cell">
445
 
        <xsl:element name="cell">
446
 
            <xsl:apply-templates/>
447
 
        </xsl:element>
448
 
    </xsl:template>
449
 
 
450
 
    <!--
451
 
    <xsl:include href="blocks.xsl"/>
452
 
    <xsl:include href="fields.xsl"/>
453
 
    -->
454
 
 
455
 
 
456
 
 
457
 
 
458
 
    <xsl:output method = "xml"/>
459
 
 
460
 
    <xsl:key name="style-types" match="rtf:paragraph-definition" use="@style-number"/>
461
 
 
462
 
 
463
 
    <xsl:variable name = "delete-list-text">true</xsl:variable>
464
 
    <xsl:variable name = "delete-field-blocks">true</xsl:variable>
465
 
    <xsl:variable name = "delete-annotation">false</xsl:variable>
466
 
 
467
 
    <xsl:template match="/">
468
 
        <xsl:call-template name="make-css-stylesheet"/>
469
 
        <html>
470
 
            <xsl:call-template name="make-header"/>
471
 
            <xsl:apply-templates/>
472
 
        </html>
473
 
    </xsl:template>
474
 
 
475
 
    <xsl:template match="rtf:doc">
476
 
        <xsl:apply-templates/>
477
 
    </xsl:template>
478
 
 
479
 
    <xsl:template match="rtf:preamble">
480
 
        <xsl:apply-templates/>
481
 
    </xsl:template>
482
 
    
483
 
    <xsl:template match="rtf:page-break">
484
 
        <xsl:element name="br">
485
 
            <xsl:attribute name="style">page-break-after:always</xsl:attribute>
486
 
        </xsl:element>
487
 
    </xsl:template>
488
 
    
489
 
    <xsl:template match="rtf:rtf-definition|rtf:font-table|rtf:color-table|rtf:style-table|rtf:page-definition|rtf:list-table|rtf:override-table|rtf:override-list|rtf:list-text"/>
490
 
 
491
 
    <xsl:template match="rtf:body">
492
 
        <xsl:element name="body">
493
 
            <xsl:apply-templates/>
494
 
            <xsl:if test = "//rtf:footnote">
495
 
                <hr/>
496
 
            </xsl:if>
497
 
            <xsl:for-each select="//rtf:footnote">
498
 
                <xsl:apply-templates select="." mode="bottom"/>
499
 
            </xsl:for-each>
500
 
        </xsl:element>
501
 
    </xsl:template>
502
 
 
503
 
    <xsl:template match="rtf:section">
504
 
        <xsl:element name="div">
505
 
            <xsl:apply-templates/>
506
 
        </xsl:element>
507
 
    </xsl:template>
508
 
    
509
 
    <xsl:template match = "rtf:field-block">
510
 
      <xsl:apply-templates/>
511
 
    </xsl:template>
512
 
    
513
 
    <xsl:template match = "rtf:field[@type='hyperlink']">
514
 
        <xsl:element name ="a">
515
 
            <xsl:attribute name = "href">
516
 
               <xsl:value-of select = "@link"/>
517
 
            </xsl:attribute>
518
 
            <xsl:apply-templates/>
519
 
        </xsl:element>
520
 
    </xsl:template>
521
 
 
522
 
    <xsl:template match = "rtf:field">
523
 
        <xsl:apply-templates/>
524
 
    </xsl:template>
525
 
    
526
 
    <xsl:template match="rtf:pict" />
527
 
    
528
 
    <xsl:template match="*">
529
 
        <xsl:message>
530
 
            <xsl:text>no match for element: "</xsl:text>
531
 
            <xsl:value-of select="name(.)"/>
532
 
            <xsl:text>" &#xA;</xsl:text>
533
 
        </xsl:message>
534
 
        <xsl:apply-templates/>
535
 
    </xsl:template>
536
 
    
537
 
</xsl:stylesheet>
538
 
'''
 
 
b'\\ No newline at end of file'