~todd-deshane/openstack-manuals/working

« back to all changes in this revision

Viewing changes to doc/build/docbook-xsl-1.76.1/slides/keynote/xsltsl/markup.xsl

  • Committer: Anne Gentle
  • Date: 2011-04-04 17:54:52 UTC
  • Revision ID: anne@openstack.org-20110404175452-gtth3hfrniqhpp5o
Switching from Ant builds to Maven, still working out kinks but should be functional

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<xsl:stylesheet version='1.0'
2
 
  xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
3
 
  xmlns:doc='http://xsltsl.org/xsl/documentation/1.0'
4
 
  xmlns:markup='http://xsltsl.org/markup'
5
 
  xmlns:str='http://xsltsl.org/string'
6
 
  extension-element-prefixes='doc markup str'>
7
 
 
8
 
  <doc:reference xmlns=''>
9
 
    <referenceinfo>
10
 
      <releaseinfo role="meta">
11
 
        $Id: markup.xsl 3991 2004-11-10 06:51:55Z balls $
12
 
      </releaseinfo>
13
 
      <author>
14
 
        <surname>Ball</surname>
15
 
        <firstname>Steve</firstname>
16
 
      </author>
17
 
      <copyright>
18
 
        <year>2003</year>
19
 
        <year>2001</year>
20
 
        <holder>Steve Ball</holder>
21
 
      </copyright>
22
 
    </referenceinfo>
23
 
 
24
 
    <title>XML Markup Templates</title>
25
 
 
26
 
    <partintro>
27
 
      <section>
28
 
        <title>Introduction</title>
29
 
 
30
 
        <para>This stylesheet module provides functions for generating literal XML markup.</para>
31
 
 
32
 
      </section>
33
 
    </partintro>
34
 
 
35
 
  </doc:reference>
36
 
 
37
 
  <doc:template name="markup:xml-declaration" xmlns="">
38
 
    <refpurpose>Create an XML Declaration</refpurpose>
39
 
 
40
 
    <refdescription>
41
 
      <para>This template returns an XML Declaration.  Although the XSLT standard provides control over the generation of the XML Declaration, this template may be useful in circumstances where the values must be computed at runtime.</para>
42
 
    </refdescription>
43
 
 
44
 
    <refparameter>
45
 
      <variablelist>
46
 
        <varlistentry>
47
 
          <term>version</term>
48
 
          <listitem>
49
 
            <para>Version number.</para>
50
 
          </listitem>
51
 
        </varlistentry>
52
 
        <varlistentry>
53
 
          <term>standalone</term>
54
 
          <listitem>
55
 
            <para>Standalone indication.  Must be value "yes" or "no".</para>
56
 
          </listitem>
57
 
        </varlistentry>
58
 
        <varlistentry>
59
 
          <term>encoding</term>
60
 
          <listitem>
61
 
            <para>Character encoding.</para>
62
 
          </listitem>
63
 
        </varlistentry>
64
 
      </variablelist>
65
 
    </refparameter>
66
 
 
67
 
    <refreturn>
68
 
      <para>Returns an XML Declaration as a string.</para>
69
 
    </refreturn>
70
 
  </doc:template>
71
 
 
72
 
  <xsl:template name='markup:xml-declaration'>
73
 
    <xsl:param name='version' select="'1.0'"/>
74
 
    <xsl:param name='standalone'/>
75
 
    <xsl:param name='encoding'/>
76
 
 
77
 
    <xsl:text disable-output-escaping='yes'>&lt;?xml version="</xsl:text>
78
 
    <xsl:copy-of select="$version"/>
79
 
    <xsl:text>"</xsl:text>
80
 
 
81
 
    <xsl:choose>
82
 
      <xsl:when test="string-length($standalone) = 0"/>
83
 
      <xsl:when test='$standalone = "yes" or $standalone = "no"'>
84
 
        <xsl:text> standalone="</xsl:text>
85
 
        <xsl:copy-of select="$standalone"/>
86
 
        <xsl:text>"</xsl:text>
87
 
      </xsl:when>
88
 
      <xsl:otherwise>
89
 
        <xsl:message terminate="yes">invalid value "<xsl:value-of select="$standalone"/>" for standalone attribute</xsl:message>
90
 
      </xsl:otherwise>
91
 
    </xsl:choose>
92
 
 
93
 
    <xsl:if test='string-length($encoding) &gt; 0'>
94
 
      <xsl:text> encoding="</xsl:text>
