]> granicus.if.org Git - docbook-dsssl/commitdiff
Add support for xlink as olink.
authorBob Stayton <bobs@sagehill.net>
Sat, 14 Apr 2007 19:53:44 +0000 (19:53 +0000)
committerBob Stayton <bobs@sagehill.net>
Sat, 14 Apr 2007 19:53:44 +0000 (19:53 +0000)
xsl/fo/inline.xsl
xsl/fo/xref.xsl

index 959b096ba3549897f475c02f011c21846b9826b4..42817128c9fa38b252bfd488ecaae3b4dc7922d8 100644 (file)
@@ -41,7 +41,7 @@
                     and (not($node/@xlink:type) or 
                          $node/@xlink:type='simple')">
 
-      <!-- Is it a local idref or a uri? -->
+      <!-- Is it a local idref? -->
       <xsl:variable name="is.idref">
         <xsl:choose>
           <!-- if the href starts with # and does not contain an "(" -->
         </xsl:choose>
       </xsl:variable>
 
+      <!-- Is it an olink ? -->
+      <xsl:variable name="is.olink">
+        <xsl:choose>
+         <!-- If xlink:role="http://docbook.org/xlink/role/olink" -->
+          <!-- and if the href contains # -->
+          <xsl:when test="contains($xhref,'#') and
+              @xlink:role = $xolink.role">1</xsl:when>
+          <xsl:otherwise>0</xsl:otherwise>
+        </xsl:choose>
+      </xsl:variable>
+
       <xsl:choose>
         <xsl:when test="$is.idref = 1">
 
           </xsl:choose>
         </xsl:when>
 
+        <xsl:when test="$is.olink = 1">
+         <xsl:call-template name="olink">
+           <xsl:with-param name="content" select="$content"/>
+         </xsl:call-template>
+        </xsl:when>
+
         <!-- otherwise it's a URI -->
         <xsl:otherwise>
           <fo:basic-link external-destination="url({$xhref})">
index f5a56b345e975a357210d02d43fbb7265c59a8c2..87eaca0318dc82cd9e8df03b1837a1f3622570c2 100644 (file)
 
      ******************************************************************** -->
 
+<!-- Use internal variable for olink xlink role for consistency -->
+<xsl:variable 
+      name="xolink.role">http://docbook.org/xlink/role/olink</xsl:variable>
+
 <!-- ==================================================================== -->
 
 <xsl:template match="anchor">
 </xsl:template>
 
 <xsl:template match="olink" name="olink">
+  <!-- olink content may be passed in from xlink olink -->
+  <xsl:param name="content" select="NOTANELEMENT"/>
+
   <xsl:call-template name="anchor"/>
 
   <xsl:variable name="localinfo" select="@localinfo"/>
 
   <xsl:choose>
     <!-- olinks resolved by stylesheet and target database -->
-    <xsl:when test="@targetdoc or @targetptr" >
-      <xsl:variable name="targetdoc.att" select="@targetdoc"/>
-      <xsl:variable name="targetptr.att" select="@targetptr"/>
+    <xsl:when test="@targetdoc or @targetptr or
+                    (@xlink:role=$xolink.role and
+                     contains(@xlink:href, '#') )" >
+
+      <xsl:variable name="targetdoc.att">
+        <xsl:choose>
+          <xsl:when test="@targetdoc != ''">
+            <xsl:value-of select="@targetdoc"/>
+          </xsl:when>
+          <xsl:when test="@xlink:role=$xolink.role and
+                       contains(@xlink:href, '#')" >
+            <xsl:value-of select="substring-before(@xlink:href, '#')"/>
+          </xsl:when>
+        </xsl:choose>
+      </xsl:variable>
+
+      <xsl:variable name="targetptr.att">
+        <xsl:choose>
+          <xsl:when test="@targetptr != ''">
+            <xsl:value-of select="@targetptr"/>
+          </xsl:when>
+          <xsl:when test="@xlink:role=$xolink.role and
+                       contains(@xlink:href, '#')" >
+            <xsl:value-of select="substring-after(@xlink:href, '#')"/>
+          </xsl:when>
+        </xsl:choose>
+      </xsl:variable>
 
       <xsl:variable name="olink.lang">
         <xsl:call-template name="l10n.language">
       </xsl:variable>
 
       <xsl:variable name="hottext">
-        <xsl:call-template name="olink.hottext">
-          <xsl:with-param name="olink.key" select="$olink.key"/>
-          <xsl:with-param name="olink.lang" select="$olink.lang"/>
-          <xsl:with-param name="target.database" select="$target.database"/>
-        </xsl:call-template>
+        <xsl:choose>
+          <xsl:when test="$content">
+            <xsl:copy-of select="$content"/>
+          </xsl:when>
+          <xsl:otherwise>
+            <xsl:call-template name="olink.hottext">
+              <xsl:with-param name="olink.key" select="$olink.key"/>
+              <xsl:with-param name="olink.lang" select="$olink.lang"/>
+              <xsl:with-param name="target.database" select="$target.database"/>
+            </xsl:call-template>
+          </xsl:otherwise>
+        </xsl:choose>
       </xsl:variable>
 
       <xsl:variable name="olink.docname.citation">
   <xsl:param name="localinfo"/>
   <xsl:param name="return" select="href"/>
 
-  <xsl:message terminate="yes">Fatal error: what is this supposed to do?</xsl:message>
+  <xsl:message terminate="yes">Fatal error: olink.outline template: what is this supposed to do?</xsl:message>
 </xsl:template>
 
 <!-- ==================================================================== -->