]> granicus.if.org Git - docbook-dsssl/commitdiff
Add parameter 'activate.external.olinks' to allow making
authorBob Stayton <bobs@sagehill.net>
Fri, 19 Oct 2012 21:16:44 +0000 (21:16 +0000)
committerBob Stayton <bobs@sagehill.net>
Fri, 19 Oct 2012 21:16:44 +0000 (21:16 +0000)
external olinks inactive, as for epub output.

xsl/common/olink.xsl
xsl/epub3/epub3-element-mods.xsl
xsl/fo/param.ent
xsl/fo/param.xweb
xsl/html/param.ent
xsl/html/param.xweb
xsl/params/activate.external.olinks.xml [new file with mode: 0755]

index c892dd7472d96d860fb556bd9d1c50ac4aedab84..bfb95a45544df472d58fe5a93c33fcebe814474b 100644 (file)
       </xsl:choose>
     </xsl:variable>
   
+    <!-- Is this olink to be active? -->
+    <xsl:variable name="active.olink">
+      <xsl:choose>
+        <xsl:when test="$activate.external.olinks = 0">
+          <xsl:choose>
+            <xsl:when test="$current.docid = ''">1</xsl:when>
+            <xsl:when test="$targetdoc = ''">1</xsl:when>
+            <xsl:when test="$targetdoc = $current.docid">1</xsl:when>
+            <xsl:otherwise>0</xsl:otherwise>
+          </xsl:choose>
+        </xsl:when>
+        <xsl:otherwise>1</xsl:otherwise>
+      </xsl:choose>
+    </xsl:variable>
+
     <!-- Form the href information -->
-    <xsl:if test="$baseuri != ''">
-      <xsl:value-of select="$baseuri"/>
-      <xsl:if test="substring($target.href,1,1) != '#'">
-        <!--xsl:text>/</xsl:text-->
+    <xsl:if test="$active.olink != 0">
+      <xsl:if test="$baseuri != ''">
+        <xsl:value-of select="$baseuri"/>
+        <xsl:if test="substring($target.href,1,1) != '#'">
+          <!--xsl:text>/</xsl:text-->
+        </xsl:if>
+      </xsl:if>
+      <!-- optionally turn off frag for PDF references -->
+      <xsl:if test="not($insert.olink.pdf.frag = 0 and
+            translate(substring($baseuri, string-length($baseuri) - 3),
+                      'PDF', 'pdf') = '.pdf'
+            and starts-with($target.href, '#') )">
+        <xsl:value-of select="$target.href"/>
       </xsl:if>
-    </xsl:if>
-    <!-- optionally turn off frag for PDF references -->
-    <xsl:if test="not($insert.olink.pdf.frag = 0 and
-          translate(substring($baseuri, string-length($baseuri) - 3),
-                    'PDF', 'pdf') = '.pdf'
-          and starts-with($target.href, '#') )">
-      <xsl:value-of select="$target.href"/>
     </xsl:if>
   </xsl:if>
 </xsl:template>
index 64f2629461fcf2a29944be7771d280fe6ffbaf2f..445146c8f5ffd42b529a64bdf657a1085f3442e1 100644 (file)
@@ -52,6 +52,9 @@ article  toc,title,figure,table,example,equation
 <xsl:param name="base.dir" select="'OEBPS/'"/>
 <xsl:param name="index.links.to.section" select="0"/>
 
+<!-- Epub does not yet support external links -->
+<xsl:param name="activate.external.olinks" select="0"/>
+
 <!-- Turning this on crashes ADE, which is unbelievably awesome -->
 <xsl:param name="formal.object.break.after">0</xsl:param>
 
index 79de10b11af4d885a6eabeba3482cee09091bbaa..6ee9ad27a29746280bf4d685e303007155ce811a 100644 (file)
 <!ENTITY region.outer.properties SYSTEM "../params/region.outer.properties.xml">
 <!ENTITY table.caption.properties SYSTEM "../params/table.caption.properties.xml">
 <!ENTITY para.properties SYSTEM "../params/para.properties.xml">
+<!ENTITY activate.external.olinks SYSTEM "../params/activate.external.olinks.xml">
index a65ff7b318c750767a00dbf293ea3726cd0790cf..0f0f8a85cf13f56a70e8d4b679884786736fd7f6 100644 (file)
@@ -167,6 +167,7 @@ generate.section.toc.level;
 </reference>
 <reference xml:id="links"><title>Linking</title>
 &current.docid;
+&activate.external.olinks;
 &collect.xref.targets;
 &insert.olink.page.number;
 &insert.olink.pdf.frag;
@@ -564,6 +565,7 @@ around all these parameters.</para>
 
 <src:fragref linkend="abstract.properties.frag"/>
 <src:fragref linkend="abstract.title.properties.frag"/>