95
 
      <xsl:copy-of select='$encoding'/>
96
 
      <xsl:text>"</xsl:text>
97
 
    </xsl:if>
98
 
 
99
 
    <xsl:text disable-output-escaping='yes'>?&gt;
100
 
</xsl:text>
101
 
  </xsl:template>
102
 
 
103
 
  <doc:template name="markup:doctype-declaration" xmlns="">
104
 
    <refpurpose>Create a Document Type Declaration</refpurpose>
105
 
 
106
 
    <refdescription>
107
 
      <para>This template returns a Document Type Declaration.  Although the XSLT standard provides control over the generation of a Document Type Declaration, this template may be useful in circumstances where the values for the identifiers or the internal subset must be computed at runtime.</para>
108
 
    </refdescription>
109
 
 
110
 
    <refparameter>
111
 
      <variablelist>
112
 
        <varlistentry>
113
 
          <term>docel</term>
114
 
          <listitem>
115
 
            <para>The name of the document element.</para>
116
 
          </listitem>
117
 
        </varlistentry>
118
 
        <varlistentry>
119
 
          <term>publicid</term>
120
 
          <listitem>
121
 
            <para>The public identifier for the external DTD subset.</para>
122
 
          </listitem>
123
 
        </varlistentry>
124
 
        <varlistentry>
125
 
          <term>systemid</term>
126
 
          <listitem>
127
 
            <para>The system identifier for the external DTD subset.</para>
128
 
          </listitem>
129
 
        </varlistentry>
130
 
        <varlistentry>
131
 
          <term>internaldtd</term>
132
 
          <listitem>
133
 
            <para>The internal DTD subset.</para>
134
 
          </listitem>
135
 
        </varlistentry>
136
 
      </variablelist>
137
 
    </refparameter>
138
 
 
139
 
    <refreturn>
140
 
      <para>Returns a Document Type Declaration as a string.</para>
141
 
    </refreturn>
142
 
  </doc:template>
143
 
 
144
 
  <xsl:template name='markup:doctype-declaration'>
145
 
    <xsl:param name='docel'/>
146
 
    <xsl:param name='publicid'/>
147
 
    <xsl:param name='systemid'/>
148
 
    <xsl:param name='internaldtd'/>
149
 
 
150
 
    <xsl:if test='string-length($docel) = 0'>
151
 
      <xsl:message terminate='yes'>No document element specified</xsl:message>
152
 
    </xsl:if>
153
 
 
154
 
    <xsl:text disable-output-escaping='yes'>&lt;!DOCTYPE </xsl:text>
155
 
    <xsl:copy-of select="$docel"/>
156
 
 
157
 
    <xsl:call-template name='markup:external-identifier'>
158
 
      <xsl:with-param name='publicid' select='$publicid'/>
159
 
      <xsl:with-param name='systemid' select='$systemid'/>
160
 
      <xsl:with-param name='leading-space' select='true()'/>
161
 
    </xsl:call-template>
162
 
 
163
 
    <xsl:if test='string-length($internaldtd) &gt; 0'>
164
 
      <xsl:text> [</xsl:text>
165
 
      <xsl:copy-of select='$internaldtd'/>
166
 
      <xsl:text>]</xsl:text>
167
 
    </xsl:if>
168
 
 
169
 
    <xsl:text disable-output-escaping='yes'>&gt;
170
 
</xsl:text>
171
 
  </xsl:template>
172
 
 
173
 
  <doc:template name="markup:element-declaration" xmlns="">
174
 
    <refpurpose>Create an Element Declaration</refpurpose>
175
 
 
176
 
    <refdescription>
177
 
      <para>This template returns an element declaration..</para>
178
 
    </refdescription>
179
 
 
180
 
    <refparameter>
181
 
      <variablelist>
182
 
        <varlistentry>
183
 
          <term>type</term>
184
 
          <listitem>
185
 
            <para>The element type.</para>
186
 
          </listitem>
187
 
        </varlistentry>
188
 
        <varlistentry>
189
 
          <term>content-spec</term>
190
 
          <listitem>
191
 
            <para>The content specification.</para>
192
 
          </listitem>
193
 
        </varlistentry>
194
 
      </variablelist>
195
 
    </refparameter>
196
 
 
197
 
    <refreturn>
198
 
      <para>Returns an element declaration as a string.</para>
199
 
    </refreturn>
200
 
  </doc:template>
201
 
 
202
 
  <xsl:template name='markup:element-declaration'>
