]> granicus.if.org Git - docbook-dsssl/commitdiff
First crude beginnings of olink support
authorNorman Walsh <ndw@nwalsh.com>
Wed, 1 Aug 2001 10:36:43 +0000 (10:36 +0000)
committerNorman Walsh <ndw@nwalsh.com>
Wed, 1 Aug 2001 10:36:43 +0000 (10:36 +0000)
xsl/html/param.xsl
xsl/html/xref.xsl
xsl/tools/olink/olink-common.xsl [new file with mode: 0644]
xsl/tools/olink/olink.xsl [new file with mode: 0644]
xsl/tools/olink/olinkchunk.xsl [new file with mode: 0644]
xsl/tools/olink/olinksum.dtd [new file with mode: 0644]

index d212d3ec748400246dbf38973c5ea0af4c5d9589..38e94733a8e4b7e3f57bfc4d9b06c1eab9664f4f 100644 (file)
@@ -1210,4 +1210,10 @@ will be passed through to the HTML as a class attribute on a
 </refdescription>
 </doc:param>
 
+<xsl:param name="olink.fragid" select="'fragid='" doc:type='string'/>
+<xsl:param name="olink.outline.ext" select="'.olink'" doc:type='string'/>
+<xsl:param name="olink.pubid" select="'pubid='" doc:type='string'/>
+<xsl:param name="olink.sysid" select="'sysid='" doc:type='string'/>
+<xsl:param name="olink.resolver" select="'/cgi-bin/olink?'" doc:type='string'/>
+
 </xsl:stylesheet>
index caf1afc9ee6dc0cc2c28c8b60f08ac1c6781b932..3762ad52957f98d4d96f92f3c724767b9d03fc29 100644 (file)
 <xsl:template match="ulink">
   <a>
     <xsl:if test="@id">
-      <xsl:attribute name="name"><xsl:value-of select="@id"/></xsl:attribute>
+      <xsl:attribute name="name">
+        <xsl:value-of select="@id"/>
+      </xsl:attribute>
     </xsl:if>
     <xsl:attribute name="href"><xsl:value-of select="@url"/></xsl:attribute>
     <xsl:if test="$ulink.target != ''">
   <xsl:if test="@id">
     <a name="{@id}"/>
   </xsl:if>
-  <xsl:apply-templates/>
+
+  <xsl:variable name="localinfo" select="@localinfo"/>
+
+  <xsl:variable name="href">
+    <xsl:choose>
+      <xsl:when test="@linkmode">
+        <!-- use the linkmode to get the base URI, use localinfo as fragid -->
+        <xsl:variable name="modespec" select="id(@linkmode)"/>
+        <xsl:if test="count($modespec) != 1
+                      or local-name($modespec) != 'modespec'">
+          <xsl:message>Warning: olink linkmode pointer is wrong.</xsl:message>
+        </xsl:if>
+        <xsl:value-of select="$modespec"/>
+        <xsl:if test="@localinfo">
+          <xsl:text>#</xsl:text>
+          <xsl:value-of select="@localinfo"/>
+        </xsl:if>
+      </xsl:when>
+      <xsl:when test="@type = 'href'">
+        <xsl:call-template name="olink.outline">
+          <xsl:with-param name="outline.base.uri"
+                          select="unparsed-entity-uri(@targetdocent)"/>
+          <xsl:with-param name="localinfo" select="@localinfo"/>
+          <xsl:with-param name="return" select="'href'"/>
+        </xsl:call-template>
+      </xsl:when>
+      <xsl:otherwise>
+        <xsl:value-of select="$olink.resolver"/>
+        <xsl:text>?</xsl:text>
+        <xsl:value-of select="$olink.sysid"/>
+        <xsl:value-of select="unparsed-entity-uri(@targetdocent)"/>
+        <!-- XSL gives no access to the public identifier (grumble...) -->
+        <xsl:if test="@localinfo">
+          <xsl:text>&amp;</xsl:text>
+          <xsl:value-of select="$olink.fragid"/>
+          <xsl:value-of select="@localinfo"/>
+        </xsl:if>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+
+  <a href="{$href}">
+    <xsl:choose>
+      <xsl:when test="count(node()) &gt; 0">
+        <xsl:apply-templates/>
+      </xsl:when>
+      <xsl:otherwise>
+        <xsl:call-template name="olink.outline">
+          <xsl:with-param name="outline.base.uri"
+                          select="unparsed-entity-uri(@targetdocent)"/>
+          <xsl:with-param name="localinfo" select="@localinfo"/>
+          <xsl:with-param name="return" select="'xref'"/>
+        </xsl:call-template>
+      </xsl:otherwise>
+    </xsl:choose>
+  </a>
+</xsl:template>
+
+<xsl:template name="olink.outline">
+  <xsl:param name="outline.base.uri"/>
+  <xsl:param name="localinfo"/>
+  <xsl:param name="return" select="href"/>
+
+  <xsl:variable name="outline-file"
+                select="concat($outline.base.uri,
+                               $olink.outline.ext)"/>
+
+  <xsl:variable name="outline" select="document($outline-file,.)/div"/>
+
+  <xsl:variable name="node-href">
+    <xsl:choose>
+      <xsl:when test="$localinfo != ''">
+        <xsl:variable name="node" select="$outline//*[@id=$localinfo]"/>
+        <xsl:value-of select="$node/@href"/>
+      </xsl:when>
+      <xsl:otherwise>
+        <xsl:value-of select="$outline/@href"/>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+
+  <xsl:variable name="node-xref">
+    <xsl:choose>
+      <xsl:when test="$localinfo != ''">
+        <xsl:variable name="node" select="$outline//*[@id=$localinfo]"/>
+        <xsl:copy-of select="$node/xref"/>
+      </xsl:when>
+      <xsl:otherwise>
+        <xsl:value-of select="$outline/xref"/>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+
+  <xsl:choose>
+    <xsl:when test="$return = 'href'">
+      <xsl:value-of select="$node-href"/>
+    </xsl:when>
+    <xsl:when test="$return = 'xref'">
+      <xsl:value-of select="$node-xref"/>
+    </xsl:when>
+    <xsl:otherwise>
+      <xsl:copy-of select="$node-xref"/>
+    </xsl:otherwise>
+  </xsl:choose>
 </xsl:template>
 
 <!-- ==================================================================== -->
