[yelp-xsl] dita: Starting to support conref



commit d72a8d05569515a36a8b0d568774358143ffba21
Author: Shaun McCance <shaunm gnome org>
Date:   Thu Oct 4 11:27:40 2012 -0400

    dita: Starting to support conref

 xslt/dita/common/dita-ref.xsl                      |  100 ++++++++++++++++++++
 .../selectors.mod => common/dita-selectors.mod}    |    0
 xslt/dita/html/dita2html-block.xsl                 |   27 ++++--
 xslt/dita/html/dita2html-inline.xsl                |    2 +-
 xslt/dita/html/dita2html-list.xsl                  |    2 +-
 xslt/dita/html/dita2html-topic.xsl                 |    2 +-
 xslt/dita/html/dita2xhtml.xsl                      |   21 +----
 7 files changed, 123 insertions(+), 31 deletions(-)
---
diff --git a/xslt/dita/common/dita-ref.xsl b/xslt/dita/common/dita-ref.xsl
new file mode 100644
index 0000000..4df1dfc
--- /dev/null
+++ b/xslt/dita/common/dita-ref.xsl
@@ -0,0 +1,100 @@
+<?xml version='1.0' encoding='UTF-8'?><!-- -*- indent-tabs-mode: nil -*- -->
+<!--
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GNU Lesser General Public License as published by the Free
+Software Foundation; either version 2 of the License, or (at your option) any
+later version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+details.
+
+You should have received a copy of the GNU Lesser General Public License
+along with this program; see the file COPYING.LGPL.  If not, write to the
+Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+02111-1307, USA.
+-->
+<!DOCTYPE xsl:stylesheet [
+<!ENTITY % selectors SYSTEM "dita-selectors.mod">
+%selectors;
+]>
+
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
+                xmlns:func="http://exslt.org/functions";
+                xmlns="http://www.w3.org/1999/xhtml";
+                extension-element-prefixes="func"
+                version="1.0">
+
+<!--!!==========================================================================
+DITA References
+
+REMARK: Describe this module
+-->
+
+<xsl:key name="dita.id.key" match="&topic_topic_all;[ id]" use="@id"/>
+<xsl:key name="dita.id.key" match="*[ id][not(self::&topic_topic_all;)]"
+         use="concat(ancestor-or-self::&topic_topic_all;[1]/@id, '/', @id)"/>
+
+<xsl:template name="dita.ref.conref.attr">
+  <xsl:param name="attr"/>
+  <xsl:param name="node"/>
+  <xsl:param name="conref" select="yelp:dita.ref.conref($node)"/>
+  <xsl:variable name="val" select="$node/attribute::*[name(.) = $attr]"/>
+  <xsl:choose>
+    <xsl:when test="$val = '-dita-use-conref-target'">
+      <xsl:value-of select="$conref/attribute::*[name(.) = $attr]"/>
+    </xsl:when>
+    <xsl:otherwise>
+      <xsl:value-of select="$val"/>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<func:function xmlns:yelp="http://projects.gnome.org/yelp/"; name="yelp:dita.ref.conref">
+  <xsl:param name="node" select="."/>
+  <xsl:choose>
+    <xsl:when test="not($node/@conref)">
+      <func:result select="$node"/>
+    </xsl:when>
+    <xsl:when test="starts-with($node/@conref, '#')">
+      <func:result select="key('dita.id.key', substring-after($node/@conref, '#'))"/>
+    </xsl:when>
+    <xsl:otherwise>
+      <xsl:variable name="uri">
+        <xsl:choose>
+          <xsl:when test="contains($node/@conref, '#')">
+            <xsl:value-of select="substring-before($node/@conref, '#')"/>
+          </xsl:when>
+          <xsl:otherwise>
+            <xsl:value-of select="$node/@conref"/>
+          </xsl:otherwise>
+        </xsl:choose>
+      </xsl:variable>
+      <xsl:for-each select="document($uri, $node)">
+        <xsl:choose>
+          <xsl:when test="contains($node/@conref, '#')">
+            <func:result select="key('dita.id.key', substring-after($node/@conref, '#'))"/>
+          </xsl:when>
+          <xsl:otherwise>
+            <func:result select="/*"/>
+          </xsl:otherwise>
+        </xsl:choose>
+      </xsl:for-each>
+    </xsl:otherwise>
+  </xsl:choose>
+</func:function>
+
+<!--
+<xsl:template name="dita.conref.node">
+  <xsl:param name="node" select="."/>
+  <xsl:choose>
+    <xsl:when test="$node/@conref">
+    </xsl:when>
+    <xsl:otherwise>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+-->
+
+</xsl:stylesheet>
diff --git a/xslt/dita/html/selectors.mod b/xslt/dita/common/dita-selectors.mod
similarity index 100%
rename from xslt/dita/html/selectors.mod
rename to xslt/dita/common/dita-selectors.mod
diff --git a/xslt/dita/html/dita2html-block.xsl b/xslt/dita/html/dita2html-block.xsl
index 80ac293..29285a9 100644
--- a/xslt/dita/html/dita2html-block.xsl
+++ b/xslt/dita/html/dita2html-block.xsl
@@ -16,12 +16,14 @@ Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 02111-1307, USA.
 -->
 <!DOCTYPE xsl:stylesheet [
-<!ENTITY % selectors SYSTEM "selectors.mod">
+<!ENTITY % selectors SYSTEM "../common/dita-selectors.mod">
 %selectors;
 ]>
 
 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