203
 
    <xsl:param name='type'/>
204
 
    <xsl:param name='content-spec' select="'ANY'"/>
205
 
 
206
 
    <xsl:if test='string-length($type) = 0'>
207
 
      <xsl:message terminate='yes'>element type must be specified</xsl:message>
208
 
    </xsl:if>
209
 
    <xsl:if test='string-length($content-spec) = 0'>
210
 
      <xsl:message terminate='yes'>content specification must be specified</xsl:message>
211
 
    </xsl:if>
212
 
 
213
 
    <xsl:text disable-output-escaping='yes'>&lt;!ELEMENT </xsl:text>
214
 
    <xsl:copy-of select='$type'/>
215
 
    <xsl:text> </xsl:text>
216
 
    <xsl:copy-of select='$content-spec'/>
217
 
    <xsl:text disable-output-escaping='yes'>&gt;</xsl:text>
218
 
  </xsl:template>
219
 
 
220
 
  <doc:template name="markup:attlist-declaration" xmlns="">
221
 
    <refpurpose>Create an Attribute List Declaration</refpurpose>
222
 
 
223
 
    <refdescription>
224
 
      <para>This template returns an attribute list declaration.</para>
225
 
    </refdescription>
226
 
 
227
 
    <refparameter>
228
 
      <variablelist>
229
 
        <varlistentry>
230
 
          <term>type</term>
231
 
          <listitem>
232
 
            <para>The element type.</para>
233
 
          </listitem>
234
 
        </varlistentry>
235
 
        <varlistentry>
236
 
          <term>attr-defns</term>
237
 
          <listitem>
238
 
            <para>Attribute definitions.</para>
239
 
          </listitem>
240
 
        </varlistentry>
241
 
      </variablelist>
242
 
    </refparameter>
243
 
 
244
 
    <refreturn>
245
 
      <para>Returns an attribute list declaration as a string.</para>
246
 
    </refreturn>
247
 
  </doc:template>
248
 
 
249
 
  <xsl:template name='markup:attlist-declaration'>
250
 
    <xsl:param name='type'/>
251
 
    <xsl:param name='attr-defns'/>
252
 
 
253
 
    <xsl:if test='string-length($type) = 0'>
254
 
      <xsl:message terminate='yes'>element type must be specified</xsl:message>
255
 
    </xsl:if>
256
 
 
257
 
    <xsl:text disable-output-escaping='yes'>&lt;!ATTLIST </xsl:text>
258
 
    <xsl:copy-of select='$type'/>
259
 
    <xsl:text> </xsl:text>
260
 
    <xsl:copy-of select='$attr-defns'/>
261
 
    <xsl:text disable-output-escaping='yes'>&gt;</xsl:text>
262
 
  </xsl:template>
263
 
 
264
 
  <doc:template name="markup:attribute-definition" xmlns="">
265
 
    <refpurpose>Create an Attribute Definition</refpurpose>
266
 
 
267
 
    <refdescription>
268
 
      <para>This template returns an attribute definition.</para>
269
 
    </refdescription>
270
 
 
271
 
    <refparameter>
272
 
      <variablelist>
273
 
        <varlistentry>
274
 
          <term>name</term>
275
 
          <listitem>
276
 
            <para>The attribute name.</para>
277
 
          </listitem>
278
 
        </varlistentry>
279
 
        <varlistentry>
280
 
          <term>type</term>
281
 
          <listitem>
282
 
            <para>The attribute type.</para>
283
 
          </listitem>
284
 
        </varlistentry>
285
 
        <varlistentry>
286
 
          <term>default</term>
287
 
          <listitem>
288
 
            <para>The attribute default.</para>
289
 
          </listitem>
290
 
        </varlistentry>
291
 
      </variablelist>
292
 
    </refparameter>
293
 
 
294
 
    <refreturn>
295
 
      <para>Returns an attribute definition as a string.</para>
296
 
    </refreturn>
297
 
  </doc:template>
298
 
 
299
 
  <xsl:template name='markup:attribute-definition'>
300
 
    <xsl:param name='name'/>
301
 
    <xsl:param name='type'/>
302
 
    <xsl:param name='default'/>
303
 
 
304
 
    <xsl:if test='string-length($name) = 0'>
305
 
      <xsl:message terminate='yes'>attribute name must be specified</xsl:message>
306
 
    </xsl:if>
307
 
    <xsl:if test='string-length($type) = 0'>
