~ubuntu-branches/ubuntu/trusty/yelp-xsl/trusty

« back to all changes in this revision

Viewing changes to xslt/docbook/html/db2html-media.xsl

  • Committer: Package Import Robot
  • Author(s): Michael Biebl
  • Date: 2013-10-17 00:05:53 UTC
  • mto: This revision was merged to the branch mainline in revision 19.
  • Revision ID: package-import@ubuntu.com-20131017000553-4rje2hk2j69y05w4
Tags: upstream-3.10.1
ImportĀ upstreamĀ versionĀ 3.10.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
20
20
                xmlns:db="http://docbook.org/ns/docbook"
21
21
                xmlns:mml="http://www.w3.org/1998/Math/MathML"
 
22
                xmlns:str="http://exslt.org/strings"
22
23
                xmlns="http://www.w3.org/1999/xhtml"
23
 
                exclude-result-prefixes="db mml"
 
24
                exclude-result-prefixes="db mml str"
24
25
                version="1.0">
25
26
 
26
27
<!--!!==========================================================================
82
83
<!--**==========================================================================
83
84
db2html.imagedata
84
85
Output an HTML #{img} element for a #{imagedata} element.
85
 
:Revision:version="3.8" date="2012-11-12" status="final"
 
86
:Revision:version="3.10" date="2013-08-11" status="final"
86
87
$node: The #{imagedata} or other graphic element.
87
88
 
88
89
This template creates an #{img} element in the HTML output.  This template
90
91
#{inlinegraphic} elements.  Note that #{graphic} and #{inlinegraphic} are
91
92
deprecated and should not be used in any newly-written DocBook files.  Use
92
93
#{mediaobject} instead.
 
94
 
 
95
This template looks for a #{textobject} with a #{phrase} child in an ancestor
 
96
#{mediaobject} or #{inlinemediaobject} element. It uses the first available,
 
97
taking conditional processing into consideration.
93
98
-->
94
99
<xsl:template name="db2html.imagedata">
95
100
  <xsl:param name="node" select="."/>
119
124
                                        self::db:imagedata/ancestor::db:mediaobject[1] |
120
125
                                        self::db:imagedata/ancestor::db:inlinemediaobject[1]
121
126
                                       )[last()]"/>
122
 
    <xsl:variable name="alt" select="$media/textobject/phrase | $media/db:textobject/db:phrase"/>
123
 
    <xsl:if test="$alt">
 
127
    <xsl:variable name="alt" select="$media/textobject[phrase] | $media/db:textobject[db:phrase]"/>
 
128
    <xsl:variable name="altpos">
 
129
      <xsl:for-each select="$alt">
 
130
        <xsl:variable name="if"><xsl:call-template name="db.profile.test"/></xsl:variable>
 
131
        <xsl:if test="$if != ''">
 
132
          <xsl:value-of select="concat(',', position())"/>
 
133
        </xsl:if>
 
134
      </xsl:for-each>
 
135
    </xsl:variable>
 
136
    <xsl:if test="$altpos != ''">
124
137
      <xsl:attribute name="alt">
125
 
        <xsl:value-of select="$alt[1]"/>
 
138
        <xsl:variable name="obj" select="$alt[position() = number(str:split($altpos, ',')[1])]"/>
 
139
        <xsl:value-of select="$obj/phrase | $obj/db:phrase"/>
126
140
      </xsl:attribute>
127
141
    </xsl:if>
128
142
  </img>
204
218
<!--**==========================================================================
205
219
db2html.mediaobject
206
220
Outputs HTML for a #{mediaobject} element.
207
 
:Revision:version="3.8" date="2012-11-13" status="final"
 
221
:Revision:version="3.10" date="2013-08-11" status="final"
208
222
$node: The #{mediaobject} element.
209
223
 
210
224
This template processes a #{mediaobject} element and outputs the appropriate
211
225
HTML. DocBook allows multiple objects to be listed in a #{mediaobject} element.
212
226
Processing tools are expected to choose the earliest suitable object. This
213
227
template will select the first audio, image, or video object it can handle,
214
 
filtering out images in non-web formats. If no suitable non-text objects are
215
 
found, this template calls *{db2html.mediaobject.fallback}.
 
228
filtering out images in non-web formats, and taking conditional processing
 
229
into consideration. If no suitable non-text objects are found, this template
 
230
calls *{db2html.mediaobject.fallback}.
216
231
 
217
232
This template also detects MathML embedded in a DocBook 5 #{imagedata} element
218
233
with the #{format} attribute #{"mathml"}, and passes it to the templates in
240
255
      @format = 'GIF'  or @format = 'GIF87a' or @format = 'GIF89a' or