+                xmlns:yelp="http://projects.gnome.org/yelp/";
                 xmlns="http://www.w3.org/1999/xhtml";
+                exclude-result-prefixes="yelp"
                 version="1.0">
 
 <!--!!==========================================================================
@@ -82,17 +84,25 @@ REMARK: Describe this module
 
 <!-- = note = -->
 <xsl:template mode="dita2html.topic.mode" match="&topic_note;">
+  <xsl:variable name="conref" select="yelp:dita.ref.conref(.)"/>
+  <xsl:variable name="type">
+    <xsl:call-template name="dita.ref.conref.attr">
+      <xsl:with-param name="attr" select="'type'"/>
+      <xsl:with-param name="node" select="."/>
+      <xsl:with-param name="conref" select="$conref"/>
+    </xsl:call-template>
+  </xsl:variable>
   <xsl:variable name="notetype">
     <xsl:choose>
-      <xsl:when test="@type = 'attention' or @type = 'important' or
-                      @type = 'remember' or @type = 'restriction'">
+      <xsl:when test="$type = 'attention' or $type = 'important' or
+                      $type = 'remember' or $type = 'restriction'">
         <xsl:text>important</xsl:text>
       </xsl:when>
-      <xsl:when test="@type = 'caution' or @type = 'danger' or
-                      @type = 'notice' or @type = 'warning'">
+      <xsl:when test="$type = 'caution' or $type = 'danger' or
+                      $type = 'notice' or $type = 'warning'">
         <xsl:text>warning</xsl:text>
       </xsl:when>
-      <xsl:when test="@type = 'fastpath' or @type = 'tip'">
+      <xsl:when test="$type = 'fastpath' or $type = 'tip'">
         <xsl:text>tip</xsl:text>
       </xsl:when>
     </xsl:choose>
@@ -110,7 +120,7 @@ REMARK: Describe this module
     <div class="inner">
       <div class="region">
         <div class="contents">
-          <xsl:apply-templates mode="dita2html.topic.mode"/>
+          <xsl:apply-templates mode="dita2html.topic.mode" select="$conref/node()"/>
         </div>
       </div>
     </div>
@@ -155,10 +165,11 @@ REMARK: Describe this module
 
 <!-- = section = -->
 <xsl:template mode="dita2html.topic.mode" match="&topic_section;">
+  <xsl:variable name="conref" select="yelp:dita.ref.conref(.)"/>
   <div class="section">
     <xsl:copy-of select="@id"/>
     <xsl:call-template name="html.lang.attrs"/>