308
 
      <xsl:message terminate='yes'>attribute type must be specified</xsl:message>
309
 
    </xsl:if>
310
 
    <xsl:if test='string-length($default) = 0'>
311
 
      <xsl:message terminate='yes'>attribute default must be specified</xsl:message>
312
 
    </xsl:if>
313
 
 
314
 
    <xsl:text> </xsl:text>
315
 
    <xsl:copy-of select='$name'/>
316
 
    <xsl:text> </xsl:text>
317
 
    <xsl:copy-of select='$type'/>
318
 
    <xsl:text> </xsl:text>
319
 
    <xsl:copy-of select='$default'/>
320
 
  </xsl:template>
321
 
 
322
 
  <doc:template name="markup:entity-declaration" xmlns="">
323
 
    <refpurpose>Create an Entity Declaration</refpurpose>
324
 
 
325
 
    <refdescription>
326
 
      <para>This template returns an entity declaration.</para>
327
 
      <para>If the 'text' parameter is given a value, then an internal entity is created.  If either the 'publicid' or 'systemid' parameters are given a value then an external entity is created.  It is an error for the 'text' parameter to have value as well as the 'publicid', 'systemid' or 'notation' parameters.</para>
328
 
    </refdescription>
329
 
 
330
 
    <refparameter>
331
 
      <variablelist>
332
 
        <varlistentry>
333
 
          <term>name</term>
334
 
          <listitem>
335
 
            <para>The entity name.</para>
336
 
          </listitem>
337
 
        </varlistentry>
338
 
        <varlistentry>
339
 
          <term>parameter</term>
340
 
          <listitem>
341
 
            <para>Boolean value to determine whether a parameter entity is created.  Default is 'false()'.</para>
342
 
          </listitem>
343
 
        </varlistentry>
344
 
        <varlistentry>
345
 
          <term>text</term>
346
 
          <listitem>
347
 
            <para>The replacement text.  Must be a string.</para>
348
 
          </listitem>
349
 
        </varlistentry>
350
 
        <varlistentry>
351
 
          <term>nodes</term>
352
 
          <listitem>
353
 
            <para>The replacement text as a nodeset.  The nodeset is formatted as XML using the as-xml template.  If both text and nodes are specified then nodes takes precedence.</para>
354
 
          </listitem>
355
 
        </varlistentry>
356
 
        <varlistentry>
357
 
          <term>publicid</term>
358
 
          <listitem>
359
 
            <para>The public identifier for an external entity.</para>
360
 
          </listitem>
361
 
        </varlistentry>
362
 
        <varlistentry>
363
 
          <term>systemid</term>
364
 
          <listitem>
365
 
            <para>The system identifier for an external entity.</para>
366
 
          </listitem>
367
 
        </varlistentry>
368
 
        <varlistentry>
369
 
          <term>notation</term>
370
 
          <listitem>
371
 
            <para>The notation for an external entity.</para>
372
 
          </listitem>
373
 
        </varlistentry>
374
 
      </variablelist>
375
 
    </refparameter>
376
 
 
377
 
    <refreturn>
378
 
      <para>Returns an entity declaration as a string.</para>
379
 
    </refreturn>
380
 
  </doc:template>
381
 
 
382
 
  <xsl:template name='markup:entity-declaration'>
383
 
    <xsl:param name='name'/>
384
 
    <xsl:param name='parameter' select='false()'/>
385
 
    <xsl:param name='text'/>
386
 
    <xsl:param name='nodes'/>
387
 
    <xsl:param name='publicid'/>
388
 
    <xsl:param name='systemid'/>
389
 
    <xsl:param name='notation'/>
390
 
 
391
 
    <xsl:if test='string-length($name) = 0'>
392
 
      <xsl:message terminate='yes'>entity name must be specified</xsl:message>
393
 
    </xsl:if>
394
 
    <xsl:if test='string-length($text) &gt; 0 and 
395
 
                  (string-length($publicid) &gt; 0 or
396
 
                   string-length($systemid) &gt; 0 or
397
 
                   string-length($notation) &gt; 0)'>
398
 
      <xsl:message terminate='yes'>both replacement text and external identifier specified</xsl:message>
399
 
    </xsl:if>
400
 
 
401
 
    <xsl:text disable-output-escaping='yes'>&lt;!ENTITY </xsl:text>
402
 
    <xsl:copy-of select='$name'/>
403
 
    <xsl:text> </xsl:text>
404
 
    <xsl:if test="$parameter">