241
256
      @format = 'JPEG' or @format = 'JPG'    or @format = 'PNG'    or
242
257
      not(@format)]] "/>
 
258
  <xsl:variable name="objspos">
 
259
    <xsl:for-each select="$objs">
 
260
      <xsl:variable name="if"><xsl:call-template name="db.profile.test"/></xsl:variable>
 
261
      <xsl:if test="$if != ''">
 
262
        <xsl:value-of select="concat(',', position())"/>
 
263
      </xsl:if>
 
264
    </xsl:for-each>
 
265
  </xsl:variable>
243
266
  <xsl:choose>
244
 
    <xsl:when test="$objs">
245
 
      <xsl:apply-templates select="$objs[1]"/>
 
267
    <xsl:when test="$objspos != ''">
 
268
      <xsl:apply-templates select="$objs[position() = number(str:split($objspos, ',')[1])]"/>
246
269
    </xsl:when>
247
270
    <xsl:otherwise>
248
271
      <xsl:call-template name="db2html.mediaobject.fallback">
256
279
<!--**==========================================================================
257
280
db2html.mediaobject.fallback
258
281
Outputs fallback HTML for a #{mediaobject} element.
259
 
:Revision:version="3.8" date="2012-11-13" status="final"
 
282
:Revision:version="3.10" date="2013-08-11" status="final"
260
283
$node: The #{mediaobject} element.
261
284
 
262
285
This template outputs HTML for the first suitable #{textobject} child element
263
286
of ${node}. If ${node} is an #{inlinemediaobject}, it looks for a #{textobject}
264
287
that contains a #{phrase} element. Otherwise, it looks for a #{textobject} with
265
 
normal block content.
 
288
normal block content. It also handles conditional processing on the #{textobject}
 
289
elements.
266
290
-->
267
291
<xsl:template name="db2html.mediaobject.fallback">
268
292
  <xsl:param name="node" select="."/>
269
293
  <xsl:choose>
270
294
    <xsl:when test="local-name($node) = 'inlinemediaobject'">
271
 
      <xsl:apply-templates select="($node/textobject/phrase | $node/db:textobject/db:phrase)[1]"/>
 
295
      <xsl:variable name="alt" select="$node/textobject[phrase] | $node/db:textobject[db:phrase]"/>
 
296
      <xsl:variable name="altpos">
 
297
        <xsl:for-each select="$alt">
 
298
          <xsl:variable name="if"><xsl:call-template name="db.profile.test"/></xsl:variable>
 
299
          <xsl:if test="$if != ''">
 
300
            <xsl:value-of select="concat(',', position())"/>
 
301
          </xsl:if>
 
302
        </xsl:for-each>
 
303
      </xsl:variable>
 
304
      <xsl:if test="$altpos != ''">
 
305
        <xsl:variable name="obj" select="$alt[position() = number(str:split($altpos, ',')[1])]"/>
 
306
        <xsl:apply-templates select="$obj/phrase | $obj/db:phrase"/>
 
307
      </xsl:if>
272
308
    </xsl:when>
273
309
    <xsl:otherwise>
274
 
      <xsl:apply-templates select="($node/textobject[not(phrase or textdata)] |
275
 
                                    $node/db:textobject[not(db:phrase or db:textdata)]
