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-footnote.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2009-03-17  |  7.1 KB  |  221 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 - Footnotes
  25. :Requires: db-chunk db-label
  26.  
  27. FIXME: Describe this module
  28. -->
  29.  
  30.  
  31. <!--**==========================================================================
  32. db2html.footnote.ref
  33. Generates a superscript link to a footnote
  34. $node: The #{footnote} element to process
  35.  
  36. REMARK: Describe this template
  37. -->
  38. <xsl:template name="db2html.footnote.ref">
  39.   <xsl:param name="node" select="."/>
  40.   <xsl:variable name="anchor">
  41.     <xsl:text>-noteref-</xsl:text>
  42.     <xsl:choose>
  43.       <xsl:when test="$node/@id">
  44.         <xsl:value-of select="$node/@id"/>
  45.       </xsl:when>
  46.       <xsl:otherwise>
  47.         <xsl:value-of select="generate-id($node)"/>
  48.       </xsl:otherwise>
  49.     </xsl:choose>
  50.   </xsl:variable>
  51.   <xsl:variable name="href">
  52.     <xsl:text>#</xsl:text>
  53.     <xsl:choose>
  54.       <xsl:when test="$node/@id">
  55.         <xsl:value-of select="$node/@id"/>
  56.       </xsl:when>
  57.       <xsl:otherwise>
  58.         <xsl:text>-note-</xsl:text>
  59.         <xsl:value-of select="generate-id($node)"/>
  60.       </xsl:otherwise>
  61.     </xsl:choose>
  62.   </xsl:variable>
  63.   <a name="{$anchor}"/>
  64.   <sup>
  65.     <a class="footnote" href="{$href}">
  66.       <xsl:call-template name="db.number">
  67.         <xsl:with-param name="node" select="$node"/>
  68.       </xsl:call-template>
  69.     </a>
  70.   </sup>
  71. </xsl:template>
  72.  
  73.  
  74. <!--**==========================================================================
  75. db2html.footnote.note
  76. Generates a footnote
  77. $node: The #{footnote} element to process
  78.  
  79. REMARK: Describe this template
  80. -->
  81. <xsl:template name="db2html.footnote.note">
  82.   <xsl:param name="node" select="."/>
  83.   <xsl:variable name="anchor">
  84.     <xsl:choose>
  85.       <xsl:when test="$node/@id">
  86.         <xsl:value-of select="$node/@id"/>
  87.       </xsl:when>
  88.       <xsl:otherwise>
  89.         <xsl:text>-note-</xsl:text>
  90.         <xsl:value-of select="generate-id($node)"/>
  91.       </xsl:otherwise>
  92.     </xsl:choose>
  93.   </xsl:variable>
  94.   <xsl:variable name="href">
  95.     <xsl:text>#</xsl:text>
  96.     <xsl:text>-noteref-</xsl:text>
  97.     <xsl:choose>
  98.       <xsl:when test="$node/@id">
  99.         <xsl:value-of select="$node/@id"/>
  100.       </xsl:when>
  101.       <xsl:otherwise>
  102.         <xsl:value-of select="generate-id($node)"/>
  103.       </xsl:otherwise>
  104.     </xsl:choose>
  105.   </xsl:variable>
  106.   <div class="footnote">
  107.     <a name="{$anchor}"/>
  108.     <span class="footnote-number">
  109.       <a class="footnote-ref" href="{$href}">
  110.         <xsl:call-template name="db.number">
  111.           <xsl:with-param name="node" select="$node"/>
  112.         </xsl:call-template>
  113.       </a>
  114.     </span>
  115.     <xsl:apply-templates select="$node/node()"/>
  116.   </div>
  117. </xsl:template>
  118.  
  119.  
  120. <!--**==========================================================================
  121. db2html.footnote.footer
  122. Generates a foot containing all the footnotes in the chunk
  123. $node: The division element containing footnotes
  124. $depth_of_chunk: The depth of the containing chunk in the document
  125.  
  126. REMARK: Describe this template
  127. -->
  128. <xsl:template name="db2html.footnote.footer">
  129.   <xsl:param name="node" select="."/>
  130.   <xsl:param name="depth_of_chunk">
  131.     <xsl:call-template name="db.chunk.depth-of-chunk"/>
  132.   </xsl:param>
  133.   <xsl:variable name="notes" select="$node//footnote" />
  134.   <xsl:if test="count($notes) != 0">
  135.     <xsl:call-template name="db2html.footnote.footer.sibling">
  136.       <xsl:with-param name="node" select="$node"/>
  137.       <xsl:with-param name="depth_of_chunk" select="$depth_of_chunk"/>
  138.       <xsl:with-param name="notes" select="$notes"/>
  139.       <xsl:with-param name="pos" select="1"/>
  140.       <xsl:with-param name="div" select="false()"/>
  141.     </xsl:call-template>
  142.   </xsl:if>
  143. </xsl:template>
  144.  
  145. <!--#* db2html.footnote.footer.sibling -->
  146. <xsl:template name="db2html.footnote.footer.sibling">
  147.   <xsl:param name="node"/>
  148.   <xsl:param name="depth_of_chunk"/>
  149.   <xsl:param name="notes"/>
  150.   <xsl:param name="pos"/>
  151.   <xsl:param name="div"/>
  152.   <xsl:variable name="this" select="$notes[$pos]"/>
  153.   <xsl:variable name="depth">
  154.     <xsl:call-template name="db.chunk.depth-of-chunk">
  155.       <xsl:with-param name="node" select="$this"/>
  156.     </xsl:call-template>
  157.   </xsl:variable>
  158.   <xsl:choose>
  159.     <xsl:when test="($depth = $depth_of_chunk) and not($div)">
  160.       <div class="footnotes">
  161.         <xsl:call-template name="db2html.footnote.note">
  162.           <xsl:with-param name="node" select="$this"/>
  163.         </xsl:call-template>
  164.         <xsl:if test="$pos < count($notes)">
  165.           <xsl:call-template name="db2html.footnote.footer.sibling">
  166.             <xsl:with-param name="node" select="$node"/>
  167.             <xsl:with-param name="depth_of_chunk" select="$depth_of_chunk"/>
  168.             <xsl:with-param name="notes" select="$notes"/>
  169.             <xsl:with-param name="pos" select="$pos + 1"/>
  170.             <xsl:with-param name="div" select="true()"/>
  171.           </xsl:call-template>
  172.         </xsl:if>
  173.       </div>
  174.     </xsl:when>
  175.     <xsl:otherwise>
  176.       <xsl:if test="$depth = $depth_of_chunk">
  177.         <xsl:call-template name="db2html.footnote.note">
  178.           <xsl:with-param name="node" select="$this"/>
  179.         </xsl:call-template>
  180.       </xsl:if>
  181.       <xsl:if test="$pos < count($notes)">
  182.         <xsl:call-template name="db2html.footnote.footer.sibling">
  183.           <xsl:with-param name="node" select="$node"/>
  184.           <xsl:with-param name="depth_of_chunk" select="$depth_of_chunk"/>
  185.           <xsl:with-param name="notes" select="$notes"/>
  186.           <xsl:with-param name="pos" select="$pos + 1"/>
  187.           <xsl:with-param name="div" select="$div"/>
  188.         </xsl:call-template>
  189.       </xsl:if>
  190.     </xsl:otherwise>
  191.   </xsl:choose>
  192. </xsl:template>
  193.  
  194.  
  195. <!--**==========================================================================
  196. db2html.footnote.css
  197. Outputs CSS that controls the appearance of footnotes
  198.  
  199. REMARK: Describe this template
  200. -->
  201. <xsl:template name="db2html.footnote.css">
  202. <xsl:text>
  203. div.footnotes { font-style: italic; font-size: 0.8em; }
  204. div.footnote { margin-top: 1.44em; }
  205. span.footnote-number { display: inline; padding-right: 0.83em; }
  206. span.footnote-number + p { display: inline; }
  207. a.footnote { text-decoration: none; font-size: 0.8em; }
  208. a.footnote-ref { text-decoration: none; }
  209. </xsl:text>
  210. </xsl:template>
  211.  
  212.  
  213. <!-- == Matched Templates == -->
  214.  
  215. <!-- = footnote = -->
  216. <xsl:template match="footnote">
  217.   <xsl:call-template name="db2html.footnote.ref"/>
  218. </xsl:template>
  219.  
  220. </xsl:stylesheet>
  221.