405
 
      <xsl:text>% </xsl:text>
406
 
    </xsl:if>
407
 
 
408
 
    <xsl:choose>
409
 
      <xsl:when test="$nodes">
410
 
        <xsl:call-template name='markup:quote-value'>
411
 
          <xsl:with-param name='value'>
412
 
            <xsl:call-template name="markup:as-xml">
413
 
              <xsl:with-param name="nodes" select="$nodes"/>
414
 
            </xsl:call-template>
415
 
          </xsl:with-param>
416
 
        </xsl:call-template>
417
 
      </xsl:when>
418
 
      <xsl:when test='$text'>
419
 
        <xsl:call-template name='markup:quote-value'>
420
 
          <xsl:with-param name='value' select='$text'/>
421
 
        </xsl:call-template>
422
 
      </xsl:when>
423
 
      <xsl:otherwise>
424
 
        <xsl:call-template name='markup:external-identifier'>
425
 
          <xsl:with-param name='publicid' select='$publicid'/>
426
 
          <xsl:with-param name='systemid' select='$systemid'/>
427
 
        </xsl:call-template>
428
 
      </xsl:otherwise>
429
 
    </xsl:choose>
430
 
 
431
 
    <xsl:if test='$notation'>
432
 
      <xsl:text> NDATA "</xsl:text>
433
 
      <xsl:copy-of select='$notation'/>
434
 
      <xsl:text>"</xsl:text>
435
 
    </xsl:if>
436
 
 
437
 
    <xsl:text disable-output-escaping='yes'>&gt;</xsl:text>
438
 
  </xsl:template>
439
 
 
440
 
  <doc:template name="markup:quote-value" xmlns="">
441
 
    <refpurpose>Quote an Attribute Value</refpurpose>
442
 
 
443
 
    <refdescription>
444
 
      <para>This template returns a quoted value.</para>
445
 
    </refdescription>
446
 
 
447
 
    <refparameter>
448
 
      <variablelist>
449
 
        <varlistentry>
450
 
          <term>value</term>
451
 
          <listitem>
452
 
            <para>The value to quote.</para>
453
 
          </listitem>
454
 
        </varlistentry>
455
 
      </variablelist>
456
 
    </refparameter>
457
 
 
458
 
    <refreturn>
459
 
      <para>Returns a quote value as a string.</para>
460
 
    </refreturn>
461
 
  </doc:template>
462
 
 
463
 
  <xsl:template name='markup:quote-value'>
464
 
    <xsl:param name='value'/>
465
 
 
466
 
    <xsl:variable name="quoted">
467
 
      <xsl:call-template name='markup:quote-value-aux'>
468
 
        <xsl:with-param name='value' select='$value'/>
469
 
      </xsl:call-template>
470
 
    </xsl:variable>
471
 
 
472
 
    <xsl:choose>
473
 
      <xsl:when test="contains($value, '&lt;')">
474
 
        <xsl:call-template name='str:subst'>
475
 
          <xsl:with-param name='text' select='$quoted'/>
476
 
          <xsl:with-param name='replace'>&lt;</xsl:with-param>
477
 
          <xsl:with-param name='with'>
478
 
            <xsl:text disable-output-escaping='yes'>&amp;lt;</xsl:text>
479
 
          </xsl:with-param>
480
 
        </xsl:call-template>
481
 
      </xsl:when>
482
 
      <xsl:otherwise>
483
 
        <xsl:copy-of select='$quoted'/>
484
 
      </xsl:otherwise>
485
 
    </xsl:choose>
486
 
  </xsl:template>
487
 
 
488
 
  <xsl:template name='markup:quote-value-aux'>
489
 
    <xsl:param name='value'/>
490
 
 
491
 
    <!-- Quoting hell! -->
492
 
    <xsl:variable name="quot">&quot;</xsl:variable>
493
 
    <xsl:variable name="apos">&apos;</xsl:variable>
494
 
 
495
 
    <xsl:choose>
496
 
      <xsl:when test='contains($value, $quot) and contains($value, $apos)'>
497
 
        <xsl:text>"</xsl:text>
498
 
        <xsl:call-template name='str:subst'>
499
 
          <xsl:with-param name='text' select='$value'/>
500
 
          <xsl:with-param name='replace'>"</xsl:with-param>
501
 
          <xsl:with-param name='with'>
502
 
            <xsl:text disable-output-escaping='yes'>&amp;quot;</xsl:text>
503
 
          </xsl:with-param>
