poetry_print.xsl
branchstyles
changeset 24 acf70691eb31
parent 21 ce4faf661fca
--- a/poetry_print.xsl	Tue Dec 29 21:26:32 2015 -0500
+++ b/poetry_print.xsl	Tue Dec 29 21:32:40 2015 -0500
@@ -66,11 +66,17 @@
 	</xsl:with-param>
       </xsl:call-template>
       <xsl:variable name="id">
-	<xsl:call-template name="get-id"/>
+	    <xsl:call-template name="get-id"/>
       </xsl:variable>
       <flow flow-name="xsl-region-body">
-	<block id="{$id}"/>
-	<xsl:apply-templates select="*[name(.)!='section']"/>
+	    <block id="{$id}"/>
+	    <xsl:apply-templates select="*[name(.)!='section']"/>
+        <block space-before="4pt">
+          <inline font-weight="bold">Table des matières</inline>
+          <list-block provisional-distance-between-starts="5mm">
+            <xsl:apply-templates select="section|story|poetry" mode="toc"/>
+          </list-block>
+        </block>
       </flow>
     </page-sequence>
     <xsl:apply-templates select="section"/> 
@@ -100,15 +106,15 @@
     </xsl:variable>
     <flow flow-name="xsl-region-body">
       <block>
-	<xsl:if test="name(.) != 'poetry'">
-	  <xsl:attribute name="id"><xsl:value-of select="$id"/></xsl:attribute>
-	</xsl:if>
-	<xsl:apply-templates select="*[not(poetry)][name(.)!='poetry']"/>
-	<xsl:if test="section[poetry]">
-	<list-block text-indent="15mm" space-before="15pt">
-	  <xsl:apply-templates select="section[poetry]" mode="toc"/>
-	</list-block>
-      </xsl:if>
+	    <xsl:if test="name(.) != 'poetry'">
+	      <xsl:attribute name="id"><xsl:value-of select="$id"/></xsl:attribute>
+	    </xsl:if>
+	    <xsl:apply-templates select="*[not(poetry)][name(.)!='poetry']"/>
+	    <xsl:if test="section[poetry]">
+	      <list-block text-indent="15mm" space-before="15pt">
+	        <xsl:apply-templates select="section[poetry]" mode="toc"/>
+	      </list-block>
+        </xsl:if>
       </block>
     </flow>    
   </page-sequence>
@@ -120,7 +126,7 @@
     <xsl:call-template name="list-label"/>
     <list-item-body start-indent="body-start()">
       <block>
-	<xsl:apply-templates select="." mode="xref"/>
+	    <xsl:apply-templates select="." mode="toc-xref"/>
       </block>
     </list-item-body>
   </list-item>
@@ -233,7 +239,7 @@
   <xsl:apply-templates/>
 </xsl:template>
 
-<xsl:template match="poetry|section" mode="xref">
+<xsl:template match="poetry|section" mode="toc-xref">
   <xsl:variable name="id">
     <xsl:call-template name="get-id"/>
   </xsl:variable>
@@ -244,9 +250,26 @@
     </basic-link>
 </xsl:template>
 
+<xsl:template match="list[@role='toc']/item/xref">
+  <xsl:variable name="linkend" select="@linkend"/>
+  <xsl:apply-templates mode="toc-xref" select="//*[@id=$linkend]"/>
+</xsl:template>
+
 <xsl:template match="xref">
   <xsl:variable name="linkend" select="@linkend"/>
-  <xsl:apply-templates mode="xref" select="//*[@id=$linkend]"/>
+  <xsl:variable name="linkterm">
+    <xsl:choose>
+      <xsl:when test="@linkterm"><xsl:value-of select="@linkterm"/></xsl:when>
+      <xsl:otherwise><xsl:value-of select="@linkend"/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+    <basic-link internal-destination="{$linkend}">
+      <xsl:apply-templates mode="xref" select="//*[@id=$linkterm]"/>
+    </basic-link>
+</xsl:template>
+    
+<xsl:template match="poetry|section" mode="xref">
+  <xsl:value-of select="descendant::title[1]"/>
 </xsl:template>
 
 </xsl:stylesheet>