diff --git a/xsl/tools/olink/olink-common.xsl b/xsl/tools/olink/olink-common.xsl
new file mode 100644 (file)
index 0000000..fe46c35
--- /dev/null
@@ -0,0 +1,187 @@
+<?xml version="1.0"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+                version="1.0">
+
+<xsl:template match="/">
+  <xsl:apply-templates mode="olink.mode"/>
+</xsl:template>
+
+<xsl:template name="attrs">
+  <xsl:param name="nd" select="."/>
+
+  <xsl:attribute name="type">
+    <xsl:value-of select="local-name(.)"/>
+  </xsl:attribute>
+
+  <xsl:attribute name="href">
+    <xsl:call-template name="olink.href.target">
+      <xsl:with-param name="object" select="$nd"/>
+    </xsl:call-template>
+  </xsl:attribute>
+
+  <xsl:attribute name="label">
+    <xsl:apply-templates select="$nd" mode="label.markup"/>
+  </xsl:attribute>
+
+  <xsl:if test="$nd/@id">
+    <xsl:attribute name="id">
+      <xsl:value-of select="$nd/@id"/>
+    </xsl:attribute>
+  </xsl:if>
+
+  <xsl:if test="$nd/@arch">
+    <xsl:attribute name="id">
+      <xsl:value-of select="$nd/@arch"/>
+    </xsl:attribute>
+  </xsl:if>
+
+  <xsl:if test="$nd/@conformance">
+    <xsl:attribute name="id">
+      <xsl:value-of select="$nd/@conformance"/>
+    </xsl:attribute>
+  </xsl:if>
+
+  <xsl:if test="$nd/@os">
+    <xsl:attribute name="id">
+      <xsl:value-of select="$nd/@os"/>
+    </xsl:attribute>
+  </xsl:if>
+
+  <xsl:if test="$nd/@revision">
+    <xsl:attribute name="id">
+      <xsl:value-of select="$nd/@revision"/>
+    </xsl:attribute>
+  </xsl:if>
+
+  <xsl:if test="$nd/@userlevel">
+    <xsl:attribute name="id">
+      <xsl:value-of select="$nd/@userlevel"/>
+    </xsl:attribute>
+  </xsl:if>
+
+  <xsl:if test="$nd/@vendor">
+    <xsl:attribute name="id">
+      <xsl:value-of select="$nd/@vendor"/>
+    </xsl:attribute>
+  </xsl:if>
+
+  <xsl:if test="$nd/@condition">
+    <xsl:attribute name="id">
+      <xsl:value-of select="$nd/@condition"/>
+    </xsl:attribute>
+  </xsl:if>
+
+  <xsl:if test="$nd/@security">
+    <xsl:attribute name="id">
+      <xsl:value-of select="$nd/@security"/>
+    </xsl:attribute>
+  </xsl:if>
+</xsl:template>
+
+<xsl:template name="div">
+  <xsl:param name="nd" select="."/>
+
+  <div>
+    <xsl:call-template name="attrs">
+      <xsl:with-param name="nd" select="$nd"/>
+    </xsl:call-template>
+    <ttl>
+      <xsl:apply-templates select="$nd" mode="title.markup"/>
+    </ttl>
+    <objttl>
+      <xsl:apply-templates select="$nd" mode="object.title.markup"/>
+    </objttl>
+    <xref>
+      <xsl:choose>
+        <xsl:when test="$nd/@xreflabel">
+          <xsl:call-template name="xref.xreflabel">
+            <xsl:with-param name="target" select="$nd"/>
+          </xsl:call-template>
+        </xsl:when>
+        <xsl:otherwise>
+          <xsl:apply-templates select="$nd" mode="xref-to"/>
+        </xsl:otherwise>
+      </xsl:choose>
+    </xref>
+    <xsl:apply-templates mode="olink.mode"/>
+  </div>
+</xsl:template>
+
+<xsl:template name="obj">
+  <xsl:param name="nd" select="."/>
+
+  <obj>
+    <xsl:call-template name="attrs">
+      <xsl:with-param name="nd" select="$nd"/>
+    </xsl:call-template>
+    <ttl>
+      <xsl:apply-templates select="$nd" mode="title.markup"/>
+    </ttl>
+    <objttl>
+      <xsl:apply-templates select="$nd" mode="object.title.markup"/>
+    </objttl>
+    <xref>
+      <xsl:choose>
+        <xsl:when test="$nd/@xreflabel">
+          <xsl:call-template name="xref.xreflabel">
+            <xsl:with-param name="target" select="$nd"/>
+          </xsl:call-template>
+        </xsl:when>
+        <xsl:otherwise>
+          <xsl:apply-templates select="$nd" mode="xref-to"/>
+        </xsl:otherwise>
+      </xsl:choose>
+    </xref>
+  </obj>
+</xsl:template>
+
+<xsl:template match="text()|processing-instruction()|comment()"
+              mode="olink.mode">
+  <!-- nop -->
+</xsl:template>
+
+<xsl:template match="*" mode="olink.mode">
+  <!-- nop -->
+</xsl:template>
+
+<xsl:template match="set" mode="olink.mode">
+  <xsl:call-template name="div"/>
+</xsl:template>
+
+<xsl:template match="book" mode="olink.mode">
+  <xsl:call-template name="div"/>
+</xsl:template>
+
+<xsl:template match="preface|chapter|appendix" mode="olink.mode">
+  <xsl:call-template name="div"/>
+</xsl:template>
+
+<xsl:template match="part|reference" mode="olink.mode">
+  <xsl:call-template name="div"/>
+</xsl:template>
+
+<xsl:template match="article" mode="olink.mode">
+  <xsl:call-template name="div"/>
+</xsl:template>
+
+<xsl:template match="refentry" mode="olink.mode">
+  <xsl:call-template name="div"/>
+</xsl:template>
+
+<xsl:template match="section|sect1|sect2|sect3|sect4|sect5" mode="olink.mode">
+  <xsl:call-template name="div"/>
+</xsl:template>
+
+<xsl:template match="refsection|refsect1|refsect2|refsect3" mode="olink.mode">
+  <xsl:call-template name="div"/>
+</xsl:template>
+
+<xsl:template match="figure|example|table" mode="olink.mode">
+  <xsl:call-template name="obj"/>
+</xsl:template>
+
+<xsl:template match="equation[title]" mode="olink.mode">
+  <xsl:call-template name="div"/>
+</xsl:template>
+
+</xsl:stylesheet>
diff --git a/xsl/tools/olink/olink.xsl b/xsl/tools/olink/olink.xsl
new file mode 100644 (file)
index 0000000..e30516c
--- /dev/null
@@ -0,0 +1,24 @@
+<?xml version="1.0"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+                version="1.0">
+
+<xsl:import href="../html/docbook.xsl"/>
+<xsl:include href="olink-common.xsl"/>
+
+<xsl:output method="xml"
+            indent="yes"
+            doctype-public="-//Norman Walsh//DTD DocBook OLink Summary V1.2//EN"
+            doctype-system="http://docbook.sourceforge.net/???"/>
+
+<xsl:param name="base-uri" select="''"/>
+
+<xsl:template name="olink.href.target">
+  <xsl:param name="nd" select="."/>
+
+  <xsl:value-of select="$base-uri"/>
+  <xsl:call-template name="href.target">
+    <xsl:with-param name="object" select="$nd"/>
+  </xsl:call-template>
+</xsl:template>
+
+</xsl:stylesheet>
diff --git a/xsl/tools/olink/olinkchunk.xsl b/xsl/tools/olink/olinkchunk.xsl
new file mode 100644 (file)
index 0000000..f8867cb
--- /dev/null
@@ -0,0 +1,22 @@
+<?xml version="1.0"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+                version="1.0">
+
+<xsl:import href="http://docbook.sourceforge.net/release/xsl/current/html/chunk.xsl"/>
+
+<xsl:include href="olink-common.xsl"/>
+
+<xsl:output method="xml"
+            indent="yes"
+            doctype-public="-//Norman Walsh//DTD DocBook OLink Summary V1.2//EN"
+            doctype-system="http://docbook.sourceforge.net/release/xsl/current/tools/olink/olinksum.dtd"/>
+
+<xsl:template name="olink.href.target">
+  <xsl:param name="nd" select="."/>
+
+  <xsl:call-template name="href.target">
+    <xsl:with-param name="object" select="$nd"/>
+  </xsl:call-template>
+</xsl:template>
+
+</xsl:stylesheet>
diff --git a/xsl/tools/olink/olinksum.dtd b/xsl/tools/olink/olinksum.dtd
new file mode 100644 (file)
index 0000000..fa31ddc
--- /dev/null
@@ -0,0 +1,59 @@
+<!-- $Id$
+
+     DTD for OLINK Summary Information
+
+     Common declaration:
+
+     <!DOCTYPE div
+               PUBLIC "-//Norman Walsh//DTD DocBook OLink Summary V1.2//EN">
+-->
+
+<!ENTITY % commonatts
+"      type            CDATA   #IMPLIED
+       name            CDATA   #IMPLIED
+       href            CDATA   #IMPLIED
+       id              ID      #IMPLIED
+       label           CDATA   #IMPLIED
+       arch            CDATA   #IMPLIED
+       conformance     CDATA   #IMPLIED
+       os              CDATA   #IMPLIED
+       revision        CDATA   #IMPLIED
+       userlevel       CDATA   #IMPLIED
+       vendor          CDATA   #IMPLIED">
+
+<!ELEMENT div (ttl, objttl, xref, obj*, div*)>
+<!ATTLIST div %commonatts;>
+
+<!ELEMENT obj (ttl, objttl, xref)>
+<!ATTLIST obj %commonatts;>
+
+<!ENTITY % inlines "tt|i|sub|sup|span">
+
+<!ELEMENT ttl (#PCDATA|%inlines;)*>
+<!ELEMENT objttl (#PCDATA|%inlines;)*>
+<!ELEMENT xref (#PCDATA|%inlines;)*>
+
+<!ELEMENT tt (#PCDATA|%inlines;)*>   <!-- typewriter (courier) -->
+<!ATTLIST tt
+       class   CDATA   #IMPLIED
+>
+
+<!ELEMENT i (#PCDATA|%inlines;)*>   <!-- italics -->
+<!ATTLIST i
+       class   CDATA   #IMPLIED
+>
+
+<!ELEMENT sub (#PCDATA|%inlines;)*>  <!-- subscript -->
+<!ATTLIST sub
+       class   CDATA   #IMPLIED
+>
+
+<!ELEMENT sup (#PCDATA|%inlines;)*>  <!-- superscript -->
+<!ATTLIST sup
+       class   CDATA   #IMPLIED
+>
+
+<!ELEMENT span (#PCDATA|%inlines;)*> <!-- span -->
+<!ATTLIST span
+       class   CDATA   #IMPLIED
+>