More support for link. styles
authorFabien Ninoles <fabien@tzone.org>
Mon, 14 Sep 2015 11:24:14 -0400
branchstyles
changeset 15 27a2a404231e
parent 11 e2d28bf2a3bb
child 16 357ad8c99f4a
More support for link.
TODO
html.xsl
poetry_html.xsl
poetry_print.xsl
print.xsl
--- a/TODO	Sat Feb 05 13:26:50 2011 -0500
+++ b/TODO	Mon Sep 14 11:24:14 2015 -0400
@@ -1,4 +1,4 @@
 * Finir la version imprimable (book)
 * Faire une version 1/pdf/contes.
 * Faire une version HTML-1-PAGE (pour la version texte).
-* Rajouter les xlink, xref, olink, oref...
+* Rajouter les link, xref, olink, oref...
--- a/html.xsl	Sat Feb 05 13:26:50 2011 -0500
+++ b/html.xsl	Mon Sep 14 11:24:14 2015 -0400
@@ -300,7 +300,7 @@
   <xsl:value-of select="title/text()"/>
 </xsl:template>
 
-<xsl:template match="section|story|poetry" mode="navbar-link">
+<xsl:template match="section|story|poetry" mode="href">
   <xsl:call-template name="get-id"/>
 </xsl:template>
 
@@ -308,7 +308,7 @@
   <xsl:param name="prefix"></xsl:param>
   <a>
     <xsl:attribute name="href">
-      <xsl:apply-templates select="." mode="navbar-link"/>
+      <xsl:apply-templates select="." mode="href"/>
       <xsl:text>.html</xsl:text>
     </xsl:attribute>
     <xsl:value-of select="$prefix"/>
@@ -460,6 +460,17 @@
 
 <xsl:template match="*" mode="xref"/>
 
+<xsl:template match="link">
+  <xsl:variable name="linkend" select="@linkend"/>
+  <a>
+    <xsl:attribute name="href">
+      <xsl:apply-templates select="//*[@id=$linkend]" mode="href"/>
+      <xsl:text>.html</xsl:text>
+    </xsl:attribute>
+    <xsl:apply-templates/>
+  </a>
+</xsl:template>
+
 <xsl:template match="section/title"/>
 <xsl:template match="section/subtitle"/>
 
--- a/poetry_html.xsl	Sat Feb 05 13:26:50 2011 -0500
+++ b/poetry_html.xsl	Mon Sep 14 11:24:14 2015 -0400
@@ -54,25 +54,25 @@
   <ul class="navbar">
     <xsl:for-each select="//xref[@linkend=$my-id]">
       <li>
-	<xsl:variable name="mysection" select="ancestor::section[last()]/@id"/>
-	<xsl:for-each select="ancestor::section">
-	  <xsl:apply-templates select="." mode="xref"/>
-	  <xsl:if test="descendant::section">
-	    <xsl:text> : </xsl:text>
-	  </xsl:if>
-	</xsl:for-each>
-	<ul>
-	  <xsl:if test="preceding::xref[1]/ancestor::section[last()]/@id=$mysection">
-	    <li><xsl:text>Précédent: </xsl:text>
-	    <xsl:apply-templates select="preceding::xref[1]"/>
-	    </li>
-	  </xsl:if>
-	  <xsl:if test="following::xref[1]/ancestor::section[last()]/@id=$mysection">
-	    <li><xsl:text>Suivant: </xsl:text>
-	    <xsl:apply-templates select="following::xref[1]"/>
-	    </li>
-	  </xsl:if>
-	</ul>
+	    <xsl:variable name="mysection" select="ancestor::section[last()]/@id"/>
+	    <xsl:for-each select="ancestor::section">
+	      <xsl:apply-templates select="." mode="xref"/>
+	      <xsl:if test="descendant::section">
+	        <xsl:text> : </xsl:text>
+	      </xsl:if>
+	    </xsl:for-each>
+	    <ul>
+	      <xsl:if test="preceding::xref[1]/ancestor::section[last()]/@id=$mysection">
+	        <li><xsl:text>Précédent: </xsl:text>
+	        <xsl:apply-templates select="preceding::xref[1]"/>
+	        </li>
+	      </xsl:if>
+	      <xsl:if test="following::xref[1]/ancestor::section[last()]/@id=$mysection">
+	        <li><xsl:text>Suivant: </xsl:text>
+	        <xsl:apply-templates select="following::xref[1]"/>
+	        </li>
+	      </xsl:if>
+	    </ul>
       </li>
     </xsl:for-each>
   </ul>
--- 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>
--- a/print.xsl	Sat Feb 05 13:26:50 2011 -0500
+++ b/print.xsl	Mon Sep 14 11:24:14 2015 -0400
@@ -150,6 +150,13 @@
   <inline vertical-align="super" font-size="60%"><xsl:apply-templates/></inline>
 </xsl:template>
 
+<xsl:template match="link">
+  <xsl:variable name="linkend" select="@linkend"/>
+  <basic-link internal-destination="{$linkend}">
+    <xsl:apply-templates/>
+  </basic-link>  
+</xsl:template>
+
 </xsl:stylesheet>
 
 <!-- Keep this comment at the end of the file