+<src:fragref linkend="activate.external.olinks.frag"/>
 <src:fragref linkend="admon.graphics.extension.frag"/>
 <src:fragref linkend="admon.graphics.frag"/>
 <src:fragref linkend="admon.graphics.path.frag"/>
index 8434ea6705a104db0486770f042a47e25dea128c..23bfb38d64d02dded746b1172445a587c92b365b 100644 (file)
 <!ENTITY webhelp.indexer.language   SYSTEM "../params/webhelp.indexer.language.xml">
 <!ENTITY webhelp.start.filename     SYSTEM "../params/webhelp.start.filename.xml">
 <!ENTITY webhelp.tree.cookie.id     SYSTEM "../params/webhelp.tree.cookie.id.xml">
+<!ENTITY activate.external.olinks     SYSTEM "../params/activate.external.olinks.xml">
index c16c328b88a65d6030dde6f474ee3c031b98ca2a..7a719aa96aa344160df9d718fa9807f3f718d222 100644 (file)
@@ -208,6 +208,7 @@ $Id$
 &use.local.olink.style;
 &current.docid;
 &olink.doctitle;
+&activate.external.olinks;
 &olink.debug;
 &olink.properties;
 &olink.lang.fallback.sequence;
@@ -457,6 +458,7 @@ around all these parameters.</para>
      ******************************************************************** -->
 
 <src:fragref linkend="abstract.notitle.enabled.frag"/>
+<src:fragref linkend="activate.external.olinks.frag"/>
 <src:fragref linkend="admon.graphics.extension.frag"/>
 <src:fragref linkend="admon.graphics.frag"/>
 <src:fragref linkend="admon.graphics.path.frag"/>
diff --git a/xsl/params/activate.external.olinks.xml b/xsl/params/activate.external.olinks.xml
new file mode 100755 (executable)
index 0000000..a28686c
--- /dev/null
@@ -0,0 +1,69 @@
+<refentry xmlns="http://docbook.org/ns/docbook"
+          xmlns:xlink="http://www.w3.org/1999/xlink"
+          xmlns:xi="http://www.w3.org/2001/XInclude"
+          xmlns:src="http://nwalsh.com/xmlns/litprog/fragment"
+          xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+          version="5.0" xml:id="activate.external.olinks">
+<refmeta>
+<refentrytitle>activate.external.olinks</refentrytitle>
+<refmiscinfo class="other" otherclass="datatype">boolean</refmiscinfo>
+</refmeta>
+<refnamediv>
+<refname>activate.external.olinks</refname>
+<refpurpose>Make external olinks into active links</refpurpose>
+</refnamediv>
+
+<refsynopsisdiv>
+<src:fragment xml:id="activate.external.olinks.frag">
+<xsl:param name="activate.external.olinks" select="1"/>
+</src:fragment>
+</refsynopsisdiv>
+
+<refsection><info><title>Description</title></info>
+
+<para>If <parameter>activate.external.olinks</parameter> is nonzero
+(the default), then any olinks that reference another document
+become active links that can be clicked on to follow the link.
+If the parameter is set to zero, then external olinks
+will have the appropriate link text generated, but the link is
+not made active.  Olinks to destinations in
+the current document remain active.</para>
+
+<para>To make an external olink active for HTML
+outputs, the link text is wrapped in an <tag>a</tag>
+element with an <tag>href</tag> attribute. To
+make an external olink active for FO outputs, the link text is
+wrapped in an <tag>fo:basic-link</tag> element with an
+<tag>external-destination</tag> attribute.</para>
+
+<para>This parameter is useful when you need external olinks
+to resolve but not be clickable. For example, if documents
+in a collection are available independently of each other,
+then having active links between them could lead to
+unresolved links when a given target document is missing.</para>
+
+<para>The epub stylesheets set this parameter to zero by default
+because there is no standard linking mechanism between Epub documents.</para>
+
+<para>If external links are made inactive, you should
+consider setting the
+stylesheet parameter <parameter>olink.doctitle</parameter>
+to <literal>yes</literal>. That will append the external document's
+title to the link text, making it easier for the user to
+locate the other document.</para>
+
+<para>An olink is considered external when the
+<parameter>current.docid</parameter> stylesheet parameter
+is set to some value, and the olink's <tag>targetdoc</tag>
+attribute has a different value. If the two values
+match, then the link is considered internal.  If the
+<parameter>current.docid</parameter> parameter is blank, or
+the <tag>olink</tag> element does not have a <tag>targetdoc</tag> attribute,
+then the link is considered to be internal and will become
+an active link.</para>
+
+<para>See also <parameter>olink.doctitle</parameter>,
+<parameter>prefer.internal.olink</parameter>.</para>
+
+</refsection>
+</refentry>