[yelp-xsl] Add DocBook 5 ubiquitous linking support.



commit aab048ff3a346061d890d95aa72cadbd5cf2b056
Author: brian m. carlson <sandals crustytoothpaste ath cx>
Date:   Wed Mar 10 20:33:49 2010 +0000

    Add DocBook 5 ubiquitous linking support.
    
    Signed-off-by: brian m. carlson <sandals crustytoothpaste ath cx>

 xslt/docbook/html/db2html-inline.xsl |   43 +++++++++++++++++++++++++++++++--
 xslt/docbook/html/db2html-xref.xsl   |    9 ++++++-
 2 files changed, 48 insertions(+), 4 deletions(-)
---
diff --git a/xslt/docbook/html/db2html-inline.xsl b/xslt/docbook/html/db2html-inline.xsl
index c9a110b..95e6957 100644
--- a/xslt/docbook/html/db2html-inline.xsl
+++ b/xslt/docbook/html/db2html-inline.xsl
@@ -18,8 +18,10 @@ Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 
 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
                 xmlns:msg="http://www.gnome.org/~shaunm/gnome-doc-utils/l10n";
+                xmlns:xl="http://www.w3.org/1999/xlink";
                 xmlns:db="http://docbook.org/ns/docbook";
                 xmlns="http://www.w3.org/1999/xhtml";
+                exclude-result-prefixes="db xl msg xsl"
                 version="1.0">
 
 <!--!!==========================================================================
@@ -30,6 +32,28 @@ REMARK: Describe this module
 -->
 <!--#% l10n.format.mode -->
 
+<!--**==========================================================================
+db2html.inline.children
+Renders the children of an inline element.
+$node: The element to render
+$children: The child elements to process
+
+REMARK: Document this template
+-->
+<xsl:template name="db2html.inline.children">
+  <xsl:param name="node" select="."/>
+  <xsl:param name="children" select="false()"/>
+
+  <xsl:choose>
+    <xsl:when test="$children">
+      <xsl:apply-templates select="$children"/>
+    </xsl:when>
+    <xsl:otherwise>
+      <xsl:apply-templates mode="db2html.inline.content.mode" select="$node"/>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
 
 <!--**==========================================================================
 db2html.inline
@@ -50,6 +74,8 @@ REMARK: Document this template
   <xsl:param name="lang" select="$node/@lang|$node/@xml:lang"/>
   <xsl:param name="dir" select="false()"/>
   <xsl:param name="ltr" select="false()"/>
+  <xsl:variable name="xlink" select="$node/@xl:href"/>
+  <xsl:variable name="linkend" select="$node/@linkend"/>
 
   <!-- FIXME: do CSS classes, rather than inline styles -->
   <span class="{$class} {local-name($node)}">
@@ -76,11 +102,22 @@ REMARK: Document this template
       <xsl:with-param name="node" select="$node"/>
     </xsl:call-template>
     <xsl:choose>
-      <xsl:when test="$children">
-        <xsl:apply-templates select="$children"/>
+      <xsl:when test="$xlink or $linkend">
+        <xsl:call-template name="db2html.xlink">
+          <xsl:with-param name="node" select="$node"/>
+          <xsl:with-param name="content">
+            <xsl:call-template name="db2html.inline.children">
+              <xsl:with-param name="node" select="$node"/>
+              <xsl:with-param name="children" select="$children"/>
+            </xsl:call-template>
+          </xsl:with-param>
+        </xsl:call-template>
       </xsl:when>
       <xsl:otherwise>
-        <xsl:apply-templates mode="db2html.inline.content.mode" select="$node"/>
+        <xsl:call-template name="db2html.inline.children">
+          <xsl:with-param name="node" select="$node"/>
+          <xsl:with-param name="children" select="$children"/>
+        </xsl:call-template>
       </xsl:otherwise>
     </xsl:choose>
   </span>
diff --git a/xslt/docbook/html/db2html-xref.xsl b/xslt/docbook/html/db2html-xref.xsl
index ed5639d..3ebd312 100644
--- a/xslt/docbook/html/db2html-xref.xsl
+++ b/xslt/docbook/html/db2html-xref.xsl
@@ -97,7 +97,12 @@ REMARK: Describe this template
       <xsl:call-template name="db.ulink.tooltip"/>
     </xsl:attribute>
     <xsl:choose>
-      <xsl:when test="$content">
+      <!--
+        Other templates, such as db2html.xlink (from ubiquitously linked
+        inlines) may pass us $content as a result tree fragment.  If $content
+        is empty, it may still be evaluated as true, which isn't what we want.
+        -->
+      <xsl:when test="$content and string-length($content) != 0">
         <xsl:copy-of select="$content"/>
       </xsl:when>
       <xsl:when test="string-length(normalize-space(node())) != 0">
@@ -114,6 +119,7 @@ REMARK: Describe this template
 <!--**==========================================================================
 db2html.xlink
 Generates a hyperlink from a DocBook 5 #{link} element
+$node: The node in question
 $linkend: The ID of the element to link to
 $url: The URL to link to
 $content: Optional content to use for the text of the link
@@ -125,6 +131,7 @@ Note that this template is also called for inline elements that use DocBook 5's
   <xsl:param name="linkend" select="$node/@linkend"/>
   <xsl:param name="url" select="$node/@xl:href"/>
   <xsl:param name="content" select="false()"/>
+
   <xsl:choose>
     <xsl:when test="$url">
       <xsl:call-template name="db2html.ulink">



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]