--- /dev/null
+<?xml version='1.0'?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ version='1.0'>
+
+<xsl:template name="add.annotation.links">
+ <xsl:param name="scripts" select="normalize-space($annotation.js)"/>
+ <xsl:choose>
+ <xsl:when test="contains($scripts, ' ')">
+ <script type="text/javascript" src="{substring-before($scripts, ' ')}"/>
+ <xsl:call-template name="add.annotation.links">
+ <xsl:with-param name="scripts" select="substring-after($scripts, ' ')"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <script type="text/javascript" src="{$scripts}"/>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<xsl:template match="annotation"/>
+
+<xsl:template name="apply-annotations">
+ <!-- do any annotations apply to the context node? -->
+ <xsl:variable name="id" select="(@id|@xml:id)[1]"/>
+
+ <xsl:variable name="aids">
+ <xsl:for-each select="//annotation">
+ <xsl:if test="@annotates=$id
+ or starts-with(@annotates, concat($id, ' '))
+ or contains(@annotates, concat(' ', $id, ' '))
+ or substring(@annotates, string-length(@annotates)-3)
+ = concat(' ', $id)">
+ <xsl:value-of select="generate-id()"/>
+ <xsl:text> </xsl:text>
+ </xsl:if>
+ </xsl:for-each>
+ <xsl:if test="normalize-space(@annotations) != ''">
+ <xsl:call-template name="annotations-pointed-to">
+ <xsl:with-param name="annotations"
+ select="normalize-space(@annotations)"/>
+ </xsl:call-template>
+ </xsl:if>
+ </xsl:variable>
+
+ <xsl:if test="$aids != ''">
+ <xsl:call-template name="apply-annotations-by-gid">
+ <xsl:with-param name="gids" select="normalize-space($aids)"/>
+ </xsl:call-template>
+ </xsl:if>
+</xsl:template>
+
+<xsl:template name="annotations-pointed-to">
+ <xsl:param name="annotations"/>
+ <xsl:choose>
+ <xsl:when test="contains($annotations, ' ')">
+ <xsl:variable name='a'
+ select="key('id', substring-before($annotations, ' '))"/>
+ <xsl:if test="$a">
+ <xsl:value-of select="generate-id($a)"/>
+ <xsl:text> </xsl:text>
+ </xsl:if>
+ <xsl:call-template name="annotations-pointed-to">
+ <xsl:with-param name="annotations"
+ select="substring-after($annotations, ' ')"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:variable name='a'
+ select="key('id', $annotations)"/>
+ <xsl:if test="$a">
+ <xsl:value-of select="generate-id($a)"/>
+ <xsl:text> </xsl:text>
+ </xsl:if>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<xsl:template name="apply-annotations-by-gid">
+ <xsl:param name="gids"/>
+
+ <xsl:choose>
+ <xsl:when test="contains($gids, ' ')">
+ <xsl:variable name="gid" select="substring-before($gids, ' ')"/>
+ <xsl:apply-templates select="key('gid', $gid)"
+ mode="annotation-inline"/>
+ <xsl:call-template name="apply-annotations-by-gid">
+ <xsl:with-param name="gids"
+ select="substring-after($gids, ' ')"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-templates select="key('gid', $gids)"
+ mode="annotation-inline"/>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<xsl:template match="annotation" mode="annotation-inline">
+ <xsl:variable name="title">
+ <xsl:choose>
+ <xsl:when test="title">
+ <xsl:value-of select="title"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text>[Annotation #</xsl:text>
+ <xsl:number count="annotation" level="any" format="1"/>
+ <xsl:text>]</xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+
+ <a href="#annot-{generate-id(.)}" title="{$title}"
+ name="anch-{generate-id(.)}" id="anch-{generate-id(.)}">
+ <xsl:attribute name="onClick">
+ <xsl:text>popup_</xsl:text>
+ <xsl:value-of select="generate-id(.)"/>
+ <xsl:text>.showPopup('anch-</xsl:text>
+ <xsl:value-of select="generate-id(.)"/>
+ <xsl:text>'); return false;</xsl:text>
+ </xsl:attribute>
+ <img src="{$annotation.graphic.open}" border="0" alt="{$title}"/>
+ </a>
+</xsl:template>
+
+<xsl:template match="annotation" mode="annotation-popup">
+ <div class="annotation-nocss">
+ <p>
+ <a name="annot-{generate-id(.)}"/>
+ <xsl:text>Annotation #</xsl:text>
+ <xsl:number count="annotation" level="any" format="1"/>
+ <xsl:text>:</xsl:text>
+ </p>
+ </div>
+
+ <div id="popup-{generate-id(.)}" class="annotation-popup">
+ <xsl:if test="string-length(.) > 300">
+ <xsl:attribute name="style">width:400px</xsl:attribute>
+ </xsl:if>
+
+ <xsl:call-template name="annotation-title"/>
+ <div class="annotation-body">
+ <xsl:apply-templates select="*[local-name(.) != 'title']"/>
+ </div>
+ <div class="annotation-close">
+ <a href="#" onclick="popup_{generate-id(.)}.hidePopup();return false;">
+ <img src="{$annotation.graphic.close}" alt="X" border="0"/>
+ </a>
+ </div>
+ </div>
+</xsl:template>
+
+<xsl:template name="annotation-title">
+ <div class="annotation-title">
+ <xsl:choose>
+ <xsl:when test="title">
+ <xsl:apply-templates select="title/node()"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text>Annotation</xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ </div>
+</xsl:template>
+
+</xsl:stylesheet>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:exsl="http://exslt.org/common"
xmlns:cf="http://docbook.sourceforge.net/xmlns/chunkfast/1.0"
+ xmlns:ng="http://docbook.org/docbook-ng"
+ xmlns:db="http://docbook.org/ns/docbook"
version="1.0"
- exclude-result-prefixes="exsl">
+ exclude-result-prefixes="exsl ng db">
<!-- ********************************************************************
$Id$
<xsl:template match="/">
<xsl:choose>
- <xsl:when test="$rootid != ''">
- <xsl:choose>
- <xsl:when test="count(key('id',$rootid)) = 0">
- <xsl:message terminate="yes">
- <xsl:text>ID '</xsl:text>
- <xsl:value-of select="$rootid"/>
- <xsl:text>' not found in document.</xsl:text>
- </xsl:message>
- </xsl:when>
- <xsl:otherwise>
- <xsl:if test="$collect.xref.targets = 'yes' or
- $collect.xref.targets = 'only'">
- <xsl:apply-templates select="key('id', $rootid)"
- mode="collect.targets"/>
- </xsl:if>
- <xsl:if test="$collect.xref.targets != 'only'">
- <xsl:apply-templates select="key('id',$rootid)"
- mode="process.root"/>
- <xsl:if test="$tex.math.in.alt != ''">
- <xsl:apply-templates select="key('id',$rootid)"
- mode="collect.tex.math"/>
- </xsl:if>
- <xsl:if test="$generate.manifest != 0">
- <xsl:call-template name="generate.manifest">
- <xsl:with-param name="node" select="key('id',$rootid)"/>
- </xsl:call-template>
- </xsl:if>
- </xsl:if>
- </xsl:otherwise>
- </xsl:choose>
+ <xsl:when test="function-available('exsl:node-set')
+ and (*/self::ng:* or */self::db:*)">
+ <!-- Hack! If someone hands us a DocBook V5.x or DocBook NG document,
+ toss the namespace and continue. Someday we'll reverse this logic
+ and add the namespace to documents that don't have one.
+ But not before the whole stylesheet has been converted to use
+ namespaces. i.e., don't hold your breath -->
+ <xsl:message>Stripping NS from DocBook 5/NG document.</xsl:message>
+ <xsl:variable name="nons">
+ <xsl:apply-templates mode="stripNS"/>
+ </xsl:variable>
+ <xsl:message>Processing stripped document.</xsl:message>
+ <xsl:apply-templates select="exsl:node-set($nons)"/>
</xsl:when>
<xsl:otherwise>
- <xsl:if test="$collect.xref.targets = 'yes' or
- $collect.xref.targets = 'only'">
- <xsl:apply-templates select="/" mode="collect.targets"/>
- </xsl:if>
- <xsl:if test="$collect.xref.targets != 'only'">
- <xsl:apply-templates select="/" mode="process.root"/>
- <xsl:if test="$tex.math.in.alt != ''">
- <xsl:apply-templates select="/" mode="collect.tex.math"/>
- </xsl:if>
- <xsl:if test="$generate.manifest != 0">
- <xsl:call-template name="generate.manifest">
- <xsl:with-param name="node" select="/"/>
- </xsl:call-template>
- </xsl:if>
- </xsl:if>
+ <xsl:choose>
+ <xsl:when test="$rootid != ''">
+ <xsl:choose>
+ <xsl:when test="count(key('id',$rootid)) = 0">
+ <xsl:message terminate="yes">
+ <xsl:text>ID '</xsl:text>
+ <xsl:value-of select="$rootid"/>
+ <xsl:text>' not found in document.</xsl:text>
+ </xsl:message>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:if test="$collect.xref.targets = 'yes' or
+ $collect.xref.targets = 'only'">
+ <xsl:apply-templates select="key('id', $rootid)"
+ mode="collect.targets"/>
+ </xsl:if>
+ <xsl:if test="$collect.xref.targets != 'only'">
+ <xsl:apply-templates select="key('id',$rootid)"
+ mode="process.root"/>
+ <xsl:if test="$tex.math.in.alt != ''">
+ <xsl:apply-templates select="key('id',$rootid)"
+ mode="collect.tex.math"/>
+ </xsl:if>
+ <xsl:if test="$generate.manifest != 0">
+ <xsl:call-template name="generate.manifest">
+ <xsl:with-param name="node" select="key('id',$rootid)"/>
+ </xsl:call-template>
+ </xsl:if>
+ </xsl:if>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:if test="$collect.xref.targets = 'yes' or
+ $collect.xref.targets = 'only'">
+ <xsl:apply-templates select="/" mode="collect.targets"/>
+ </xsl:if>
+ <xsl:if test="$collect.xref.targets != 'only'">
+ <xsl:apply-templates select="/" mode="process.root"/>
+ <xsl:if test="$tex.math.in.alt != ''">
+ <xsl:apply-templates select="/" mode="collect.tex.math"/>
+ </xsl:if>
+ <xsl:if test="$generate.manifest != 0">
+ <xsl:call-template name="generate.manifest">
+ <xsl:with-param name="node" select="/"/>
+ </xsl:call-template>
+ </xsl:if>
+ </xsl:if>
+ </xsl:otherwise>
+ </xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:call-template>
</div>
</xsl:if>
+
+ <!-- FIXME: When chunking, only the annotations actually used
+ in this chunk should be referenced. I don't think it
+ does any harm to reference them all, but it adds
+ unnecessary bloat to each chunk. -->
+ <xsl:if test="$annotation.support != 0 and //annotation">
+ <div class="annotation-list">
+ <div class="annotation-nocss">
+ <p>The following annotations are from this essay. You are seeing
+ them here because your browser doesn’t support the user-interface
+ techniques used to make them appear as ‘popups’ on modern browsers.</p>
+ </div>
+
+ <xsl:apply-templates select="//annotation"
+ mode="annotation-popup"/>
+ </div>
+ </xsl:if>
</xsl:template>
<xsl:template name="process.chunk.footnotes">
<xsl:include href="chunker.xsl"/>
<xsl:include href="html-rtf.xsl"/>
<xsl:include href="docbookng.xsl"/>
+<xsl:include href="annotations.xsl"/>
<xsl:param name="stylesheet.result.type" select="'html'"/>
<xsl:param name="htmlhelp.output" select="0"/>
<!-- ==================================================================== -->
<xsl:key name="id" match="*" use="@id|@xml:id"/>
+<xsl:key name="gid" match="*" use="generate-id()"/>
<!-- ==================================================================== -->
<xsl:template name="system.head.content">
<xsl:param name="node" select="."/>
+ <!-- FIXME: When chunking, only the annotations actually used
+ in this chunk should be referenced. I don't think it
+ does any harm to reference them all, but it adds
+ unnecessary bloat to each chunk. -->
+ <xsl:if test="$annotation.support != 0 and //annotation">
+ <xsl:call-template name="add.annotation.links"/>
+ <script type="text/javascript">
+ <xsl:text> // Create PopupWindow objects</xsl:text>
+ <xsl:for-each select="//annotation">
+ <xsl:text> var popup_</xsl:text>
+ <xsl:value-of select="generate-id(.)"/>
+ <xsl:text> = new PopupWindow("popup-</xsl:text>
+ <xsl:value-of select="generate-id(.)"/>
+ <xsl:text>"); </xsl:text>
+ <xsl:text>popup_</xsl:text>
+ <xsl:value-of select="generate-id(.)"/>
+ <xsl:text>.offsetY = 15; </xsl:text>
+ <xsl:text>popup_</xsl:text>
+ <xsl:value-of select="generate-id(.)"/>
+ <xsl:text>.autoHide(); </xsl:text>
+ </xsl:for-each>
+ </script>
+
+ <style type="text/css">
+/* ======================================================================
+ Annotations
+*/
+
+div.annotation-list { visibility: hidden;
+ }
+
+div.annotation-nocss { position: absolute;
+ visibility: hidden;
+ }
+
+div.annotation-popup { position: absolute;
+ z-index: 4;
+ visibility: hidden;
+ padding: 0px;
+ margin: 2px;
+ border-style: solid;
+ border-width: 1px;
+ width: 200px
+ }
+
+div.annotation-title { padding: 1px;
+ font-weight: bold;
+ border-bottom-style: solid;
+ border-bottom-width: 1px;
+ }
+
+div.annotation-body { padding: 2px;
+ }
+
+div.annotation-body p { margin-top: 0px;
+ padding-top: 0px;
+ }
+
+div.annotation-close { position: absolute;
+ top: 2px;
+ right: 2px;
+ }
+ </style>
+ </xsl:if>
+
<!-- system.head.content is like user.head.content, except that
it is called before head.content. This is important because it
means, for example, that <style> elements output by system.head.content
<xsl:apply-templates select="$footnotes" mode="process.footnote.mode"/>
</div>
</xsl:if>
+
+ <xsl:if test="$annotation.support != 0 and //annotation">
+ <div class="annotation-list">
+ <div class="annotation-nocss">
+ <p>The following annotations are from this essay. You are seeing
+ them here because your browser doesn’t support the user-interface
+ techniques used to make them appear as ‘popups’ on modern browsers.</p>
+ </div>
+
+ <xsl:apply-templates select="//annotation"
+ mode="annotation-popup"/>
+ </div>
+ </xsl:if>
</xsl:template>
<xsl:template name="process.chunk.footnotes">
</xsl:attribute>
</xsl:if>
<xsl:copy-of select="$content"/>
+ <xsl:call-template name="apply-annotations"/>
</span>
</xsl:template>
</xsl:attribute>
</xsl:if>
<xsl:copy-of select="$content"/>
+ <xsl:call-template name="apply-annotations"/>
</code>
</xsl:template>
</strong>
</xsl:otherwise>
</xsl:choose>
+ <xsl:call-template name="apply-annotations"/>
</span>
</xsl:template>
</xsl:attribute>
</xsl:if>
<xsl:copy-of select="$content"/>
+ <xsl:call-template name="apply-annotations"/>
</em>
</xsl:template>
</xsl:attribute>
</xsl:if>
<xsl:copy-of select="$content"/>
+ <xsl:call-template name="apply-annotations"/>
</code>
</xsl:when>
<xsl:otherwise>
</xsl:if>
<xsl:copy-of select="$content"/>
</code>
+ <xsl:call-template name="apply-annotations"/>
</strong>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
</xsl:if>
<xsl:copy-of select="$content"/>
+ <xsl:call-template name="apply-annotations"/>
</code>
</em>
</xsl:template>
</xsl:attribute>
</xsl:if>
<xsl:copy-of select="$content"/>
+ <xsl:call-template name="apply-annotations"/>
</sup>
</xsl:template>
</xsl:attribute>
</xsl:if>
<xsl:copy-of select="$content"/>
+ <xsl:call-template name="apply-annotations"/>
</sub>
</xsl:template>
<span class="{name(.)}">
<xsl:call-template name="anchor"/>
<xsl:call-template name="person.name"/>
+ <xsl:call-template name="apply-annotations"/>
</span>
</xsl:template>
<span class="{name(.)}">
<xsl:call-template name="anchor"/>
<xsl:call-template name="person.name"/>
+ <xsl:call-template name="apply-annotations"/>
</span>
</xsl:template>
<span class="{name(.)}">
<xsl:call-template name="anchor"/>
<xsl:call-template name="person.name"/>
+ <xsl:call-template name="apply-annotations"/>
</span>
</xsl:template>
<xsl:apply-templates/>
</xsl:with-param>
</xsl:call-template>
+ <xsl:call-template name="apply-annotations"/>
</span>
</xsl:template>
<!ENTITY insert.xref.page.number SYSTEM "../params/insert.xref.page.number.xml">
<!ENTITY component.label.includes.part.label SYSTEM "../params/component.label.includes.part.label.xml">
<!ENTITY simplesect.in.toc SYSTEM "../params/simplesect.in.toc.xml">
+<!ENTITY annotation.support SYSTEM "../params/annotation.support.xml">
+<!ENTITY annotation.js SYSTEM "../params/annotation.js.xml">
+<!ENTITY annotation.graphic.open SYSTEM "../params/annotation.graphic.open.xml">
+<!ENTITY annotation.graphic.close SYSTEM "../params/annotation.graphic.close.xml">
&insert.xref.page.number;
</reference>
+<reference><title>Annotations</title>
+&annotation.support;
+&annotation.js;
+&annotation.graphic.open;
+&annotation.graphic.close;
+</reference>
+
<reference><title>Graphics</title>
&img.src.path;
&graphic.default.extension;
<src:fragref linkend="admon.style.frag"/>
<src:fragref linkend="admon.textlabel.frag"/>
<src:fragref linkend="annotate.toc.frag"/>
+<src:fragref linkend="annotation.js.frag"/>
+<src:fragref linkend="annotation.graphic.open.frag"/>
+<src:fragref linkend="annotation.graphic.close.frag"/>
+<src:fragref linkend="annotation.support.frag"/>
<src:fragref linkend="appendix.autolabel.frag"/>
<src:fragref linkend="author.othername.in.middle.frag"/>
<src:fragref linkend="autotoc.label.separator.frag"/>
--- /dev/null
+<refentry id="annotation.graphic.close">
+<refmeta>
+<refentrytitle>annotation.graphic.close</refentrytitle>
+<refmiscinfo role="type">boolean</refmiscinfo>
+</refmeta>
+<refnamediv>
+<refname>annotation.graphic.close</refname>
+<refpurpose>Enable annotations?</refpurpose>
+</refnamediv>
+
+<refsynopsisdiv>
+<src:fragment id='annotation.graphic.close.frag'>
+<xsl:param name="annotation.graphic.close"
+ select="'http://docbook.sourceforge.net/release/images/annot-close.png'"/>
+</src:fragment>
+</refsynopsisdiv>
+
+<refsect1><title>Description</title>
+
+<para>This image is used on popup annotations as the “x” that the
+user can click to dismiss the popup.</para>
+
+</refsect1>
+</refentry>
--- /dev/null
+<refentry id="annotation.graphic.open">
+<refmeta>
+<refentrytitle>annotation.graphic.open</refentrytitle>
+<refmiscinfo role="type">boolean</refmiscinfo>
+</refmeta>
+<refnamediv>
+<refname>annotation.graphic.open</refname>
+<refpurpose>Enable annotations?</refpurpose>
+</refnamediv>
+
+<refsynopsisdiv>
+<src:fragment id='annotation.graphic.open.frag'>
+<xsl:param name="annotation.graphic.open"
+ select="'http://docbook.sourceforge.net/release/images/annot-open.png'"/>
+</src:fragment>
+</refsynopsisdiv>
+
+<refsect1><title>Description</title>
+
+<para>This image is used inline to identify the location of
+annotations.</para>
+
+</refsect1>
+</refentry>
--- /dev/null
+<refentry id="annotation.js">
+<refmeta>
+<refentrytitle>annotation.js</refentrytitle>
+<refmiscinfo role="type">boolean</refmiscinfo>
+</refmeta>
+<refnamediv>
+<refname>annotation.js</refname>
+<refpurpose>Enable annotations?</refpurpose>
+</refnamediv>
+
+<refsynopsisdiv>
+<src:fragment id='annotation.js.frag'>
+<xsl:param name="annotation.js"
+ select="'http://docbook.sourceforge.net/release/script/AnchorPosition.js
+ http://docbook.sourceforge.net/release/script/PopupWindow.js'"/>
+</src:fragment>
+</refsynopsisdiv>
+
+<refsect1><title>Description</title>
+
+<para>If <property>annotation.support</property> is enabled and the
+document contains <sgmltag>annotation</sgmltag>s, then the URIs listed
+in this parameter will be included. These JavaScript files are required
+for popup annotation support.</para>
+
+</refsect1>
+</refentry>
--- /dev/null
+<refentry id="annotation.support">
+<refmeta>
+<refentrytitle>annotation.support</refentrytitle>
+<refmiscinfo role="type">boolean</refmiscinfo>
+</refmeta>
+<refnamediv>
+<refname>annotation.support</refname>
+<refpurpose>Enable annotations?</refpurpose>
+</refnamediv>
+
+<refsynopsisdiv>
+<src:fragment id='annotation.support.frag'>
+<xsl:param name="annotation.support" select="1"/>
+</src:fragment>
+</refsynopsisdiv>
+
+<refsect1><title>Description</title>
+
+<para>If non-zero, the stylesheets will attempt to support annotation
+elements in HTML by including some JavaScript (see
+<parameter>annotation.js</parameter>).</para>
+
+</refsect1>
+</refentry>