504
 
        </xsl:call-template>
505
 
        <xsl:text>"</xsl:text>
506
 
      </xsl:when>
507
 
      <xsl:when test='contains($value, $quot)'>
508
 
        <xsl:text>'</xsl:text>
509
 
        <xsl:value-of select='$value'/>
510
 
        <xsl:text>'</xsl:text>
511
 
      </xsl:when>
512
 
      <xsl:otherwise>
513
 
        <xsl:text>"</xsl:text>
514
 
        <xsl:value-of select='$value'/>
515
 
        <xsl:text>"</xsl:text>
516
 
      </xsl:otherwise>
517
 
    </xsl:choose>
518
 
  </xsl:template>
519
 
 
520
 
  <doc:template name="markup:external-identifier" xmlns="">
521
 
    <refpurpose>Create an External Identifier</refpurpose>
522
 
 
523
 
    <refdescription>
524
 
      <para>This template returns an external identifier.</para>
525
 
    </refdescription>
526
 
 
527
 
    <refparameter>
528
 
      <variablelist>
529
 
        <varlistentry>
530
 
          <term>publicid</term>
531
 
          <listitem>
532
 
            <para>The public identifier.</para>
533
 
          </listitem>
534
 
        </varlistentry>
535
 
        <varlistentry>
536
 
          <term>systemid</term>
537
 
          <listitem>
538
 
            <para>The system identifier.</para>
539
 
          </listitem>
540
 
        </varlistentry>
541
 
      </variablelist>
542
 
    </refparameter>
543
 
 
544
 
    <refreturn>
545
 
      <para>Returns an external identifier as a string.</para>
546
 
    </refreturn>
547
 
  </doc:template>
548
 
 
549
 
  <xsl:template name='markup:external-identifier'>
550
 
    <xsl:param name='publicid'/>
551
 
    <xsl:param name='systemid'/>
552
 
    <xsl:param name='leading-space' select='false()'/>
553
 
 
554
 
    <xsl:choose>
555
 
      <xsl:when test='string-length($publicid) &gt; 0'>
556
 
        <xsl:if test='$leading-space'>
557
 
          <xsl:text> </xsl:text>
558
 
        </xsl:if>
559
 
        <xsl:text disable-output-escaping='yes'>PUBLIC "</xsl:text>
560
 
        <xsl:value-of select='$publicid' disable-output-escaping='yes'/>
561
 
        <xsl:text disable-output-escaping='yes'>"</xsl:text>
562
 
        <xsl:if test='string-length($systemid) &gt; 0'>
563
 
          <xsl:text disable-output-escaping='yes'> "</xsl:text>
564
 
          <xsl:value-of select='$systemid' disable-output-escaping='yes'/>
565
 
          <xsl:text disable-output-escaping='yes'>"</xsl:text>
566
 
        </xsl:if>
567
 
      </xsl:when>
568
 
      <xsl:when test="string-length($systemid) &gt; 0">
569
 
        <xsl:if test='$leading-space'>
570
 
          <xsl:text> </xsl:text>
571
 
        </xsl:if>
572
 
        <xsl:text disable-output-escaping='yes'>SYSTEM "</xsl:text>
573
 
        <xsl:value-of select='$systemid' disable-output-escaping='yes'/>
574
 
        <xsl:text disable-output-escaping='yes'>"</xsl:text>
575
 
      </xsl:when>
576
 
    </xsl:choose>
577
 
  </xsl:template>
578
 
 
579
 
  <doc:template name="markup:entity-reference" xmlns="">
580
 
    <refpurpose>Create an Entity Reference</refpurpose>
581
 
 
582
 
    <refdescription>
583
 
      <para>This template returns an entity reference.</para>
584
 
    </refdescription>
585
 
 
586
 
    <refparameter>
587
 
      <variablelist>
588
 
        <varlistentry>
589
 
          <term>name</term>
590
 
          <listitem>
591
 
            <para>The name of the entity.</para>
592
 
          </listitem>
593
 
        </varlistentry>
594
 
      </variablelist>
595
 
    </refparameter>
596
 
 
597
 
    <refreturn>
598
 
      <para>Returns an entity reference as a string.</para>
599
 
    </refreturn>
600
 
  </doc:template>
601
 
 
602
 
  <xsl:template name='markup:entity-reference'>
603
 
    <xsl:param name='name'/>
604
 
 
605
 
    <xsl:text disable-output-escaping='yes'>&amp;</xsl:text>
