home *** CD-ROM | disk | FTP | other *** search
/ Internet Magazine 2003 October / INTERNET108.ISO / pc / software / windows / building / xmlspy / xmlspyentcomplete5.exe / Data1.cab / _EBF3CB25E451451C949FB5FC6025A162 < prev    next >
Encoding:
Extensible Markup Language  |  2002-09-04  |  5.2 KB  |  153 lines

  1. <?xml version='1.0'?>
  2. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  3.                 xmlns:fo="http://www.w3.org/1999/XSL/Format"
  4.                 xmlns:exsl="http://exslt.org/common"
  5.                 exclude-result-prefixes="exsl"
  6.                 version='1.0'>
  7.  
  8. <!-- ********************************************************************
  9.      $Id: footnote.xsl,v 1.1.2.1 2002/09/04 14:25:10 jdj Exp $
  10.      ********************************************************************
  11.  
  12.      This file is part of the XSL DocBook Stylesheet distribution.
  13.      See ../README or http://nwalsh.com/docbook/xsl/ for copyright
  14.      and other information.
  15.  
  16.      ******************************************************************** -->
  17.  
  18. <xsl:template name="format.footnote.mark">
  19.   <xsl:param name="mark" select="'?'"/>
  20.   <fo:inline baseline-shift="super" font-size="90%">
  21.     <xsl:copy-of select="$mark"/>
  22.   </fo:inline>
  23. </xsl:template>
  24.  
  25. <xsl:template match="footnote">
  26.   <xsl:choose>
  27.     <xsl:when test="ancestor::tgroup">
  28.       <xsl:call-template name="format.footnote.mark">
  29.         <xsl:with-param name="mark">
  30.           <xsl:apply-templates select="." mode="footnote.number"/>
  31.         </xsl:with-param>
  32.       </xsl:call-template>
  33.     </xsl:when>
  34.     <xsl:otherwise>
  35.       <fo:footnote>
  36.         <fo:inline>
  37.           <xsl:call-template name="format.footnote.mark">
  38.             <xsl:with-param name="mark">
  39.               <xsl:apply-templates select="." mode="footnote.number"/>
  40.             </xsl:with-param>
  41.           </xsl:call-template>
  42.         </fo:inline>
  43.         <fo:footnote-body font-family="{$body.font.family}"
  44.                           font-size="{$footnote.font.size}">
  45.           <xsl:apply-templates/>
  46.         </fo:footnote-body>
  47.       </fo:footnote>
  48.     </xsl:otherwise>
  49.   </xsl:choose>
  50. </xsl:template>
  51.  
  52. <xsl:template match="footnoteref">
  53.   <xsl:variable name="footnote" select="key('id',@linkend)"/>
  54.   <xsl:call-template name="format.footnote.mark">
  55.     <xsl:with-param name="mark">
  56.       <xsl:apply-templates select="$footnote" mode="footnote.number"/>
  57.     </xsl:with-param>
  58.   </xsl:call-template>
  59. </xsl:template>
  60.  
  61. <xsl:template match="footnote" mode="footnote.number">
  62.   <xsl:choose>
  63.     <xsl:when test="ancestor::tgroup">
  64.       <xsl:number level="any" from="tgroup" format="a"/>
  65.     </xsl:when>
  66.     <xsl:otherwise>
  67.       <xsl:variable name="pfoot" select="preceding::footnote"/>
  68.       <xsl:variable name="ptfoot" select="preceding::tgroup//footnote"/>
  69.       <xsl:number value="count($pfoot) - count($ptfoot) + 1" format="1"/>
  70.     </xsl:otherwise>
  71.   </xsl:choose>
  72. </xsl:template>
  73.  
  74. <!-- ==================================================================== -->
  75.  
  76. <xsl:template match="*" mode="footnote.body.number">
  77.   <xsl:variable name="footnote.mark">
  78.     <xsl:call-template name="format.footnote.mark">
  79.       <xsl:with-param name="mark">
  80.         <xsl:apply-templates select="ancestor::footnote" mode="footnote.number"/>
  81.       </xsl:with-param>
  82.     </xsl:call-template>
  83.   </xsl:variable>
  84.  
  85.   <xsl:variable name="fo">
  86.     <xsl:apply-templates select="."/>
  87.   </xsl:variable>
  88.  
  89.   <xsl:variable name="fo-nodes" select="exsl:node-set($fo)"/>
  90.  
  91.   <xsl:choose>
  92.     <xsl:when test="$fo-nodes//fo:block">
  93.       <xsl:apply-templates select="$fo-nodes" mode="insert.fo.fnum">
  94.         <xsl:with-param name="mark" select="$footnote.mark"/>
  95.       </xsl:apply-templates>
  96.     </xsl:when>
  97.     <xsl:otherwise>
  98.       <xsl:apply-templates select="$fo-nodes" mode="insert.fo.text">
  99.         <xsl:with-param name="mark" select="$footnote.mark"/>
  100.       </xsl:apply-templates>
  101.     </xsl:otherwise>
  102.   </xsl:choose>
  103. </xsl:template>
  104.  
  105. <!-- ==================================================================== -->
  106.  
  107. <xsl:template match="footnote/para[1]
  108.                      |footnote/simpara[1]
  109.                      |footnote/formalpara[1]"
  110.               priority="2">
  111.   <!-- this only works if the first thing in a footnote is a para, -->
  112.   <!-- which is ok, because it usually is. -->
  113.   <fo:block>
  114.     <xsl:call-template name="format.footnote.mark">
  115.       <xsl:with-param name="mark">
  116.         <xsl:apply-templates select="ancestor::footnote" mode="footnote.number"/>
  117.       </xsl:with-param>
  118.     </xsl:call-template>
  119.     <xsl:apply-templates/>
  120.   </fo:block>
  121. </xsl:template>
  122.  
  123. <xsl:template match="footnote" name="process.footnote" mode="table.footnote.mode">
  124.   <xsl:choose>
  125.     <xsl:when test="local-name(*[1]) = 'para' or local-name(*[1]) = 'simpara'">
  126.       <fo:block>
  127.         <xsl:apply-templates/>
  128.       </fo:block>
  129.     </xsl:when>
  130.  
  131.     <xsl:when test="function-available('exsl:node-set')">
  132.       <fo:block>
  133.         <xsl:apply-templates select="*[1]" mode="footnote.body.number"/>
  134.         <xsl:apply-templates select="*[position() > 1]"/>
  135.       </fo:block>
  136.     </xsl:when>
  137.  
  138.     <xsl:otherwise>
  139.       <xsl:message>
  140.         <xsl:text>Warning: footnote number may not be generated </xsl:text>
  141.         <xsl:text>correctly; </xsl:text>
  142.         <xsl:value-of select="local-name(*[1])"/>
  143.         <xsl:text> unexpected as first child of footnote.</xsl:text>
  144.       </xsl:message>
  145.       <fo:block>
  146.         <xsl:apply-templates/>
  147.       </fo:block>
  148.     </xsl:otherwise>
  149.   </xsl:choose>
  150. </xsl:template>
  151.  
  152. </xsl:stylesheet>
  153.