--- /dev/null
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ version="1.0">
+
+<!-- DocBook stylesheet driver file for processing DocBook
+ documents for chunked HTML output using a target database
+ for resolving olinks.
+
+ Adjust this relative reference for importing the
+ standard chunk.xsl file.
+ -->
+
+
+<xsl:import href="../../docbook-xsl-1.45/html/chunk.xsl"/>
+<xsl:output method="html" indent="yes" encoding="UTF-8"/>
+
+<xsl:param name="target.database.document" select="''"/>
+<xsl:param name="use.id.as.filename" select="'1'"/>
+<xsl:param name="quiet" select="1"/>
+
+<xsl:include href="newolink.xsl"/>
+
+</xsl:stylesheet>
+
--- /dev/null
+<?xml version="1.0"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:t="http://sagehill.net/xsl/target/1.0"
+ version="1.0">
+
+<!-- Extracts cross reference target information from
+ a document that is going to be chunked in HTML output
+
+ Adjust this relative reference for importing the
+ standard chunk.xsl file.
+-->
+
+<xsl:import href="../../docbook-xsl-1.45/html/chunk.xsl"/>
+<xsl:include href="olink-common.xsl"/>
+
+<xsl:output method="xml" indent="yes"/>
+
+<xsl:param name="base-uri" select="''"/>
+<xsl:param name="use.id.as.filename" select="'1'"/>
+
+<xsl:param name="local.l10n.xml" select="document('')"/>
+<l:i18n xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0">
+ <l:l10n language="en">
+ <l:context name="xref">
+ <l:template name="refentry" text="%t"/>
+ </l:context>
+ <l:context name="section-xref">
+ <l:template name="refsect1" text="%t"/>
+ </l:context>
+ <l:gentext key="refsect1" text="Refsect1"/>
+ </l:l10n>
+</l:i18n>
+
+<xsl:template match="refentry" mode="xref-to">
+ <xsl:apply-templates select="." mode="object.xref.markup"/>
+</xsl:template>
+
+
+<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="obj" select="$nd"/>
+ </xsl:call-template>
+</xsl:template>
+
+</xsl:stylesheet>
--- /dev/null
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ version="1.0">
+
+<!-- DocBook stylesheet driver file for processing DocBook
+ documents for single-file HTML output using a target database
+ for resolving olinks.
+
+ Adjust this relative reference for importing the
+ standard docbook.xsl file.
+-->
+
+<xsl:import href="../../docbook-xsl-1.45/html/docbook.xsl"/>
+<xsl:output method="html" indent="yes" encoding="UTF-8"/>
+
+<xsl:param name="target.database.document" select="''"/>
+
+<xsl:include href="newolink.xsl"/>
+
+</xsl:stylesheet>
+
--- /dev/null
+<?xml version='1.0'?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:t="http://sagehill.net/xsl/target/1.0"
+ exclude-result-prefixes="t"
+ version='1.0'>
+
+<!-- New olink template to process olinks using an
+ external cross reference database
+ If an olink does not use a type="stylesheet" attribute,
+ then the behavior reverts to the old olink by
+ applying imports for the olink template from the
+ standard stylesheet.
+-->
+
+<xsl:template match="olink">
+
+ <!-- Open the database document passed on the command line -->
+ <xsl:variable name="target.database"
+ select="document($target.database.document)"/>
+
+ <!-- Future feature to assemble generated text using local stylesheet -->
+ <xsl:variable name="olink.styled.locally" select="0"/>
+
+
+<!-- You can uncomment these message to see what is going on.
+<xsl:message>
+ The database name is <xsl:value-of select="$target.database.document"/>
+ The targetset is <xsl:value-of select="$target.database/t:targetset"/>
+</xsl:message>
+-->
+
+<xsl:choose>
+ <xsl:when test="@type='stylesheet'">
+ <xsl:choose>
+ <xsl:when test="@targetdoc and @targetid">
+
+ <!-- Open data file for this document -->
+ <xsl:variable name="targetdatafilename" select="$target.database/t:targetset/t:document[@targetdoc=current()/@targetdoc]/@href" />
+ <xsl:variable name="targetdocset" select="document($target.database/t:targetset/t:document[@targetdoc=current()/@targetdoc]/@href)"/>
+
+ <!-- Get the cross reference href -->
+ <xsl:variable name="target.href" select="$targetdocset//*[@targetid=current()/@targetid]/@href"/>
+
+ <xsl:variable name="baseuri" select="$target.database/t:targetset/t:document[@targetdoc=current()/@targetdoc]/@baseuri"/>
+ <xsl:variable name="href">
+ <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>
+ <xsl:value-of select="$target.href"/>
+ </xsl:variable>
+
+ <!-- Uncomment to see what is going on
+ <xsl:message>
+ Opening document data file <xsl:value-of select="$targetdatafilename"/>
+ targetdoc is <xsl:value-of select="current()/@targetdoc"/>
+ targetid is <xsl:value-of select="current()/@targetid"/>
+ baseuri is <xsl:value-of select="$baseuri"/>
+ target.href is <xsl:value-of select="$target.href"/>
+ href is <xsl:value-of select="$href"/></xsl:message>
+ -->
+
+ <!-- Start the HTML output -->
+ <a href="{$href}">
+
+ <xsl:choose>
+ <!-- If olink has content, use it -->
+ <xsl:when test="count(child::node()) > 0">
+ <xsl:apply-templates/>
+ </xsl:when>
+ <!-- Otherwise generate the text -->
+ <xsl:otherwise>
+ <xsl:choose>
+ <xsl:when test="$olink.styled.locally">
+ <!-- no-op until implemented
+ <xsl:call-template name="olink.localstyle">
+ </xsl:call-template>
+ -->
+ </xsl:when>
+ <xsl:otherwise>
+ <!-- Use the text from the database -->
+ <xsl:variable name="xref.text" select="$targetdocset//*[@targetid=current()/@targetid]/t:xreftext"/>
+
+ <!-- Uncomment to display the text
+<xsl:message> xref.text is <xsl:value-of select="$xref.text"/>
+</xsl:message>
+ -->
+ <xsl:choose>
+ <xsl:when test="$xref.text">
+ <xsl:value-of select="$xref.text"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:message>
+ Olink text not available
+ </xsl:message>
+ <xsl:text>MISSING OLINK TEXT</xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:otherwise>
+ </xsl:choose>
+
+ <!-- Close the anchor tag -->
+ </a>
+
+ <!-- Generate 'in document title' -->
+ <xsl:variable name="doctitle"
+ select="$targetdocset/t:div[1]/t:ttl"/>
+ <xsl:if test="$doctitle">
+ <xsl:text> in </xsl:text>
+ <xsl:value-of select="$doctitle"/>
+ </xsl:if>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:message>
+ Olink of type of stylesheet is missing either targetdoc or targetid attribute.
+ </xsl:message>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:otherwise>
+ <!-- use the standard olink template -->
+ <xsl:apply-imports/>
+ </xsl:otherwise>
+</xsl:choose>
+
+</xsl:template>
+
+</xsl:stylesheet>
--- /dev/null
+<?xml version="1.0"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:t="http://sagehill.net/xsl/target/1.0"
+ version="1.0">
+
+<!-- Templates for extracting cross reference information
+ from a document for use in an xref database.
+ It is included by targets.xsl and chunktargets.xsl.
+ This was modified from Norm Walsh's original olink-common.xsl.
+-->
+
+<xsl:template match="/">
+ <xsl:apply-templates mode="olink.mode"/>
+</xsl:template>
+
+<xsl:template name="attrs">
+ <xsl:param name="nd" select="."/>
+
+ <xsl:attribute name="element">
+ <xsl:value-of select="local-name(.)"/>
+ </xsl:attribute>
+
+ <xsl:attribute name="href">
+ <xsl:call-template name="olink.href.target">
+ <xsl:with-param name="obj" select="$nd"/>
+ </xsl:call-template>
+ </xsl:attribute>
+
+ <xsl:attribute name="name">
+ <xsl:call-template name="gentext.element.name"/>
+ </xsl:attribute>
+
+ <xsl:variable name="num">
+ <xsl:apply-templates select="$nd" mode="label.markup"/>
+ </xsl:variable>
+
+ <xsl:if test="$num">
+ <xsl:attribute name="number">
+ <xsl:value-of select="$num"/>
+ </xsl:attribute>
+ </xsl:if>
+
+ <xsl:if test="$nd/@id">
+ <xsl:attribute name="targetid">
+ <xsl:value-of select="$nd/@id"/>
+ </xsl:attribute>
+ </xsl:if>
+
+ <xsl:if test="$nd/@lang">
+ <xsl:attribute name="lang">
+ <xsl:value-of select="$nd/@lang"/>
+ </xsl:attribute>
+ </xsl:if>
+
+</xsl:template>
+
+<xsl:template name="div">
+ <xsl:param name="nd" select="."/>
+
+ <t:div>
+ <xsl:call-template name="attrs">
+ <xsl:with-param name="nd" select="$nd"/>
+ </xsl:call-template>
+ <t:ttl>
+ <xsl:apply-templates select="$nd" mode="title.markup"/>
+ </t:ttl>
+<!-- <t:divttl>
+ <xsl:apply-templates select="$nd" mode="object.title.markup"/>
+ </t:divttl>
+-->
+ <t:xreftext>
+ <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>
+ </t:xreftext>
+ <t:page>
+ </t:page>
+ <xsl:apply-templates mode="olink.mode"/>
+ </t:div>
+</xsl:template>
+
+<xsl:template name="obj">
+ <xsl:param name="nd" select="."/>
+
+ <t:obj>
+ <xsl:call-template name="attrs">
+ <xsl:with-param name="nd" select="$nd"/>
+ </xsl:call-template>
+ <t:ttl>
+ <xsl:apply-templates select="$nd" mode="title.markup"/>
+ </t:ttl>
+<!-- <t:objttl>
+ <xsl:apply-templates select="$nd" mode="object.title.markup"/>
+ </t:objttl>
+-->
+ <t:xreftext>
+ <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>
+ </t:xreftext>
+ </t:obj>
+</xsl:template>
+
+<xsl:template match="text()|processing-instruction()|comment()"
+ mode="olink.mode">
+ <!-- nop -->
+</xsl:template>
+
+<!--
+<xsl:template match="*" mode="olink.mode">
+</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="obj"/>
+</xsl:template>
+
+<xsl:template match="*" mode="olink.mode">
+ <xsl:if test="@id">
+ <xsl:call-template name="obj"/>
+ </xsl:if>
+</xsl:template>
+
+</xsl:stylesheet>
--- /dev/null
+<!-- targetdatabase.dtd -->
+<!-- A DTD for managing cross reference target information -->
+
+<!ELEMENT targetset (targetsetinfo?, document+) >
+
+<!ELEMENT targetsetinfo (#PCDATA) >
+
+<!ELEMENT document (div*) >
+<!ATTLIST document
+ targetdoc CDATA #REQUIRED
+ uri CDATA #IMPLIED
+ baseuri CDATA #IMPLIED
+ href CDATA #IMPLIED
+>
+
+<!ELEMENT div (ttl?, objttl?, xreftext?, page?, (div|obj)*)>
+<!ATTLIST div
+ targetid CDATA #REQUIRED
+ element CDATA #IMPLIED
+ name CDATA #IMPLIED
+ number CDATA #IMPLIED
+ href CDATA #IMPLIED
+ lang CDATA #IMPLIED
+>
+
+
+<!ELEMENT ttl (#PCDATA)>
+<!ELEMENT objttl (#PCDATA)>
+<!ELEMENT xreftext (#PCDATA)>
+<!ELEMENT page (#PCDATA)>
+
+<!ELEMENT obj (ttl?, objttl?, xreftext?, page?)>
+<!ATTLIST obj
+ targetid CDATA #REQUIRED
+ element CDATA #IMPLIED
+ name CDATA #IMPLIED
+ number CDATA #IMPLIED
+ href CDATA #IMPLIED
+ lang CDATA #IMPLIED
+>
--- /dev/null
+<?xml version="1.0"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:t="http://sagehill.net/xsl/target/1.0"
+ version="1.0">
+
+<!-- Extracts cross reference target information from
+ a document that is going to be output non-chunked in HTML.
+
+ Adjust this relative reference for importing the
+ standard docbook.xsl file.
+-->
+
+<xsl:import href="../../docbook-xsl-1.45/html/docbook.xsl"/>
+<xsl:include href="olink-common.xsl"/>
+
+<xsl:output method="xml" indent="yes" />
+
+<xsl:param name="base-uri" select="''"/>
+
+<xsl:param name="local.l10n.xml" select="document('')"/>
+<l:l10n language="en" xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0">
+ <l:context name="xref">
+ <l:template name="refentry" text="%t"/>
+ </l:context>
+</l:l10n>
+
+<xsl:template match="refentry" mode="xref-to">
+ <xsl:apply-templates select="." mode="object.xref.markup"/>
+</xsl:template>
+
+
+
+<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="obj" select="$nd"/>
+ </xsl:call-template>
+</xsl:template>
+
+</xsl:stylesheet>