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

  1. <?xml version="1.0" encoding="US-ASCII"?>
  2. <!--This file was created automatically by html2xhtml-->
  3. <!--from the HTML stylesheets. Do not edit this file.-->
  4. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:exsl="http://exslt.org/common" exclude-result-prefixes="exsl" version="1.0">
  5.  
  6. <!-- ********************************************************************
  7.      $Id: footnote.xsl,v 1.1.2.3 2002/09/04 13:55:37 jdj Exp $
  8.      ********************************************************************
  9.  
  10.      This file is part of the XSL DocBook Stylesheet distribution.
  11.      See ../README or http://nwalsh.com/docbook/xsl/ for copyright
  12.      and other information.
  13.  
  14.      ******************************************************************** -->
  15.  
  16. <xsl:template match="footnote">
  17.   <xsl:variable name="name">
  18.     <xsl:call-template name="object.id"/>
  19.   </xsl:variable>
  20.   <xsl:variable name="href">
  21.     <xsl:text>#ftn.</xsl:text>
  22.     <xsl:call-template name="object.id"/>
  23.   </xsl:variable>
  24.  
  25.   <xsl:choose>
  26.     <xsl:when test="ancestor::tgroup">
  27.       <sup xmlns="http://www.w3.org/1999/xhtml">
  28.         <xsl:text>[</xsl:text>
  29.         <a id="{$name}" href="{$href}">
  30.           <xsl:apply-templates select="." mode="footnote.number"/>
  31.         </a>
  32.         <xsl:text>]</xsl:text>
  33.       </sup>
  34.     </xsl:when>
  35.     <xsl:otherwise>
  36.       <sup xmlns="http://www.w3.org/1999/xhtml">
  37.         <xsl:text>[</xsl:text>
  38.         <a id="{$name}" href="{$href}">
  39.           <xsl:apply-templates select="." mode="footnote.number"/>
  40.         </a>
  41.         <xsl:text>]</xsl:text>
  42.       </sup>
  43.     </xsl:otherwise>
  44.   </xsl:choose>
  45. </xsl:template>
  46.  
  47. <xsl:template match="footnoteref">
  48.   <xsl:variable name="targets" select="key('id',@linkend)"/>
  49.   <xsl:variable name="footnote" select="$targets[1]"/>
  50.   <xsl:variable name="href">
  51.     <xsl:text>#ftn.</xsl:text>
  52.     <xsl:call-template name="object.id">
  53.       <xsl:with-param name="object" select="$footnote"/>
  54.     </xsl:call-template>
  55.   </xsl:variable>
  56.   <sup xmlns="http://www.w3.org/1999/xhtml">
  57.     <xsl:text>[</xsl:text>
  58.     <a href="{$href}">
  59.       <xsl:apply-templates select="$footnote" mode="footnote.number"/>
  60.     </a>
  61.     <xsl:text>]</xsl:text>
  62.   </sup>
  63. </xsl:template>
  64.  
  65. <xsl:template match="footnote" mode="footnote.number">
  66.   <xsl:choose>
  67.     <xsl:when test="ancestor::tgroup">
  68.       <xsl:number level="any" from="table|informaltable" format="a"/>
  69.     </xsl:when>
  70.     <xsl:when test="ancestor::refentry">
  71.       <xsl:number level="any" from="refentry" format="1"/>
  72.     </xsl:when>
  73.     <xsl:otherwise>
  74.       <xsl:variable name="pfoot" select="preceding::footnote"/>
  75.       <xsl:variable name="ptfoot" select="preceding::table//footnote                                           |preceding::informaltable//footnote"/>
  76.       <xsl:number value="count($pfoot) - count($ptfoot) + 1" format="1"/>
  77.     </xsl:otherwise>
  78.   </xsl:choose>
  79. </xsl:template>
  80.  
  81. <!-- ==================================================================== -->
  82.  
  83. <xsl:template match="footnote/para[1]|footnote/simpara[1]" priority="2">
  84.   <!-- this only works if the first thing in a footnote is a para, -->
  85.   <!-- which is ok, because it usually is. -->
  86.   <xsl:variable name="name">
  87.     <xsl:text>ftn.</xsl:text>
  88.     <xsl:call-template name="object.id">
  89.       <xsl:with-param name="object" select="ancestor::footnote"/>
  90.     </xsl:call-template>
  91.   </xsl:variable>
  92.   <xsl:variable name="href">
  93.     <xsl:text>#</xsl:text>
  94.     <xsl:call-template name="object.id">
  95.       <xsl:with-param name="object" select="ancestor::footnote"/>
  96.     </xsl:call-template>
  97.   </xsl:variable>
  98.   <p xmlns="http://www.w3.org/1999/xhtml">
  99.     <sup>
  100.       <xsl:text>[</xsl:text>
  101.       <a id="{$name}" href="{$href}">
  102.         <xsl:apply-templates select="ancestor::footnote" mode="footnote.number"/>
  103.       </a>
  104.       <xsl:text>] </xsl:text>
  105.     </sup>
  106.     <xsl:apply-templates/>
  107.   </p>
  108. </xsl:template>
  109.  
  110. <!-- ==================================================================== -->
  111.  
  112. <xsl:template match="*" mode="footnote.body.number">
  113.   <xsl:variable name="name">
  114.     <xsl:text>ftn.</xsl:text>
  115.     <xsl:call-template name="object.id">
  116.       <xsl:with-param name="object" select="ancestor::footnote"/>
  117.     </xsl:call-template>
  118.   </xsl:variable>
  119.   <xsl:variable name="href">
  120.     <xsl:text>#</xsl:text>
  121.     <xsl:call-template name="object.id">
  122.       <xsl:with-param name="object" select="ancestor::footnote"/>
  123.     </xsl:call-template>
  124.   </xsl:variable>
  125.   <xsl:variable name="footnote.mark">
  126.     <sup xmlns="http://www.w3.org/1999/xhtml">
  127.       <xsl:text>[</xsl:text>
  128.       <a id="{$name}" href="{$href}">
  129.         <xsl:apply-templates select="ancestor::footnote" mode="footnote.number"/>
  130.       </a>
  131.       <xsl:text>] </xsl:text>
  132.     </sup>
  133.   </xsl:variable>
  134.  
  135.   <xsl:variable name="html">
  136.     <xsl:apply-templates select="."/>
  137.   </xsl:variable>
  138.  
  139.   <xsl:choose>
  140.     <xsl:when test="function-available('exsl:node-set')">
  141.       <xsl:variable name="html-nodes" select="exsl:node-set($html)"/>
  142.       <xsl:choose>
  143.         <xsl:when test="$html-nodes//p">
  144.           <xsl:apply-templates select="$html-nodes" mode="insert.html.p">
  145.             <xsl:with-param name="mark" select="$footnote.mark"/>
  146.           </xsl:apply-templates>
  147.         </xsl:when>
  148.         <xsl:otherwise>
  149.           <xsl:apply-templates select="$html-nodes" mode="insert.html.text">
  150.             <xsl:with-param name="mark" select="$footnote.mark"/>
  151.           </xsl:apply-templates>
  152.         </xsl:otherwise>
  153.       </xsl:choose>
  154.     </xsl:when>
  155.     <xsl:otherwise>
  156.       <xsl:copy-of select="$html"/>
  157.     </xsl:otherwise>
  158.   </xsl:choose>
  159. </xsl:template>
  160.  
  161. <!-- ==================================================================== -->
  162.  
  163. <!--
  164. <xsl:template name="count-element-from">
  165.   <xsl:param name="from" select=".."/>
  166.   <xsl:param name="to" select="."/>
  167.   <xsl:param name="count" select="0"/>
  168.   <xsl:param name="list" select="$from/following::*[name(.)=name($to)]
  169.                                  |$from/descendant-or-self::*[name(.)=name($to)]"/>
  170.  
  171.   <xsl:choose>
  172.     <xsl:when test="not($list)">
  173.       <xsl:text>-1</xsl:text>
  174.     </xsl:when>
  175.     <xsl:when test="$list[1] = $to">
  176.       <xsl:value-of select="$count + 1"/>
  177.     </xsl:when>
  178.     <xsl:otherwise>
  179.     </xsl:otherwise>
  180.   </xsl:choose>
  181. </xsl:template>
  182. -->
  183.  
  184. <!-- ==================================================================== -->
  185.  
  186. <xsl:template name="process.footnotes">
  187.   <xsl:variable name="footnotes" select=".//footnote"/>
  188.   <xsl:variable name="table.footnotes" select=".//tgroup//footnote"/>
  189.  
  190.   <!-- Only bother to do this if there's at least one non-table footnote -->
  191.   <xsl:if test="count($footnotes)>count($table.footnotes)">
  192.     <div xmlns="http://www.w3.org/1999/xhtml" class="footnotes">
  193.       <br/>
  194.       <hr width="100" align="left"/>
  195.       <xsl:apply-templates select="$footnotes" mode="process.footnote.mode"/>
  196.     </div>
  197.   </xsl:if>
  198. </xsl:template>
  199.  
  200. <xsl:template name="process.chunk.footnotes">
  201.   <!-- nop -->
  202. </xsl:template>
  203.  
  204. <xsl:template match="footnote" name="process.footnote" mode="process.footnote.mode">
  205.   <xsl:choose>
  206.     <xsl:when test="local-name(*[1]) = 'para' or local-name(*[1]) = 'simpara'">
  207.       <div xmlns="http://www.w3.org/1999/xhtml" class="{name(.)}">
  208.         <xsl:apply-templates/>
  209.       </div>
  210.     </xsl:when>
  211.  
  212.     <xsl:when test="$html.cleanup != 0 and function-available('exsl:node-set')">
  213.       <div xmlns="http://www.w3.org/1999/xhtml" class="{name(.)}">
  214.         <xsl:apply-templates select="*[1]" mode="footnote.body.number"/>
  215.         <xsl:apply-templates select="*[position() > 1]"/>
  216.       </div>
  217.     </xsl:when>
  218.  
  219.     <xsl:otherwise>
  220.       <xsl:message>
  221.         <xsl:text>Warning: footnote number may not be generated </xsl:text>
  222.         <xsl:text>correctly; </xsl:text>
  223.         <xsl:value-of select="local-name(*[1])"/>
  224.         <xsl:text> unexpected as first child of footnote.</xsl:text>
  225.       </xsl:message>
  226.       <div xmlns="http://www.w3.org/1999/xhtml" class="{name(.)}">
  227.         <xsl:apply-templates/>
  228.       </div>
  229.     </xsl:otherwise>
  230.   </xsl:choose>
  231. </xsl:template>
  232.  
  233. <xsl:template match="tgroup//footnote" mode="process.footnote.mode">
  234. </xsl:template>
  235.  
  236. <xsl:template match="footnote" mode="table.footnote.mode">
  237.   <xsl:call-template name="process.footnote"/>
  238. </xsl:template>
  239.  
  240. </xsl:stylesheet>
  241.