606
 
    <xsl:value-of select='$name'/>
607
 
    <xsl:text>;</xsl:text>
608
 
 
609
 
  </xsl:template>
610
 
 
611
 
  <doc:template name="markup:notation-declaration" xmlns="">
612
 
    <refpurpose>Create a Notation Declaration</refpurpose>
613
 
 
614
 
    <refdescription>
615
 
      <para>This template returns a notation declaration.</para>
616
 
    </refdescription>
617
 
 
618
 
    <refparameter>
619
 
      <variablelist>
620
 
        <varlistentry>
621
 
          <term>name</term>
622
 
          <listitem>
623
 
            <para>The notation name.</para>
624
 
          </listitem>
625
 
        </varlistentry>
626
 
        <varlistentry>
627
 
          <term>publicid</term>
628
 
          <listitem>
629
 
            <para>The public identifier for the notation.</para>
630
 
          </listitem>
631
 
        </varlistentry>
632
 
        <varlistentry>
633
 
          <term>systemid</term>
634
 
          <listitem>
635
 
            <para>The system identifier for the notation.</para>
636
 
          </listitem>
637
 
        </varlistentry>
638
 
      </variablelist>
639
 
    </refparameter>
640
 
 
641
 
    <refreturn>
642
 
      <para>Returns a notation declaration as a string.</para>
643
 
    </refreturn>
644
 
  </doc:template>
645
 
 
646
 
  <xsl:template name='markup:notation-declaration'>
647
 
    <xsl:param name='name'/>
648
 
    <xsl:param name='publicid'/>
649
 
    <xsl:param name='systemid'/>
650
 
 
651
 
    <xsl:if test='string-length($name) = 0'>
652
 
      <xsl:message terminate='yes'>notation name must be specified</xsl:message>
653
 
    </xsl:if>
654
 
    <xsl:if test='string-length($publicid) = 0 and string-length($systemid) = 0'>
655
 
      <xsl:message terminate='yes'>external identifier must be specified</xsl:message>
656
 
    </xsl:if>
657
 
 
658
 
    <xsl:text disable-output-escaping='yes'>&lt;!NOTATION </xsl:text>
659
 
    <xsl:copy-of select='$name'/>
660
 
 
661
 
    <xsl:call-template name='markup:external-identifier'>
662
 
      <xsl:with-param name='publicid' select='$publicid'/>
663
 
      <xsl:with-param name='systemid' select='$systemid'/>
664
 
      <xsl:with-param name='leading-space' select='true()'/>
665
 
    </xsl:call-template>
666
 
 
667
 
    <xsl:text disable-output-escaping='yes'>&gt;</xsl:text>
668
 
  </xsl:template>
669
 
 
670
 
  <doc:template name="markup:cdata-section" xmlns="">
671
 
    <refpurpose>Create a CDATA Section</refpurpose>
672
 
 
673
 
    <refdescription>
674
 
      <para>This template returns a CDATA Section.  The XSLT specification provides a mechanism for instructing the XSL processor to output character data in a CDATA section for certain elements, but this template may be useful in those circumstances where not all instances of an element are to have their content placed in a CDATA section.</para>
675
 
    </refdescription>
676
 
 
677
 
    <refparameter>
678
 
      <variablelist>
679
 
        <varlistentry>
680
 
          <term>text</term>
681
 
          <listitem>
682
 
            <para>The content of the CDATA section.</para>
683
 
          </listitem>
684
 
        </varlistentry>
685
 
      </variablelist>
686
 
    </refparameter>
687
 
 
688
 
    <refreturn>
689
 
      <para>Returns a CDATA section as a string.</para>
690
 
    </refreturn>
691
 
  </doc:template>
692
 
 
693
 
  <xsl:template name='markup:cdata-section'>
694
 
    <xsl:param name='text'/>
695
 
 
696
 
    <xsl:if test="contains($text, ']]&gt;')">
697
 
      <xsl:message terminate="yes">CDATA section contains "]]&gt;"</xsl:message>
698
 
    </xsl:if>
699
 
 
700
 
    <xsl:text disable-output-escaping='yes'>&lt;![CDATA[</xsl:text>
701
 
    <xsl:copy-of select='$text'/>
702
 
    <xsl:text disable-output-escaping='yes'>]]&gt;</xsl:text>
703
 
  </xsl:template>
704
 
 
705
 
  <doc:template name="markup:as-xml" xmlns="">
