home *** CD-ROM | disk | FTP | other *** search
/ Internet Magazine 2003 October / INTERNET108.ISO / pc / software / windows / building / xmlspy / xmlspyentcomplete5.exe / Data1.cab / _117D137C693B4A2EA475F2FE29A5D564 < prev    next >
Encoding:
Extensible Markup Language  |  2002-09-04  |  14.2 KB  |  453 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.                 version='1.0'>
  5.  
  6. <!-- ********************************************************************
  7.      $Id: autotoc.xsl,v 1.1.2.1 2002/09/04 14:24:54 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. <!-- ==================================================================== -->
  17.  
  18. <xsl:template name="set.toc">
  19.   <xsl:param name="toc-context" select="."/>
  20.  
  21.   <xsl:variable name="id">
  22.     <xsl:call-template name="object.id"/>
  23.   </xsl:variable>
  24.  
  25.   <xsl:variable name="cid">
  26.     <xsl:call-template name="object.id">
  27.       <xsl:with-param name="object" select="$toc-context"/>
  28.     </xsl:call-template>
  29.   </xsl:variable>
  30.  
  31.   <xsl:variable name="nodes" select="book|setindex"/>
  32.  
  33.   <xsl:if test="$nodes">
  34.     <fo:block id="toc...{$id}"
  35.               xsl:use-attribute-sets="toc.margin.properties">
  36.       <xsl:call-template name="table.of.contents.titlepage"/>
  37.       <xsl:apply-templates select="$nodes" mode="toc">
  38.         <xsl:with-param name="toc-context" select="$toc-context"/>
  39.       </xsl:apply-templates>
  40.     </fo:block>
  41.   </xsl:if>
  42. </xsl:template>
  43.  
  44. <xsl:template name="division.toc">
  45.   <xsl:param name="toc-context" select="."/>
  46.  
  47.   <xsl:variable name="id">
  48.     <xsl:call-template name="object.id"/>
  49.   </xsl:variable>
  50.  
  51.   <xsl:variable name="cid">
  52.     <xsl:call-template name="object.id">
  53.       <xsl:with-param name="object" select="$toc-context"/>
  54.     </xsl:call-template>
  55.   </xsl:variable>
  56.  
  57.   <xsl:variable name="nodes"
  58.                 select="part|reference|preface
  59.                         |chapter|appendix
  60.                         |article
  61.                         |bibliography|glossary|index"/>
  62.   <xsl:if test="$nodes">
  63.     <fo:block id="toc...{$id}"
  64.               xsl:use-attribute-sets="toc.margin.properties">
  65.       <xsl:call-template name="table.of.contents.titlepage"/>
  66.       <xsl:apply-templates select="$nodes" mode="toc">
  67.         <xsl:with-param name="toc-context" select="$toc-context"/>
  68.       </xsl:apply-templates>
  69.     </fo:block>
  70.   </xsl:if>
  71. </xsl:template>
  72.  
  73. <xsl:template name="component.toc">
  74.   <xsl:param name="toc-context" select="."/>
  75.  
  76.   <xsl:variable name="id">
  77.     <xsl:call-template name="object.id"/>
  78.   </xsl:variable>
  79.  
  80.   <xsl:variable name="cid">
  81.     <xsl:call-template name="object.id">
  82.       <xsl:with-param name="object" select="$toc-context"/>
  83.     </xsl:call-template>
  84.   </xsl:variable>
  85.  
  86.   <xsl:variable name="nodes" select="section|sect1|refentry
  87.                                      |article|bibliography|glossary
  88.                                      |appendix"/>
  89.   <xsl:if test="$nodes">
  90.     <fo:block id="toc...{$id}"
  91.               xsl:use-attribute-sets="toc.margin.properties">
  92.       <xsl:call-template name="table.of.contents.titlepage"/>
  93.       <xsl:apply-templates select="$nodes" mode="toc">
  94.         <xsl:with-param name="toc-context" select="$toc-context"/>
  95.       </xsl:apply-templates>
  96.     </fo:block>
  97.   </xsl:if>
  98. </xsl:template>
  99.  
  100. <!-- ==================================================================== -->
  101.  
  102. <xsl:template name="toc.line">
  103.   <xsl:variable name="id">
  104.     <xsl:call-template name="object.id"/>
  105.   </xsl:variable>
  106.  
  107.   <xsl:variable name="label">
  108.     <xsl:apply-templates select="." mode="label.markup"/>
  109.   </xsl:variable>
  110.  
  111.   <fo:block text-align-last="justify"
  112.             end-indent="{$toc.indent.width}pt"
  113.             last-line-end-indent="-{$toc.indent.width}pt">
  114.     <fo:inline keep-with-next.within-line="always">
  115.       <fo:basic-link internal-destination="{$id}">
  116.         <xsl:if test="$label != ''">
  117.           <xsl:copy-of select="$label"/>
  118.           <xsl:value-of select="$autotoc.label.separator"/>
  119.         </xsl:if>
  120.         <xsl:apply-templates select="." mode="title.markup"/>
  121.       </fo:basic-link>
  122.     </fo:inline>
  123.     <fo:inline keep-together.within-line="always">
  124.       <xsl:text> </xsl:text>
  125.       <fo:leader leader-pattern="dots"
  126.                  leader-pattern-width="3pt"
  127.                  leader-alignment="reference-area"
  128.                  keep-with-next.within-line="always"/>
  129.       <xsl:text> </xsl:text> 
  130.       <fo:basic-link internal-destination="{$id}">
  131.         <fo:page-number-citation ref-id="{$id}"/>
  132.       </fo:basic-link>
  133.     </fo:inline>
  134.   </fo:block>
  135. </xsl:template>
  136.  
  137. <!-- ==================================================================== -->
  138.  
  139. <xsl:template match="book|setindex" mode="toc">
  140.   <xsl:param name="toc-context" select="."/>
  141.  
  142.   <xsl:variable name="id">
  143.     <xsl:call-template name="object.id"/>
  144.   </xsl:variable>
  145.  
  146.   <xsl:variable name="cid">
  147.     <xsl:call-template name="object.id">
  148.       <xsl:with-param name="object" select="$toc-context"/>
  149.     </xsl:call-template>
  150.   </xsl:variable>
  151.  
  152.   <xsl:call-template name="toc.line"/>
  153.  
  154.   <xsl:variable name="nodes" select="glossary|bibliography|preface|chapter
  155.                                      |reference|part|article|appendix|index"/>
  156.  
  157.   <xsl:if test="$toc.section.depth > 0 and $nodes">
  158.     <fo:block id="toc.{$cid}.{$id}"
  159.               start-indent="{count(ancestor::*)*$toc.indent.width}pt">
  160.       <xsl:apply-templates select="$nodes" mode="toc">
  161.         <xsl:with-param name="toc-context" select="$toc-context"/>
  162.       </xsl:apply-templates>
  163.     </fo:block>
  164.   </xsl:if>
  165. </xsl:template>
  166.  
  167. <xsl:template match="part" mode="toc">
  168.   <xsl:param name="toc-context" select="."/>
  169.  
  170.   <xsl:variable name="id">
  171.     <xsl:call-template name="object.id"/>
  172.   </xsl:variable>
  173.  
  174.   <xsl:variable name="cid">
  175.     <xsl:call-template name="object.id">
  176.       <xsl:with-param name="object" select="$toc-context"/>
  177.     </xsl:call-template>
  178.   </xsl:variable>
  179.  
  180.   <xsl:call-template name="toc.line"/>
  181.  
  182.   <xsl:variable name="nodes" select="chapter|appendix|preface|reference"/>
  183.  
  184.   <xsl:if test="$toc.section.depth > 0 and $nodes">
  185.     <fo:block id="toc.{$cid}.{$id}"
  186.               start-indent="{count(ancestor::*)*$toc.indent.width}pt">
  187.       <xsl:apply-templates select="$nodes" mode="toc">
  188.         <xsl:with-param name="toc-context" select="$toc-context"/>
  189.       </xsl:apply-templates>
  190.     </fo:block>
  191.   </xsl:if>
  192. </xsl:template>
  193.  
  194. <xsl:template match="reference" mode="toc">
  195.   <xsl:param name="toc-context" select="."/>
  196.  
  197.   <xsl:variable name="id">
  198.     <xsl:call-template name="object.id"/>
  199.   </xsl:variable>
  200.  
  201.   <xsl:variable name="cid">
  202.     <xsl:call-template name="object.id">
  203.       <xsl:with-param name="object" select="$toc-context"/>
  204.     </xsl:call-template>
  205.   </xsl:variable>
  206.  
  207.   <xsl:call-template name="toc.line"/>
  208.  
  209.   <xsl:if test="$toc.section.depth > 0 and refentry">
  210.     <fo:block id="toc.{$cid}.{$id}"
  211.               start-indent="{count(ancestor::*)*$toc.indent.width}pt">
  212.       <xsl:apply-templates select="refentry" mode="toc">
  213.         <xsl:with-param name="toc-context" select="$toc-context"/>
  214.       </xsl:apply-templates>
  215.     </fo:block>
  216.   </xsl:if>
  217. </xsl:template>
  218.  
  219. <xsl:template match="refentry" mode="toc">
  220.   <xsl:param name="toc-context" select="."/>
  221.  
  222.   <xsl:call-template name="toc.line"/>
  223. </xsl:template>
  224.  
  225. <xsl:template match="preface|chapter|appendix|article"
  226.               mode="toc">
  227.   <xsl:param name="toc-context" select="."/>
  228.  
  229.   <xsl:variable name="id">
  230.     <xsl:call-template name="object.id"/>
  231.   </xsl:variable>
  232.  
  233.   <xsl:variable name="cid">
  234.     <xsl:call-template name="object.id">
  235.       <xsl:with-param name="object" select="$toc-context"/>
  236.     </xsl:call-template>
  237.   </xsl:variable>
  238.  
  239.   <xsl:call-template name="toc.line"/>
  240.  
  241.   <xsl:variable name="nodes" select="section|sect1"/>
  242.  
  243.   <xsl:if test="$toc.section.depth > 0 and $nodes">
  244.     <fo:block id="toc.{$cid}.{$id}"
  245.               start-indent="{count(ancestor::*)*$toc.indent.width}pt">
  246.       <xsl:apply-templates select="$nodes" mode="toc">
  247.         <xsl:with-param name="toc-context" select="$toc-context"/>
  248.       </xsl:apply-templates>
  249.     </fo:block>
  250.   </xsl:if>
  251. </xsl:template>
  252.  
  253. <xsl:template match="sect1" mode="toc">
  254.   <xsl:param name="toc-context" select="."/>
  255.  
  256.   <xsl:variable name="id">
  257.     <xsl:call-template name="object.id"/>
  258.   </xsl:variable>
  259.  
  260.   <xsl:variable name="cid">
  261.     <xsl:call-template name="object.id">
  262.       <xsl:with-param name="object" select="$toc-context"/>
  263.     </xsl:call-template>
  264.   </xsl:variable>
  265.  
  266.   <xsl:call-template name="toc.line"/>
  267.  
  268.   <xsl:if test="$toc.section.depth > 1 and sect2">
  269.     <fo:block id="toc.{$cid}.{$id}"
  270.               start-indent="{count(ancestor::*)*$toc.indent.width}pt">
  271.       <xsl:apply-templates select="sect2" mode="toc">
  272.         <xsl:with-param name="toc-context" select="$toc-context"/>
  273.       </xsl:apply-templates>
  274.     </fo:block>
  275.   </xsl:if>
  276. </xsl:template>
  277.  
  278. <xsl:template match="sect2" mode="toc">
  279.   <xsl:param name="toc-context" select="."/>
  280.  
  281.   <xsl:variable name="id">
  282.     <xsl:call-template name="object.id"/>
  283.   </xsl:variable>
  284.  
  285.   <xsl:variable name="cid">
  286.     <xsl:call-template name="object.id">
  287.       <xsl:with-param name="object" select="$toc-context"/>
  288.     </xsl:call-template>
  289.   </xsl:variable>
  290.  
  291.   <xsl:call-template name="toc.line"/>
  292.  
  293.   <xsl:if test="$toc.section.depth > 2 and sect3">
  294.     <fo:block id="toc.{$cid}.{$id}"
  295.               start-indent="{count(ancestor::*)*$toc.indent.width}pt">
  296.       <xsl:apply-templates select="sect3" mode="toc">
  297.         <xsl:with-param name="toc-context" select="$toc-context"/>
  298.       </xsl:apply-templates>
  299.     </fo:block>
  300.   </xsl:if>
  301. </xsl:template>
  302.  
  303. <xsl:template match="sect3" mode="toc">
  304.   <xsl:param name="toc-context" select="."/>
  305.  
  306.   <xsl:variable name="id">
  307.     <xsl:call-template name="object.id"/>
  308.   </xsl:variable>
  309.  
  310.   <xsl:variable name="cid">
  311.     <xsl:call-template name="object.id">
  312.       <xsl:with-param name="object" select="$toc-context"/>
  313.     </xsl:call-template>
  314.   </xsl:variable>
  315.  
  316.   <xsl:call-template name="toc.line"/>
  317.  
  318.   <xsl:if test="$toc.section.depth > 3 and sect4">
  319.     <fo:block id="toc.{$cid}.{$id}"
  320.               start-indent="{count(ancestor::*)*$toc.indent.width}pt">
  321.       <xsl:apply-templates select="sect4" mode="toc">
  322.         <xsl:with-param name="toc-context" select="$toc-context"/>
  323.       </xsl:apply-templates>
  324.     </fo:block>
  325.   </xsl:if>
  326. </xsl:template>
  327.  
  328. <xsl:template match="sect4" mode="toc">
  329.   <xsl:param name="toc-context" select="."/>
  330.  
  331.   <xsl:variable name="id">
  332.     <xsl:call-template name="object.id"/>
  333.   </xsl:variable>
  334.  
  335.   <xsl:variable name="cid">
  336.     <xsl:call-template name="object.id">
  337.       <xsl:with-param name="object" select="$toc-context"/>
  338.     </xsl:call-template>
  339.   </xsl:variable>
  340.  
  341.   <xsl:call-template name="toc.line"/>
  342.  
  343.   <xsl:if test="$toc.section.depth > 4 and sect5">
  344.     <fo:block id="toc.{$cid}.{$id}"
  345.               start-indent="{count(ancestor::*)*$toc.indent.width}pt">
  346.       <xsl:apply-templates select="sect5" mode="toc">
  347.         <xsl:with-param name="toc-context" select="$toc-context"/>
  348.       </xsl:apply-templates>
  349.     </fo:block>
  350.   </xsl:if>
  351. </xsl:template>
  352.  
  353. <xsl:template match="sect5" mode="toc">
  354.   <xsl:param name="toc-context" select="."/>
  355.  
  356.   <xsl:call-template name="toc.line"/>
  357. </xsl:template>
  358.  
  359. <xsl:template match="section" mode="toc">
  360.   <xsl:param name="toc-context" select="."/>
  361.  
  362.   <xsl:variable name="id">
  363.     <xsl:call-template name="object.id"/>
  364.   </xsl:variable>
  365.  
  366.   <xsl:variable name="cid">
  367.     <xsl:call-template name="object.id">
  368.       <xsl:with-param name="object" select="$toc-context"/>
  369.     </xsl:call-template>
  370.   </xsl:variable>
  371.  
  372.   <xsl:variable name="depth" select="count(ancestor::section) + 1"/>
  373.  
  374.   <xsl:if test="$toc.section.depth >= $depth">
  375.     <xsl:call-template name="toc.line"/>
  376.  
  377.     <xsl:if test="$toc.section.depth > $depth and section">
  378.       <fo:block id="toc.{$cid}.{$id}"
  379.                 start-indent="{count(ancestor::*)*$toc.indent.width}pt">
  380.         <xsl:apply-templates select="section" mode="toc">
  381.           <xsl:with-param name="toc-context" select="$toc-context"/>
  382.         </xsl:apply-templates>
  383.       </fo:block>
  384.     </xsl:if>
  385.   </xsl:if>
  386. </xsl:template>
  387.  
  388. <xsl:template match="bibliography|glossary"
  389.               mode="toc">
  390.   <xsl:param name="toc-context" select="."/>
  391.  
  392.   <xsl:call-template name="toc.line"/>
  393. </xsl:template>
  394.  
  395. <xsl:template match="index"
  396.               mode="toc">
  397.   <xsl:param name="toc-context" select="."/>
  398.  
  399.   <xsl:if test="* or $generate.index">
  400.     <xsl:call-template name="toc.line"/>
  401.   </xsl:if>
  402. </xsl:template>
  403.  
  404. <xsl:template match="title" mode="toc">
  405.   <xsl:apply-templates/>
  406. </xsl:template>
  407.  
  408. <!-- ==================================================================== -->
  409.  
  410. <xsl:template name="list.of.titles">
  411.   <xsl:param name="titles" select="'table'"/>
  412.   <xsl:param name="nodes" select=".//table"/>
  413.   <xsl:param name="toc-context" select="."/>
  414.  
  415.   <xsl:variable name="id">
  416.     <xsl:call-template name="object.id"/>
  417.   </xsl:variable>
  418.  
  419.   <xsl:if test="$nodes">
  420.     <fo:block id="lot...{$titles}...{$id}">
  421.       <xsl:choose>
  422.         <xsl:when test="$titles='table'">
  423.           <xsl:call-template name="list.of.tables.titlepage"/>
  424.         </xsl:when>
  425.         <xsl:when test="$titles='figure'">
  426.           <xsl:call-template name="list.of.figures.titlepage"/>
  427.         </xsl:when>
  428.         <xsl:when test="$titles='equation'">
  429.           <xsl:call-template name="list.of.equations.titlepage"/>
  430.         </xsl:when>
  431.         <xsl:when test="$titles='example'">
  432.           <xsl:call-template name="list.of.examples.titlepage"/>
  433.         </xsl:when>
  434.         <xsl:otherwise>
  435.           <xsl:call-template name="list.of.unknowns.titlepage"/>
  436.         </xsl:otherwise>
  437.       </xsl:choose>
  438.       <xsl:apply-templates select="$nodes" mode="toc">
  439.         <xsl:with-param name="toc-context" select="$toc-context"/>
  440.       </xsl:apply-templates>
  441.     </fo:block>
  442.   </xsl:if>
  443. </xsl:template>
  444.  
  445. <xsl:template match="figure|table|example|equation" mode="toc">
  446.   <xsl:call-template name="toc.line"/>
  447. </xsl:template>
  448.  
  449. <!-- ==================================================================== -->
  450.  
  451. </xsl:stylesheet>
  452.  
  453.