poetry_print.xsl
branchstyles
changeset 15 27a2a404231e
parent 11 e2d28bf2a3bb
child 21 ce4faf661fca
--- a/poetry_print.xsl	Sat Feb 05 13:26:50 2011 -0500
+++ b/poetry_print.xsl	Mon Sep 14 11:24:14 2015 -0400
@@ -100,15 +100,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 +120,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 +233,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 +244,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>