-    <xsl:apply-templates mode="dita2html.topic.mode"/>
+    <xsl:apply-templates mode="dita2html.topic.mode" select="$conref/node()"/>
   </div>
 </xsl:template>
 
diff --git a/xslt/dita/html/dita2html-inline.xsl b/xslt/dita/html/dita2html-inline.xsl
index 4dea195..63426af 100644
--- a/xslt/dita/html/dita2html-inline.xsl
+++ b/xslt/dita/html/dita2html-inline.xsl
@@ -16,7 +16,7 @@ Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 02111-1307, USA.
 -->
 <!DOCTYPE xsl:stylesheet [
-<!ENTITY % selectors SYSTEM "selectors.mod">
+<!ENTITY % selectors SYSTEM "../common/dita-selectors.mod">
 %selectors;
 ]>
 
diff --git a/xslt/dita/html/dita2html-list.xsl b/xslt/dita/html/dita2html-list.xsl
index 6093291..1c063d2 100644
--- a/xslt/dita/html/dita2html-list.xsl
+++ b/xslt/dita/html/dita2html-list.xsl
@@ -16,7 +16,7 @@ Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 02111-1307, USA.
 -->
 <!DOCTYPE xsl:stylesheet [
-<!ENTITY % selectors SYSTEM "selectors.mod">
+<!ENTITY % selectors SYSTEM "../common/dita-selectors.mod">
 %selectors;
 ]>
 
diff --git a/xslt/dita/html/dita2html-topic.xsl b/xslt/dita/html/dita2html-topic.xsl
index 29a46ad..17ea8f2 100644
--- a/xslt/dita/html/dita2html-topic.xsl
+++ b/xslt/dita/html/dita2html-topic.xsl
@@ -16,7 +16,7 @@ Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 02111-1307, USA.
 -->
 <!DOCTYPE xsl:stylesheet [
-<!ENTITY % selectors SYSTEM "selectors.mod">
+<!ENTITY % selectors SYSTEM "../common/dita-selectors.mod">
 %selectors;
 ]>
 
diff --git a/xslt/dita/html/dita2xhtml.xsl b/xslt/dita/html/dita2xhtml.xsl
index be81da0..1e73bd1 100644
--- a/xslt/dita/html/dita2xhtml.xsl
+++ b/xslt/dita/html/dita2xhtml.xsl
@@ -34,11 +34,7 @@ REMARK: Describe this module
 <xsl:import href="../../common/ttml.xsl"/>
 <xsl:import href="../../common/utils.xsl"/>
 
-<!--
-<xsl:import href="../common/mal-gloss.xsl"/>
-<xsl:import href="../common/mal-if.xsl"/>
-<xsl:import href="../common/mal-link.xsl"/>
--->
+<xsl:include href="../common/dita-ref.xsl"/>
 
 <!--
 <xsl:param name="mal.if.target" select="'target:html target:xhtml'"/>
@@ -64,20 +60,5 @@ http://www.w3.org/ns/ttml/feature/#timing
 <xsl:include href="dita2html-inline.xsl"/>
 <xsl:include href="dita2html-list.xsl"/>
 <xsl:include href="dita2html-topic.xsl"/>
-<!--
-<xsl:include href="mal2html-api.xsl"/>
-<xsl:include href="mal2html-block.xsl"/>
-<xsl:include href="mal2html-facets.xsl"/>
-<xsl:include href="mal2html-gloss.xsl"/>
-<xsl:include href="mal2html-inline.xsl"/>
-<xsl:include href="mal2html-links.xsl"/>
-<xsl:include href="mal2html-list.xsl"/>
-<xsl:include href="mal2html-media.xsl"/>
-<xsl:include href="mal2html-page.xsl"/>
-<xsl:include href="mal2html-svg.xsl"/>
-<xsl:include href="mal2html-table.xsl"/>
-<xsl:include href="mal2html-ui.xsl"/>
--->
-
 
 </xsl:stylesheet>



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