706
 
    <refpurpose>Format Nodeset As XML Markup</refpurpose>
707
 
 
708
 
    <refdescription>
709
 
      <para>This template returns XML markup.  Each node in the given nodeset is converted to its equivalent XML markup.</para>
710
 
 
711
 
      <para>BUG: This version may not adequately handle XML Namespaces.</para>
712
 
    </refdescription>
713
 
 
714
 
    <refparameter>
715
 
      <variablelist>
716
 
        <varlistentry>
717
 
          <term>nodes</term>
718
 
          <listitem>
719
 
            <para>Nodeset to format as XML.</para>
720
 
          </listitem>
721
 
        </varlistentry>
722
 
      </variablelist>
723
 
    </refparameter>
724
 
 
725
 
    <refreturn>
726
 
      <para>Returns XML markup.</para>
727
 
    </refreturn>
728
 
  </doc:template>
729
 
 
730
 
  <xsl:template name='markup:as-xml'>
731
 
    <xsl:param name='nodes'/>
732
 
 
733
 
    <xsl:if test="$nodes">
734
 
      <xsl:choose>
735
 
        <xsl:when test="$nodes[1]/self::*">
736
 
          <xsl:text disable-output-escaping='yes'>&lt;</xsl:text>
737
 
          <xsl:value-of select="name($nodes[1])"/>
738
 
          <xsl:for-each select="$nodes[1]/@*">
739
 
            <xsl:text> </xsl:text>
740
 
            <xsl:value-of select="name()"/>
741
 
            <xsl:text>=</xsl:text>
742
 
            <xsl:call-template name='markup:quote-value'>
743
 
              <xsl:with-param name='value' select='.'/>
744
 
            </xsl:call-template>
745
 
          </xsl:for-each>
746
 
 
747
 
          <xsl:choose>
748
 
            <xsl:when test='$nodes[1]/node()'>
749
 
              <xsl:text disable-output-escaping='yes'>&gt;</xsl:text>
750
 
              <xsl:call-template name='markup:as-xml'>
751
 
                <xsl:with-param name='nodes' select='$nodes[1]/node()'/>
752
 
              </xsl:call-template>
753
 
              <xsl:text disable-output-escaping='yes'>&lt;/</xsl:text>
754
 
              <xsl:value-of select="name($nodes[1])"/>
755
 
              <xsl:text disable-output-escaping='yes'>&gt;</xsl:text>
756
 
            </xsl:when>
757
 
            <xsl:otherwise>
758
 
              <xsl:text disable-output-escaping='yes'>/&gt;</xsl:text>
759
 
            </xsl:otherwise>
760
 
          </xsl:choose>
761
 
        </xsl:when>
762
 
        <xsl:when test="$nodes[1]/self::text()">
763
 
          <xsl:value-of select="$nodes[1]"/>
764
 
        </xsl:when>
765
 
        <xsl:when test="$nodes[1]/self::comment()">
766
 
          <xsl:text disable-output-escaping='yes'>&lt;!--</xsl:text>
767
 
          <xsl:value-of select="$nodes[1]"/>
768
 
          <xsl:text disable-output-escaping='yes'>--&gt;</xsl:text>
769
 
        </xsl:when>
770
 
        <xsl:when test="$nodes[1]/self::processing-instruction()">
771
 
          <xsl:text disable-output-escaping='yes'>&lt;?</xsl:text>
772
 
          <xsl:value-of select="name($nodes[1])"/>
773
 
          <xsl:text> </xsl:text>
774
 
          <xsl:value-of select="$nodes[1]"/>
775
 
          <xsl:text disable-output-escaping='yes'>?&gt;</xsl:text>
776
 
        </xsl:when>
777
 
 
778
 
        <xsl:when test="not($nodes[1]/parent::*)"/> <!-- root node -->
779
 
        <xsl:when test="count($nodes[1] | $nodes[1]/../namespace::*) = count($nodes[1]/../namespace::*)"/> <!-- namespace node -->
780
 
        <xsl:when test="count($nodes[1] | $nodes[1]/../@*) = count($nodes[1]/../@*)"/> <!-- attribute node -->
781
 
      </xsl:choose>
782
 
 
783
 
      <xsl:call-template name="markup:as-xml">
784
 
        <xsl:with-param name="nodes" select="$nodes[position() &gt; 1]"/>
785
 
      </xsl:call-template>
786
 
    </xsl:if>
787
 
  </xsl:template>
788
 
 
789
 
</xsl:stylesheet>