276
 
                                   )[1]/*"/>
 
310
      <xsl:variable name="alt" select="$node/textobject[not(phrase or textdata)] |
 
311
                                       $node/db:textobject[not(db:phrase or db:textdata)]"/>
 
312
      <xsl:variable name="altpos">
 
313
        <xsl:for-each select="$alt">
 
314
          <xsl:variable name="if"><xsl:call-template name="db.profile.test"/></xsl:variable>
 
315
          <xsl:if test="$if != ''">
 
316
            <xsl:value-of select="concat(',', position())"/>
 
317
          </xsl:if>
 
318
        </xsl:for-each>
 
319
      </xsl:variable>
 
320
      <xsl:if test="$altpos != ''">
 
321
        <xsl:apply-templates select="$alt[position() = number(str:split($altpos, ',')[1])]/*"/>
 
322
      </xsl:if>
277
323
    </xsl:otherwise>
278
324
  </xsl:choose>
279
325
</xsl:template>
284
330
<!-- = audiodata = -->
285
331
<xsl:template match="mediaobject/audioobject/audiodata |
286
332
                     db:mediaobject/db:audioobject/db:audiodata">
287
 
  <div class="media media-audio">
 
333
  <div>
 
334
    <xsl:call-template name="html.class.attr">
 
335
      <xsl:with-param name="class" select="'media media-audio'"/>
 
336
    </xsl:call-template>
288
337
    <div class="inner">
289
338
      <xsl:call-template name="db2html.audiodata">
290
339
        <xsl:with-param name="inline" select="false()"/>
294
343
</xsl:template>
295
344
<xsl:template match="inlinemediaobject/audioobject/audiodata |
296
345
                     db:inlinemediaobject/db:audioobject/db:audiodata">
297
 
  <span class="media media-audio">
 
346
  <span>
 
347
    <xsl:call-template name="html.class.attr">
 
348
      <xsl:with-param name="class" select="'media media-audio'"/>
 
349
    </xsl:call-template>
298
350
    <xsl:call-template name="db2html.audiodata"/>
299
351
  </span>
300
352
</xsl:template>
306
358
 
307
359
<!-- = graphic = -->
308
360
<xsl:template match="graphic">
309
 
  <div class="graphic">
 
361
  <div>
 
362
    <xsl:call-template name="html.class.attr">
 
363
      <xsl:with-param name="class" select="'graphic'"/>
 
364
    </xsl:call-template>
310
365
    <xsl:call-template name="db2html.anchor"/>
311
366
    <xsl:call-template name="db2html.imagedata"/>
312
367
  </div>
331
386
 
332
387
<!-- = inlinegraphic = -->
333
388
<xsl:template match="inlinegraphic">
334
 
  <span class="inlinegraphic">
 
389
  <span>
 
390
    <xsl:call-template name="html.class.attr">
 
391
      <xsl:with-param name="class" select="'inlinegraphic'"/>
 
392
    </xsl:call-template>
335
393
    <xsl:call-template name="db2html.anchor"/>
336
394
    <xsl:call-template name="db2html.imagedata"/>
337
395
  </span>
339
397
 
340
398
<!-- = inlinemediaobject = -->
341
399
<xsl:template match="inlinemediaobject | db:inlinemediaobject">
342
 
  <span class="inlinemediaobject">
 
400
  <xsl:variable name="if"><xsl:call-template name="db.profile.test"/></xsl:variable>
 
401
  <xsl:if test="$if != ''">
 
402
  <span>
 
403
    <xsl:call-template name="html.class.attr">
 
404
      <xsl:with-param name="class" select="'inlinemediaobject'"/>
 
405
    </xsl:call-template>
343
406
    <xsl:call-template name="db2html.anchor"/>
344
407
    <xsl:call-template name="db2html.mediaobject"/>
345
408
  </span>
 
409
  </xsl:if>
346
410
</xsl:template>
347
411
 
348
412
<!-- = mediaojbect = -->
349
413
<xsl:template match="mediaobject | db:mediaobject">
350
 
  <div class="mediaobject">
 
414
  <xsl:variable name="if"><xsl:call-template name="db.profile.test"/></xsl:variable>
 
415
  <xsl:if test="$if != ''">
 
416
  <div>
 
417
    <xsl:call-template name="html.class.attr">
 
418
      <xsl:with-param name="class" select="'mediaobject'"/>
 
419
    </xsl:call-template>
351
420
    <xsl:call-template name="db2html.anchor"/>
352
421
    <xsl:call-template name="db2html.mediaobject"/>
353
422
    <!-- When a figure contains only a single mediaobject, it eats the caption -->
360
429
      <xsl:apply-templates select="caption | db:caption"/>
361
430
    </xsl:if>
362
431
  </div>
 
432
  </xsl:if>
363
433
</xsl:template>
364
434
 
365
435
<!-- = videodata = -->
366
436
<xsl:template match="mediaobject/videoobject/videodata |
367
437
                     db:mediaobject/db:videoobject/db:videodata">
368
 
  <div class="media media-video">
 
438
  <div>
 
439
    <xsl:call-template name="html.class.attr">
 
440
      <xsl:with-param name="class" select="'media media-video'"/>
 
441
    </xsl:call-template>
369
442
    <div class="inner">
370
443
      <xsl:call-template name="db2html.videodata">
371
444
        <xsl:with-param name="inline" select="false()"/>
375
448
</xsl:template>
376
449
<xsl:template match="inlinemediaobject/videoobject/videodata |
377
450
                     db:inlinemediaobject/db:videoobject/db:videodata">
378
 
  <span class="media media-video">
 
451
  <span>
 
452
    <xsl:call-template name="html.class.attr">
 
453
      <xsl:with-param name="class" select="'media media-video'"/>
 
454
    </xsl:call-template>
379
455
    <xsl:call-template name="db2html.videodata"/>
380
456
  </span>
381
457
</xsl:template>