]> granicus.if.org Git - docbook-dsssl/commitdiff
Implement active links between co and callout elements for
authorBob Stayton <bobs@sagehill.net>
Wed, 28 Nov 2012 00:47:59 +0000 (00:47 +0000)
committerBob Stayton <bobs@sagehill.net>
Wed, 28 Nov 2012 00:47:59 +0000 (00:47 +0000)
PDF output, linking in both directions.

xsl/fo/callout.xsl
xsl/fo/lists.xsl

index 025d4a536a3aecbbcf0275a0292216ec0bc53c1c..690bbc733a7ba7970e14714e0137eeb1cf52807c 100644 (file)
 </xsl:template>
 
 <xsl:template match="co">
-  <fo:inline>
-    <xsl:call-template name="anchor"/>
-    <xsl:apply-templates select="." mode="callout-bug"/>
-  </fo:inline>
+  <xsl:param name="coref"/> 
+  <!-- link to the callout? -->
+  <xsl:variable name="linkend">
+    <xsl:choose>
+      <!-- if more than one target, choose the first -->
+      <xsl:when test="contains(normalize-space(@linkends), ' ')">
+        <xsl:value-of select="substring-before(normalize-space(@linkends), ' ')"/>
+      </xsl:when>
+      <xsl:when test="string-length(normalize-space(@linkends)) != 0">
+        <xsl:value-of select="normalize-space(@linkends)"/>
+      </xsl:when>
+      <xsl:otherwise>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+
+  <xsl:choose>
+    <xsl:when test="string-length($linkend) != 0">
+      <fo:basic-link internal-destination="{$linkend}">
+        <xsl:choose>
+          <xsl:when test="$coref">
+            <xsl:call-template name="anchor">
+              <xsl:with-param name="node" select="$coref"/>
+              <xsl:with-param name="conditional" select="0"/>
+            </xsl:call-template>
+          </xsl:when>
+          <xsl:otherwise>
+            <xsl:call-template name="anchor">
+              <xsl:with-param name="conditional" select="0"/>
+            </xsl:call-template>
+          </xsl:otherwise>
+        </xsl:choose>
+        <xsl:apply-templates select="." mode="callout-bug"/>
+      </fo:basic-link>
+    </xsl:when>
+    <xsl:otherwise>
+      <fo:inline>
+        <xsl:choose>
+          <xsl:when test="$coref">
+            <xsl:call-template name="anchor">
+              <xsl:with-param name="node" select="$coref"/>
+              <xsl:with-param name="conditional" select="0"/>
+            </xsl:call-template>
+          </xsl:when>
+          <xsl:otherwise>
+            <xsl:call-template name="anchor">
+              <xsl:with-param name="conditional" select="0"/>
+            </xsl:call-template>
+          </xsl:otherwise>
+        </xsl:choose>
+        <xsl:apply-templates select="." mode="callout-bug"/>
+      </fo:inline>
+    </xsl:otherwise>
+  </xsl:choose>
 </xsl:template>
 
 <xsl:template match="coref">
-  <!-- tricky; this relies on the fact that we can process the "co" that's -->
+  <!-- this relies on the fact that we can process the "co" that's -->
   <!-- "over there" as if it were "right here" -->
 
   <xsl:variable name="co" select="key('id', @linkend)"/>
       </xsl:message>
     </xsl:when>
     <xsl:otherwise>
-      <fo:inline>
-        <xsl:call-template name="anchor"/>
-        <xsl:apply-templates select="$co" mode="callout-bug"/>
-      </fo:inline>
+      <!-- process it as if it were the co itself -->
+      <xsl:apply-templates select="$co">
+        <xsl:with-param name="coref" select="."/>
+      </xsl:apply-templates>
     </xsl:otherwise>
   </xsl:choose>
 </xsl:template>
index 87ba5f96b6bb5ade38e62c1ad8c8f50eb1b8c2a0..87151c8a124d72cccbdbfe80e51d494e1df97237 100644 (file)
       <xsl:text>: ???</xsl:text>
     </xsl:when>
     <xsl:when test="local-name($target)='co'">
-      <xsl:apply-templates select="$target" mode="callout-bug"/>
+      <fo:basic-link internal-destination="{$arearef}">
+        <xsl:apply-templates select="$target" mode="callout-bug"/>
+      </fo:basic-link>
     </xsl:when>
     <xsl:when test="local-name($target)='areaset'">
       <xsl:call-template name="callout-bug">