Index: main/plugin-cms/stylesheets/io/docbook2fo.xsl
===================================================================
--- main/plugin-cms/stylesheets/io/docbook2fo.xsl	(revision 28404)
+++ main/plugin-cms/stylesheets/io/docbook2fo.xsl	(working copy)
@@ -49,6 +49,12 @@
     <xsl:template match="docbook:section">
         <xsl:param name="level" />
         
+        <!-- Table of contents references -->
+        <xsl:variable name="ref"><xsl:call-template name="section-reference"/></xsl:variable>
+        <xsl:variable name="id" select="generate-id()"/>
+        
+        <fo:block id="{$id}-chapter-refid-{$ref}"></fo:block>
+        
         <xsl:if test="docbook:title/text()">
            	<fo:block>
            		<xsl:call-template name="title-style">
@@ -419,6 +443,123 @@
     <xsl:template match="html:toc">
     </xsl:template>
     
+    <!-- Table of contents -->
+    <xsl:template match="docbook:para[html:toc]">
+         <xsl:if test="following-sibling::docbook:section">
+             <xsl:apply-templates select="following-sibling::docbook:section" mode="toc"/>
+         </xsl:if>
+    </xsl:template>
+    
+    <!-- Section -->
+    <xsl:template match="docbook:section" mode="toc">
+        <fo:block margin-top="0.2cm" margin-right="1.2cm" margin-left="1.2cm" text-align='justify' text-align-last="justify" space-after="3pt">
+            <xsl:call-template name="toc-section"/>
+        </fo:block>
+
+        <xsl:apply-templates select="docbook:section" mode="toc_subsection"/>
+    </xsl:template>
+    
+    <!-- Subsection -->
+    <xsl:template match="docbook:section" mode="toc_subsection">
+    
+        <fo:block margin-right="1.2cm" margin-left="2cm" text-align='justify' text-align-last="justify" space-after="3pt">
+            <xsl:call-template name="toc-subsection"/>
+        </fo:block>
+        <xsl:apply-templates select="docbook:section" mode="toc_subsubsection"/>
+            
+    </xsl:template>
+    
+    <!-- Subsubsection -->
+    <xsl:template match="docbook:section" mode="toc_subsubsection">
+        <fo:block margin-right="1.2cm" margin-left="2.8cm" text-align='justify' text-align-last="justify" space-after="3pt">
+            <xsl:call-template name="toc-subsubsection"/>
+        </fo:block>
+    </xsl:template>
+    
+    <!-- Toc section -->
+    <xsl:template name="toc-section">
+	    <fo:basic-link margin-top="0.7cm" font-size="14px">
+		    <xsl:variable name="ref"><xsl:call-template name="section-reference"/></xsl:variable>
+		    <xsl:variable name="id" select="generate-id()"/>
+            
+		    <xsl:attribute name='internal-destination'><xsl:value-of select="$id"/>-chapter-refid-<xsl:value-of select="$ref"/></xsl:attribute>
+		    
+		    <xsl:call-template name="section-number"/><xsl:value-of select="docbook:title"/>
+		    &#160;<fo:leader leader-pattern='dots' rule-thickness='.2pt' leader-alignment='reference-area' font-size="10pt"/>&#160;
+		    
+		    <fo:page-number-citation>
+		        <xsl:attribute name='ref-id'><xsl:value-of select="$id"/>-chapter-refid-<xsl:value-of select="$ref"/></xsl:attribute>
+		    </fo:page-number-citation>
+        </fo:basic-link>
+    </xsl:template>
+    
+    <!-- Toc subsection -->
+    <xsl:template name="toc-subsection">
+        <fo:basic-link margin-top="0.7cm" font-size="14px">
+            <xsl:variable name="ref"><xsl:call-template name="subsection-reference"/></xsl:variable>
+            <xsl:variable name="id" select="generate-id()"/>
+            
+            <xsl:attribute name='internal-destination'><xsl:value-of select="$id"/>-chapter-refid-<xsl:value-of select="$ref"/></xsl:attribute>
+            
+            <xsl:call-template name="subsection-number"/><xsl:value-of select="docbook:title"/>
+            &#160;<fo:leader leader-pattern='dots' rule-thickness='.2pt' leader-alignment='reference-area' font-size="10pt"/>&#160;
+            
+            <fo:page-number-citation>
+                <xsl:attribute name='ref-id'><xsl:value-of select="$id"/>-chapter-refid-<xsl:value-of select="$ref"/></xsl:attribute>
+            </fo:page-number-citation>
+        </fo:basic-link>
+    </xsl:template>
+    
+    <!-- Toc subsubsection -->
+    <xsl:template name="toc-subsubsection">
+        <fo:basic-link margin-top="0.7cm" font-size="14px">
+            <xsl:variable name="ref"><xsl:call-template name="subsubsection-reference"/></xsl:variable>
+            <xsl:variable name="id" select="generate-id()"/>
+            
+            <xsl:attribute name='internal-destination'><xsl:value-of select="$id"/>-chapter-refid-<xsl:value-of select="$ref"/></xsl:attribute>
+            
+            <xsl:call-template name="subsubsection-number"/><xsl:value-of select="docbook:title"/>
+            &#160;<fo:leader leader-pattern='dots' rule-thickness='.2pt' leader-alignment='reference-area' font-size="10pt"/>&#160;
+            
+            <fo:page-number-citation>
+                <xsl:attribute name='ref-id'><xsl:value-of select="$id"/>-chapter-refid-<xsl:value-of select="$ref"/></xsl:attribute>
+            </fo:page-number-citation>
+        </fo:basic-link>
+    </xsl:template>
+        
+    <xsl:template name="section-number">
+	   <xsl:number value="position()" format="1. "/>
+    </xsl:template>
+    
+    <xsl:template name="section-reference">
+        <xsl:number level="multiple" format="1"/>
+    </xsl:template>
+    
+    <xsl:template name="subsection-number">
+        <xsl:variable name="parent-position">
+            <xsl:value-of select="count(../preceding-sibling::docbook:section) + 1"/>
+        </xsl:variable>
+        <xsl:value-of select="$parent-position"/>.<xsl:value-of select="position()"/><xsl:text> </xsl:text>
+    </xsl:template>
+    
+    <xsl:template name="subsection-reference">
+        <xsl:number level="multiple" format="1.1"/>
+    </xsl:template>
+    
+    <xsl:template name="subsubsection-number">
+        <xsl:variable name="parent-parent-position">
+            <xsl:value-of select="count(../../preceding-sibling::docbook:section) + 1"/>
+        </xsl:variable>
+        <xsl:variable name="parent-position">
+            <xsl:value-of select="count(../preceding-sibling::docbook:section) + 1"/>
+        </xsl:variable>
+        <xsl:value-of select="$parent-parent-position"/>.<xsl:value-of select="$parent-position"/>.<xsl:value-of select="position()"/><xsl:text> </xsl:text>
+    </xsl:template>
+    
+    <xsl:template name="subsubsection-reference">
+        <xsl:number level="multiple" format="1.1.1"/>
+    </xsl:template>
+    
     <!-- +
          | Default style
          + -->
