home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / share / xml / gnome / xslt / docbook / html / db2html-media.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2009-03-17  |  7.1 KB  |  214 lines

  1. <?xml version='1.0' encoding='UTF-8'?><!-- -*- indent-tabs-mode: nil -*- -->
  2. <!--
  3. This program is free software; you can redistribute it and/or modify it under
  4. the terms of the GNU Lesser General Public License as published by the Free
  5. Software Foundation; either version 2 of the License, or (at your option) any
  6. later version.
  7.  
  8. This program is distributed in the hope that it will be useful, but WITHOUT
  9. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  10. FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
  11. details.
  12.  
  13. You should have received a copy of the GNU Lesser General Public License
  14. along with this program; see the file COPYING.LGPL.  If not, write to the
  15. Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  16. 02111-1307, USA.
  17. -->
  18.  
  19. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  20.                 xmlns="http://www.w3.org/1999/xhtml"
  21.                 version="1.0">
  22.  
  23. <!--!!==========================================================================
  24. DocBook to HTML - Images and Media
  25. :Requires: db2html-block db2html-xref
  26.  
  27. REMARK: Describe this module
  28. -->
  29.  
  30.  
  31. <!--**==========================================================================
  32. db2html.imagedata
  33. Renders an #{imagedata} element into an #{img} element
  34. $node: The element to render
  35.  
  36. This template creates an #{img} element in the HTML output.  This named template
  37. is called not only for #{imagedata} elements, but also for #{graphic} and
  38. #{inlinegraphic} elements.  Note that #{graphic} and #{inlinegraphic} are
  39. deprecated and should not be used in any newly-written DocBook files.  Use
  40. #{mediaobject} instead.
  41.  
  42. REMARK: calls db2html.imagedata.src, how other attrs are gotten
  43. -->
  44. <xsl:template name="db2html.imagedata">
  45.   <xsl:param name="node" select="."/>
  46.   <img>
  47.     <xsl:attribute name="src">
  48.       <xsl:call-template name="db2html.imagedata.src">
  49.         <xsl:with-param name="node" select="$node"/>
  50.       </xsl:call-template>
  51.     </xsl:attribute>
  52.     <xsl:choose>
  53.       <xsl:when test="$node/@scale">
  54.         <xsl:attribute name="width">
  55.           <xsl:value-of select="concat($node/@scale, '%')"/>
  56.         </xsl:attribute>
  57.       </xsl:when>
  58.       <xsl:when test="$node/@width">
  59.         <xsl:attribute name="width">
  60.           <xsl:value-of select="$node/@width"/>
  61.         </xsl:attribute>
  62.         <xsl:if test="$node/@height">
  63.           <xsl:attribute name="height">
  64.             <xsl:value-of select="$node/@height"/>
  65.           </xsl:attribute>
  66.         </xsl:if>
  67.       </xsl:when>
  68.     </xsl:choose>
  69.     <xsl:if test="$node/@align">
  70.       <xsl:attribute name="align">
  71.         <xsl:value-of select="$node/@align"/>
  72.       </xsl:attribute>
  73.     </xsl:if>
  74. <!-- FIXME
  75.     <xsl:if test="$textobject/phrase">
  76.       <xsl:attribute name="alt">
  77.         <xsl:value-of select="phrase[1]"/>
  78.       </xsl:attribute>
  79.     </xsl:if>
  80. -->
  81.     <!-- FIXME: longdesc -->
  82.   </img>
  83. </xsl:template>
  84.  
  85.  
  86. <!--**==========================================================================
  87. db2html.imagedata.src
  88. Outputs the content of the #{src} attribute for an #{img} element
  89. $node: The element to render
  90.  
  91. This template is called by *{db2html.imagedata.src} for the content of the
  92. #{src} attribute of an #{img} element.
  93. -->
  94. <xsl:template name="db2html.imagedata.src">
  95.   <xsl:param name="node" select="."/>
  96.   <xsl:choose>
  97.     <xsl:when test="$node/@fileref">
  98.       <!-- FIXME: do this less stupidly, or not at all -->
  99.       <xsl:choose>
  100.         <xsl:when test="$node/@format = 'PNG' and
  101.                         (substring($node/@fileref, string-length($node/@fileref) - 3)
  102.                           != '.png')">
  103.           <xsl:value-of select="concat($node/@fileref, '.png')"/>
  104.         </xsl:when>
  105.         <xsl:otherwise>
  106.           <xsl:value-of select="$node/@fileref"/>
  107.         </xsl:otherwise>
  108.       </xsl:choose>
  109.     </xsl:when>
  110.     <xsl:when test="$node/@entityref">
  111.       <xsl:value-of select="unparsed-entity-uri($node/@entityref)"/>
  112.     </xsl:when>
  113.   </xsl:choose>
  114. </xsl:template>
  115.  
  116.  
  117. <!--**==========================================================================
  118. db2html.mediaobject
  119. Outputs HTML for a #{mediaobject} element
  120. $node: The element to render
  121.  
  122. This template processes a #{mediaobject} element and outputs the appropriate
  123. HTML.  DocBook allows multiple objects to be listed in a #{mediaobject} element.
  124. Processing tools are expected to choose the earliest suitable object.  Currently,
  125. this template only chooses the first suitable #{imageobject} element.  Support
  126. for #{videobject} and #{audioobject} should be added in future versions, as well
  127. as a text-only mode.
  128. -->
  129. <xsl:template name="db2html.mediaobject">
  130.   <xsl:param name="node" select="."/>
  131.   <xsl:choose>
  132. <!-- FIXME
  133.     <xsl:when test="$text_only">
  134.       <xsl:apply-templates select="textobject[1]"/>
  135.     </xsl:when>
  136. -->
  137.     <xsl:when test="$node/imageobject[imagedata/@format = 'PNG']">
  138.       <xsl:apply-templates
  139.        select="$node/imageobject[imagedata/@format = 'PNG'][1]">
  140.         <xsl:with-param name="textobject" select="$node/textobject[1]"/>
  141.       </xsl:apply-templates>
  142.     </xsl:when>
  143.     <xsl:when test="$node/imageobjectco[imageobject/imagedata/@format = 'PNG']">
  144.       <xsl:apply-templates
  145.        select="$node/imageobjectco[imageobject/imagedata/@format = 'PNG'][1]">
  146.         <xsl:with-param name="textobject" select="$node/textobject[1]"/>
  147.       </xsl:apply-templates>
  148.     </xsl:when>
  149.     <xsl:otherwise>
  150.       <xsl:apply-templates select="($node/imageobject | $node/imageobjectco)[1]">
  151.         <xsl:with-param name="textobject" select="$node/textobject[1]"/>
  152.       </xsl:apply-templates>
  153.     </xsl:otherwise>
  154.   </xsl:choose>
  155. </xsl:template>
  156.  
  157.  
  158. <!-- == Matched Templates == -->
  159.  
  160. <!-- = graphic = -->
  161. <xsl:template match="graphic">
  162.   <div class="graphic">
  163.     <xsl:call-template name="db2html.anchor"/>
  164.     <xsl:call-template name="db2html.imagedata"/>
  165.   </div>
  166. </xsl:template>
  167.  
  168. <!-- = imagedata = -->
  169. <xsl:template match="imagedata">
  170.   <xsl:call-template name="db2html.imagedata"/>
  171. </xsl:template>
  172.  
  173. <!-- = imageobject = -->
  174. <xsl:template match="imageobject">
  175.   <xsl:apply-templates select="imagedata"/>
  176. </xsl:template>
  177.  
  178. <!-- = inlinegraphic = -->
  179. <xsl:template match="inlinegraphic">
  180.   <span class="inlinegraphic">
  181.     <xsl:call-template name="db2html.anchor"/>
  182.     <xsl:call-template name="db2html.imagedata"/>
  183.   </span>
  184. </xsl:template>
  185.  
  186. <!-- = inlinemediaobject = -->
  187. <xsl:template match="inlinemediaobject">
  188.   <span class="inlinemediaobject">
  189.     <xsl:call-template name="db2html.anchor"/>
  190.     <xsl:call-template name="db2html.mediaobject"/>
  191.   </span>
  192. </xsl:template>
  193.  
  194. <!-- = mediaojbect = -->
  195. <xsl:template match="mediaobject">
  196.   <div class="mediaobject">
  197.     <xsl:call-template name="db2html.anchor"/>
  198.     <xsl:call-template name="db2html.mediaobject"/>
  199.     <!-- When a figure contains only a single mediaobject, it eats the caption -->
  200.     <xsl:if test="not(../self::figure or ../self::informalfigure) or
  201.                   ../*[not(self::blockinfo) and not(self::title) and
  202.                        not(self::titleabbrev) and not(. = current()) ]">
  203.       <xsl:apply-templates select="caption"/>
  204.     </xsl:if>
  205.   </div>
  206. </xsl:template>
  207.  
  208. <!-- = screenshot = -->
  209. <xsl:template match="screenshot">
  210.   <xsl:call-template name="db2html.block"/>
  211. </xsl:template>
  212.  
  213. </xsl:stylesheet>
  214.